diff options
-rw-r--r-- | nexgb/bigreq/bigreq.go | 20 | ||||
-rw-r--r-- | nexgb/composite/composite.go | 578 | ||||
-rw-r--r-- | nexgb/damage/damage.go | 346 | ||||
-rw-r--r-- | nexgb/dpms/dpms.go | 544 | ||||
-rw-r--r-- | nexgb/dri2/dri2.go | 894 | ||||
-rw-r--r-- | nexgb/ge/ge.go | 20 | ||||
-rw-r--r-- | nexgb/glx/glx.go | 7938 | ||||
-rw-r--r-- | nexgb/randr/randr.go | 3982 | ||||
-rw-r--r-- | nexgb/record/record.go | 838 | ||||
-rw-r--r-- | nexgb/render/render.go | 3690 | ||||
-rw-r--r-- | nexgb/res/res.go | 318 | ||||
-rw-r--r-- | nexgb/screensaver/screensaver.go | 336 | ||||
-rw-r--r-- | nexgb/shape/shape.go | 692 | ||||
-rw-r--r-- | nexgb/shm/shm.go | 526 | ||||
-rw-r--r-- | nexgb/sync/sync.go | 1988 | ||||
-rw-r--r-- | nexgb/xcmisc/xcmisc.go | 164 | ||||
-rw-r--r-- | nexgb/xevie/xevie.go | 292 | ||||
-rw-r--r-- | nexgb/xf86dri/xf86dri.go | 918 | ||||
-rw-r--r-- | nexgb/xf86vidmode/xf86vidmode.go | 2376 | ||||
-rw-r--r-- | nexgb/xfixes/xfixes.go | 2212 | ||||
-rw-r--r-- | nexgb/xinerama/xinerama.go | 394 | ||||
-rw-r--r-- | nexgb/xinput/xinput.go | 7870 | ||||
-rw-r--r-- | nexgb/xprint/xprint.go | 2270 | ||||
-rw-r--r-- | nexgb/xproto/xproto.go | 16348 | ||||
-rw-r--r-- | nexgb/xselinux/xselinux.go | 1612 | ||||
-rw-r--r-- | nexgb/xtest/xtest.go | 212 | ||||
-rw-r--r-- | nexgb/xv/xv.go | 2356 | ||||
-rw-r--r-- | nexgb/xvmc/xvmc.go | 700 |
28 files changed, 30267 insertions, 30167 deletions
diff --git a/nexgb/bigreq/bigreq.go b/nexgb/bigreq/bigreq.go index af03110..2ff767a 100644 --- a/nexgb/bigreq/bigreq.go +++ b/nexgb/bigreq/bigreq.go @@ -2,7 +2,7 @@ package bigreq /* - This file was generated by bigreq.xml on Jun 5 2012 12:11:58am EDT. + This file was generated by bigreq.xml on Aug 11 2013 8:39:42pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,30 +40,30 @@ func init() { xgb.NewExtErrorFuncs["BIG-REQUESTS"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Void' +// Skipping definition for base type 'Bool' // Skipping definition for base type 'Byte' -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' +// Skipping definition for base type 'Card8' // Skipping definition for base type 'Char' -// Skipping definition for base type 'Card32' +// Skipping definition for base type 'Void' // 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 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + // EnableCookie is a cookie used only for Enable requests. type EnableCookie struct { *xgb.Cookie diff --git a/nexgb/composite/composite.go b/nexgb/composite/composite.go index d1f19b9..de1b773 100644 --- a/nexgb/composite/composite.go +++ b/nexgb/composite/composite.go @@ -2,7 +2,7 @@ package composite /* - This file was generated by composite.xml on Jun 5 2012 12:11:58am EDT. + This file was generated by composite.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,74 +41,131 @@ func init() { xgb.NewExtErrorFuncs["Composite"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int32' +const ( + RedirectAutomatic = 0 + RedirectManual = 1 +) -// Skipping definition for base type 'Void' +// 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 'Char' - // Skipping definition for base type 'Card32' -// Skipping definition for base type 'Double' +// CreateRegionFromBorderClipCookie is a cookie used only for CreateRegionFromBorderClip requests. +type CreateRegionFromBorderClipCookie struct { + *xgb.Cookie +} -// Skipping definition for base type 'Bool' +// CreateRegionFromBorderClip sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateRegionFromBorderClip(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { + if _, ok := c.Extensions["COMPOSITE"]; !ok { + panic("Cannot issue request 'CreateRegionFromBorderClip' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) + return CreateRegionFromBorderClipCookie{cookie} +} -// Skipping definition for base type 'Float' +// CreateRegionFromBorderClipChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromBorderClipCookie.Check() +func CreateRegionFromBorderClipChecked(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { + if _, ok := c.Extensions["COMPOSITE"]; !ok { + panic("Cannot issue request 'CreateRegionFromBorderClip' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) + return CreateRegionFromBorderClipCookie{cookie} +} -// Skipping definition for base type 'Card8' +// 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 CreateRegionFromBorderClipCookie) Check() error { + return cook.Cookie.Check() +} -// Skipping definition for base type 'Int16' +// Write request to wire for CreateRegionFromBorderClip +// createRegionFromBorderClipRequest writes a CreateRegionFromBorderClip request to a byte slice. +func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) []byte { + size := 12 + b := 0 + buf := make([]byte, size) -const ( - RedirectAutomatic = 0 - RedirectManual = 1 -) + buf[b] = c.Extensions["COMPOSITE"] + b += 1 -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { + 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:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// GetOverlayWindowCookie is a cookie used only for GetOverlayWindow requests. +type GetOverlayWindowCookie 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { +// GetOverlayWindow sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOverlayWindowCookie.Reply() +func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(getOverlayWindowRequest(c, Window), cookie) + return GetOverlayWindowCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// GetOverlayWindowUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { +func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(getOverlayWindowRequest(c, Window), cookie) + return GetOverlayWindowCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// GetOverlayWindowReply represents the data returned from a GetOverlayWindow request. +type GetOverlayWindowReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + OverlayWin xproto.Window + // padding: 20 bytes } -// 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 GetOverlayWindow request. +func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -116,12 +173,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return getOverlayWindowReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// getOverlayWindowReply reads a byte slice into a GetOverlayWindowReply value. +func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { + v := new(GetOverlayWindowReply) b := 1 // skip reply determinant b += 1 // padding @@ -132,78 +189,72 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) + v.OverlayWin = xproto.Window(xgb.Get32(buf[b:])) b += 4 - b += 16 // padding + b += 20 // padding return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 +// Write request to wire for GetOverlayWindow +// getOverlayWindowRequest writes a GetOverlayWindow request to a byte slice. +func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 0 // request opcode + 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:], ClientMajorVersion) - b += 4 - - xgb.Put32(buf[b:], ClientMinorVersion) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// RedirectWindowCookie is a cookie used only for RedirectWindow requests. -type RedirectWindowCookie struct { +// NameWindowPixmapCookie is a cookie used only for NameWindowPixmap requests. +type NameWindowPixmapCookie struct { *xgb.Cookie } -// RedirectWindow sends an unchecked request. +// NameWindowPixmap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RedirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { +func NameWindowPixmap(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'RedirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'NameWindowPixmap' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) - return RedirectWindowCookie{cookie} + c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) + return NameWindowPixmapCookie{cookie} } -// RedirectWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using RedirectWindowCookie.Check() -func RedirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { +// NameWindowPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using NameWindowPixmapCookie.Check() +func NameWindowPixmapChecked(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'RedirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'NameWindowPixmap' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) - return RedirectWindowCookie{cookie} + c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) + return NameWindowPixmapCookie{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 RedirectWindowCookie) Check() error { +func (cook NameWindowPixmapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RedirectWindow -// redirectWindowRequest writes a RedirectWindow request to a byte slice. -func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { +// Write request to wire for NameWindowPixmap +// nameWindowPixmapRequest writes a NameWindowPixmap request to a byte slice. +func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -211,7 +262,7 @@ func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byt buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -220,50 +271,88 @@ func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byt xgb.Put32(buf[b:], uint32(Window)) b += 4 - buf[b] = Update - b += 1 - - b += 3 // padding + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 return buf } -// RedirectSubwindowsCookie is a cookie used only for RedirectSubwindows requests. -type RedirectSubwindowsCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// RedirectSubwindows sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { +// 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'RedirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) - return RedirectSubwindowsCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// RedirectSubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using RedirectSubwindowsCookie.Check() -func RedirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { +// 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'RedirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) - return RedirectSubwindowsCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{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 RedirectSubwindowsCookie) Check() error { - return cook.Cookie.Check() +// 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 + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes } -// Write request to wire for RedirectSubwindows -// redirectSubwindowsRequest writes a RedirectSubwindows request to a byte slice. -func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { +// 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.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -271,59 +360,57 @@ func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) [ buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 0 // 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)) + xgb.Put32(buf[b:], ClientMajorVersion) b += 4 - buf[b] = Update - b += 1 - - b += 3 // padding + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 return buf } -// UnredirectWindowCookie is a cookie used only for UnredirectWindow requests. -type UnredirectWindowCookie struct { +// RedirectSubwindowsCookie is a cookie used only for RedirectSubwindows requests. +type RedirectSubwindowsCookie struct { *xgb.Cookie } -// UnredirectWindow sends an unchecked request. +// RedirectSubwindows sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnredirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { +func RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'UnredirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'RedirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) - return UnredirectWindowCookie{cookie} + c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) + return RedirectSubwindowsCookie{cookie} } -// UnredirectWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using UnredirectWindowCookie.Check() -func UnredirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { +// RedirectSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using RedirectSubwindowsCookie.Check() +func RedirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'UnredirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'RedirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) - return UnredirectWindowCookie{cookie} + c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) + return RedirectSubwindowsCookie{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 UnredirectWindowCookie) Check() error { +func (cook RedirectSubwindowsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnredirectWindow -// unredirectWindowRequest writes a UnredirectWindow request to a byte slice. -func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { +// Write request to wire for RedirectSubwindows +// redirectSubwindowsRequest writes a RedirectSubwindows request to a byte slice. +func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -331,7 +418,7 @@ func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []b buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -348,42 +435,42 @@ func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []b return buf } -// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. -type UnredirectSubwindowsCookie struct { +// RedirectWindowCookie is a cookie used only for RedirectWindow requests. +type RedirectWindowCookie struct { *xgb.Cookie } -// UnredirectSubwindows sends an unchecked request. +// RedirectWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { +func RedirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'UnredirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'RedirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) - return UnredirectSubwindowsCookie{cookie} + c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) + return RedirectWindowCookie{cookie} } -// UnredirectSubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using UnredirectSubwindowsCookie.Check() -func UnredirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { +// RedirectWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using RedirectWindowCookie.Check() +func RedirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'UnredirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'RedirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) - return UnredirectSubwindowsCookie{cookie} + c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) + return RedirectWindowCookie{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 UnredirectSubwindowsCookie) Check() error { +func (cook RedirectWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnredirectSubwindows -// unredirectSubwindowsRequest writes a UnredirectSubwindows request to a byte slice. -func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { +// Write request to wire for RedirectWindow +// redirectWindowRequest writes a RedirectWindow request to a byte slice. +func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -391,7 +478,7 @@ func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -408,100 +495,97 @@ func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) return buf } -// CreateRegionFromBorderClipCookie is a cookie used only for CreateRegionFromBorderClip requests. -type CreateRegionFromBorderClipCookie struct { +// ReleaseOverlayWindowCookie is a cookie used only for ReleaseOverlayWindow requests. +type ReleaseOverlayWindowCookie struct { *xgb.Cookie } -// CreateRegionFromBorderClip sends an unchecked request. +// ReleaseOverlayWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateRegionFromBorderClip(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { +func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'CreateRegionFromBorderClip' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'ReleaseOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) - return CreateRegionFromBorderClipCookie{cookie} + c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) + return ReleaseOverlayWindowCookie{cookie} } -// CreateRegionFromBorderClipChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRegionFromBorderClipCookie.Check() -func CreateRegionFromBorderClipChecked(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { +// ReleaseOverlayWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ReleaseOverlayWindowCookie.Check() +func ReleaseOverlayWindowChecked(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'CreateRegionFromBorderClip' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'ReleaseOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) - return CreateRegionFromBorderClipCookie{cookie} + c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) + return ReleaseOverlayWindowCookie{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 CreateRegionFromBorderClipCookie) Check() error { +func (cook ReleaseOverlayWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateRegionFromBorderClip -// createRegionFromBorderClipRequest writes a CreateRegionFromBorderClip request to a byte slice. -func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) []byte { - size := 12 +// Write request to wire for ReleaseOverlayWindow +// releaseOverlayWindowRequest writes a ReleaseOverlayWindow request to a byte slice. +func releaseOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 5 // request opcode + 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:], uint32(Region)) - b += 4 - xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// NameWindowPixmapCookie is a cookie used only for NameWindowPixmap requests. -type NameWindowPixmapCookie struct { +// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. +type UnredirectSubwindowsCookie struct { *xgb.Cookie } -// NameWindowPixmap sends an unchecked request. +// UnredirectSubwindows sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func NameWindowPixmap(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { +func UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'NameWindowPixmap' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'UnredirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) - return NameWindowPixmapCookie{cookie} + c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) + return UnredirectSubwindowsCookie{cookie} } -// NameWindowPixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using NameWindowPixmapCookie.Check() -func NameWindowPixmapChecked(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { +// UnredirectSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnredirectSubwindowsCookie.Check() +func UnredirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'NameWindowPixmap' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'UnredirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) - return NameWindowPixmapCookie{cookie} + c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) + return UnredirectSubwindowsCookie{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 NameWindowPixmapCookie) Check() error { +func (cook UnredirectSubwindowsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for NameWindowPixmap -// nameWindowPixmapRequest writes a NameWindowPixmap request to a byte slice. -func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) []byte { +// Write request to wire for UnredirectSubwindows +// unredirectSubwindowsRequest writes a UnredirectSubwindows request to a byte slice. +func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -509,7 +593,7 @@ func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pi buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -518,147 +602,58 @@ func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pi xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Pixmap)) - b += 4 - - return buf -} - -// GetOverlayWindowCookie is a cookie used only for GetOverlayWindow requests. -type GetOverlayWindowCookie struct { - *xgb.Cookie -} - -// GetOverlayWindow sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetOverlayWindowCookie.Reply() -func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getOverlayWindowRequest(c, Window), cookie) - return GetOverlayWindowCookie{cookie} -} - -// GetOverlayWindowUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getOverlayWindowRequest(c, Window), cookie) - return GetOverlayWindowCookie{cookie} -} - -// GetOverlayWindowReply represents the data returned from a GetOverlayWindow request. -type GetOverlayWindowReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - OverlayWin xproto.Window - // padding: 20 bytes -} - -// Reply blocks and returns the reply data for a GetOverlayWindow request. -func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getOverlayWindowReply(buf), nil -} - -// getOverlayWindowReply reads a byte slice into a GetOverlayWindowReply value. -func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { - v := new(GetOverlayWindowReply) - 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.OverlayWin = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -// Write request to wire for GetOverlayWindow -// getOverlayWindowRequest writes a GetOverlayWindow request to a byte slice. -func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["COMPOSITE"] - b += 1 - - buf[b] = 7 // request opcode + buf[b] = Update 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 + b += 3 // padding return buf } -// ReleaseOverlayWindowCookie is a cookie used only for ReleaseOverlayWindow requests. -type ReleaseOverlayWindowCookie struct { +// UnredirectWindowCookie is a cookie used only for UnredirectWindow requests. +type UnredirectWindowCookie struct { *xgb.Cookie } -// ReleaseOverlayWindow sends an unchecked request. +// UnredirectWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { +func UnredirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'ReleaseOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'UnredirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) - return ReleaseOverlayWindowCookie{cookie} + c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) + return UnredirectWindowCookie{cookie} } -// ReleaseOverlayWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using ReleaseOverlayWindowCookie.Check() -func ReleaseOverlayWindowChecked(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { +// UnredirectWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using UnredirectWindowCookie.Check() +func UnredirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'ReleaseOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + panic("Cannot issue request 'UnredirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) - return ReleaseOverlayWindowCookie{cookie} + c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) + return UnredirectWindowCookie{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 ReleaseOverlayWindowCookie) Check() error { +func (cook UnredirectWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ReleaseOverlayWindow -// releaseOverlayWindowRequest writes a ReleaseOverlayWindow request to a byte slice. -func releaseOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for UnredirectWindow +// unredirectWindowRequest writes a UnredirectWindow request to a byte slice. +func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -667,5 +662,10 @@ func releaseOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + buf[b] = Update + b += 1 + + b += 3 // padding + return buf } diff --git a/nexgb/damage/damage.go b/nexgb/damage/damage.go index abf2206..72e0f3d 100644 --- a/nexgb/damage/damage.go +++ b/nexgb/damage/damage.go @@ -2,7 +2,7 @@ package damage /* - This file was generated by damage.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by damage.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,36 +41,51 @@ func init() { xgb.NewExtErrorFuncs["DAMAGE"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' +// BadBadDamage is the error number for a BadBadDamage. +const BadBadDamage = 0 -// Skipping definition for base type 'Byte' +type BadDamageError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Int8' +// BadDamageErrorNew constructs a BadDamageError value that implements xgb.Error from a byte slice. +func BadDamageErrorNew(buf []byte) xgb.Error { + v := BadDamageError{} + v.NiceName = "BadDamage" -// Skipping definition for base type 'Card16' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Char' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card32' + return v +} -// Skipping definition for base type 'Double' +// SequenceId returns the sequence id attached to the BadBadDamage error. +// This is mostly used internally. +func (err BadDamageError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Bool' +// BadId returns the 'BadValue' number if one exists for the BadBadDamage error. If no bad value exists, 0 is returned. +func (err BadDamageError) BadId() uint32 { + return 0 +} -// Skipping definition for base type 'Float' +// Error returns a rudimentary string representation of the BadBadDamage error. -// Skipping definition for base type 'Card8' +func (err BadDamageError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadDamage {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -const ( - ReportLevelRawRectangles = 0 - ReportLevelDeltaRectangles = 1 - ReportLevelBoundingBox = 2 - ReportLevelNonEmpty = 3 -) +func init() { + xgb.NewExtErrorFuncs["DAMAGE"][0] = BadDamageErrorNew +} type Damage uint32 @@ -184,128 +199,73 @@ func init() { xgb.NewExtEventFuncs["DAMAGE"][0] = NotifyEventNew } -// BadBadDamage is the error number for a BadBadDamage. -const BadBadDamage = 0 +const ( + ReportLevelRawRectangles = 0 + ReportLevelDeltaRectangles = 1 + ReportLevelBoundingBox = 2 + ReportLevelNonEmpty = 3 +) -type BadDamageError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Bool' -// BadDamageErrorNew constructs a BadDamageError value that implements xgb.Error from a byte slice. -func BadDamageErrorNew(buf []byte) xgb.Error { - v := BadDamageError{} - v.NiceName = "BadDamage" +// Skipping definition for base type 'Byte' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Card8' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Char' - return v -} +// Skipping definition for base type 'Void' -// SequenceId returns the sequence id attached to the BadBadDamage error. -// This is mostly used internally. -func (err BadDamageError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Double' -// BadId returns the 'BadValue' number if one exists for the BadBadDamage error. If no bad value exists, 0 is returned. -func (err BadDamageError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Float' -// Error returns a rudimentary string representation of the BadBadDamage error. +// Skipping definition for base type 'Int16' -func (err BadDamageError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadDamage {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Int32' -func init() { - xgb.NewExtErrorFuncs["DAMAGE"][0] = BadDamageErrorNew -} +// Skipping definition for base type 'Int8' -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { - *xgb.Cookie -} +// Skipping definition for base type 'Card16' -// 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { - if _, ok := c.Extensions["DAMAGE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} +// Skipping definition for base type 'Card32' + +// AddCookie is a cookie used only for Add requests. +type AddCookie struct { + *xgb.Cookie } -// QueryVersionUnchecked sends an unchecked request. +// Add sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { +func Add(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { if _, ok := c.Extensions["DAMAGE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + panic("Cannot issue request 'Add' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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 - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(addRequest(c, Drawable, Region), cookie) + return AddCookie{cookie} } -// 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 +// AddChecked sends a checked request. +// If an error occurs, it can be retrieved using AddCookie.Check() +func AddChecked(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Add' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") } - return queryVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(addRequest(c, Drawable, Region), cookie) + return AddCookie{cookie} } -// 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.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - 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 AddCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { +// Write request to wire for Add +// addRequest writes a Add request to a byte slice. +func addRequest(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -313,16 +273,16 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVers buf[b] = c.Extensions["DAMAGE"] b += 1 - buf[b] = 0 // request opcode + 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:], ClientMajorVersion) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], ClientMinorVersion) + xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf @@ -446,120 +406,160 @@ func destroyRequest(c *xgb.Conn, Damage Damage) []byte { return buf } -// SubtractCookie is a cookie used only for Subtract requests. -type SubtractCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// Subtract sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Subtract(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { +// 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["DAMAGE"]; !ok { - panic("Cannot issue request 'Subtract' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) - return SubtractCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// SubtractChecked sends a checked request. -// If an error occurs, it can be retrieved using SubtractCookie.Check() -func SubtractChecked(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { +// 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["DAMAGE"]; !ok { - panic("Cannot issue request 'Subtract' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) - return SubtractCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{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 SubtractCookie) Check() error { - return cook.Cookie.Check() +// 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 + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes } -// Write request to wire for Subtract -// subtractRequest writes a Subtract request to a byte slice. -func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) []byte { - size := 16 +// 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.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DAMAGE"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 0 // 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(Damage)) - b += 4 - - xgb.Put32(buf[b:], uint32(Repair)) + xgb.Put32(buf[b:], ClientMajorVersion) b += 4 - xgb.Put32(buf[b:], uint32(Parts)) + xgb.Put32(buf[b:], ClientMinorVersion) b += 4 return buf } -// AddCookie is a cookie used only for Add requests. -type AddCookie struct { +// SubtractCookie is a cookie used only for Subtract requests. +type SubtractCookie struct { *xgb.Cookie } -// Add sends an unchecked request. +// Subtract sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Add(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { +func Subtract(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { if _, ok := c.Extensions["DAMAGE"]; !ok { - panic("Cannot issue request 'Add' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + panic("Cannot issue request 'Subtract' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(addRequest(c, Drawable, Region), cookie) - return AddCookie{cookie} + c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) + return SubtractCookie{cookie} } -// AddChecked sends a checked request. -// If an error occurs, it can be retrieved using AddCookie.Check() -func AddChecked(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { +// SubtractChecked sends a checked request. +// If an error occurs, it can be retrieved using SubtractCookie.Check() +func SubtractChecked(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { if _, ok := c.Extensions["DAMAGE"]; !ok { - panic("Cannot issue request 'Add' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + panic("Cannot issue request 'Subtract' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(addRequest(c, Drawable, Region), cookie) - return AddCookie{cookie} + c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) + return SubtractCookie{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 AddCookie) Check() error { +func (cook SubtractCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Add -// addRequest writes a Add request to a byte slice. -func addRequest(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) []byte { - size := 12 +// Write request to wire for Subtract +// subtractRequest writes a Subtract request to a byte slice. +func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DAMAGE"] b += 1 - buf[b] = 4 // request opcode + 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(Drawable)) + xgb.Put32(buf[b:], uint32(Damage)) b += 4 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Repair)) + b += 4 + + xgb.Put32(buf[b:], uint32(Parts)) b += 4 return buf diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index f7d6ffe..96d82f0 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by dpms.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["DPMS"] = 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' - const ( DPMSModeOn = 0 DPMSModeStandby = 1 @@ -71,100 +47,29 @@ const ( DPMSModeOff = 3 ) -// GetVersionCookie is a cookie used only for GetVersion requests. -type GetVersionCookie struct { - *xgb.Cookie -} - -// GetVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() -func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return GetVersionCookie{cookie} -} - -// GetVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return GetVersionCookie{cookie} -} - -// GetVersionReply represents the data returned from a GetVersion request. -type GetVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ServerMajorVersion uint16 - ServerMinorVersion uint16 -} - -// Reply blocks and returns the reply data for a GetVersion request. -func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getVersionReply(buf), nil -} - -// getVersionReply reads a byte slice into a GetVersionReply value. -func getVersionReply(buf []byte) *GetVersionReply { - v := new(GetVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Bool' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Byte' - v.ServerMajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card8' - v.ServerMinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Char' - return v -} +// Skipping definition for base type 'Void' -// Write request to wire for GetVersion -// getVersionRequest writes a GetVersion request to a byte slice. -func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Double' - buf[b] = c.Extensions["DPMS"] - b += 1 +// Skipping definition for base type 'Float' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Int16' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Int32' - xgb.Put16(buf[b:], ClientMajorVersion) - b += 2 +// Skipping definition for base type 'Int8' - xgb.Put16(buf[b:], ClientMinorVersion) - b += 2 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // CapableCookie is a cookie used only for Capable requests. type CapableCookie struct { @@ -258,86 +163,42 @@ func capableRequest(c *xgb.Conn) []byte { return buf } -// GetTimeoutsCookie is a cookie used only for GetTimeouts requests. -type GetTimeoutsCookie struct { +// DisableCookie is a cookie used only for Disable requests. +type DisableCookie struct { *xgb.Cookie } -// GetTimeouts sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() -func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getTimeoutsRequest(c), cookie) - return GetTimeoutsCookie{cookie} -} - -// GetTimeoutsUnchecked sends an unchecked request. +// Disable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { +func Disable(c *xgb.Conn) DisableCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getTimeoutsRequest(c), cookie) - return GetTimeoutsCookie{cookie} -} - -// GetTimeoutsReply represents the data returned from a GetTimeouts request. -type GetTimeoutsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - StandbyTimeout uint16 - SuspendTimeout uint16 - OffTimeout uint16 - // padding: 18 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} } -// Reply blocks and returns the reply data for a GetTimeouts request. -func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DisableChecked sends a checked request. +// If an error occurs, it can be retrieved using DisableCookie.Check() +func DisableChecked(c *xgb.Conn) DisableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - return getTimeoutsReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} } -// getTimeoutsReply reads a byte slice into a GetTimeoutsReply value. -func getTimeoutsReply(buf []byte) *GetTimeoutsReply { - v := new(GetTimeoutsReply) - 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.StandbyTimeout = xgb.Get16(buf[b:]) - b += 2 - - v.SuspendTimeout = xgb.Get16(buf[b:]) - b += 2 - - v.OffTimeout = xgb.Get16(buf[b:]) - b += 2 - - b += 18 // padding - - 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 DisableCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetTimeouts -// getTimeoutsRequest writes a GetTimeouts request to a byte slice. -func getTimeoutsRequest(c *xgb.Conn) []byte { +// Write request to wire for Disable +// disableRequest writes a Disable request to a byte slice. +func disableRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -345,7 +206,7 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["DPMS"] 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 @@ -354,155 +215,193 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { return buf } -// SetTimeoutsCookie is a cookie used only for SetTimeouts requests. -type SetTimeoutsCookie struct { +// EnableCookie is a cookie used only for Enable requests. +type EnableCookie struct { *xgb.Cookie } -// SetTimeouts sends an unchecked request. +// Enable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { +func Enable(c *xgb.Conn) EnableCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) - return SetTimeoutsCookie{cookie} + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} } -// SetTimeoutsChecked sends a checked request. -// If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() -func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { +// EnableChecked sends a checked request. +// If an error occurs, it can be retrieved using EnableCookie.Check() +func EnableChecked(c *xgb.Conn) EnableCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) - return SetTimeoutsCookie{cookie} + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{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 SetTimeoutsCookie) Check() error { +func (cook EnableCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetTimeouts -// setTimeoutsRequest writes a SetTimeouts request to a byte slice. -func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { - size := 12 +// Write request to wire for Enable +// enableRequest writes a Enable request to a byte slice. +func enableRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], StandbyTimeout) - b += 2 - - xgb.Put16(buf[b:], SuspendTimeout) - b += 2 - - xgb.Put16(buf[b:], OffTimeout) - b += 2 - return buf } -// EnableCookie is a cookie used only for Enable requests. -type EnableCookie struct { +// ForceLevelCookie is a cookie used only for ForceLevel requests. +type ForceLevelCookie struct { *xgb.Cookie } -// Enable sends an unchecked request. +// ForceLevel sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Enable(c *xgb.Conn) EnableCookie { +func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(enableRequest(c), cookie) - return EnableCookie{cookie} + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{cookie} } -// EnableChecked sends a checked request. -// If an error occurs, it can be retrieved using EnableCookie.Check() -func EnableChecked(c *xgb.Conn) EnableCookie { +// ForceLevelChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceLevelCookie.Check() +func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(enableRequest(c), cookie) - return EnableCookie{cookie} + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{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 EnableCookie) Check() error { +func (cook ForceLevelCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Enable -// enableRequest writes a Enable request to a byte slice. -func enableRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for ForceLevel +// forceLevelRequest writes a ForceLevel request to a byte slice. +func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put16(buf[b:], PowerLevel) + b += 2 + return buf } -// DisableCookie is a cookie used only for Disable requests. -type DisableCookie struct { +// GetTimeoutsCookie is a cookie used only for GetTimeouts requests. +type GetTimeoutsCookie struct { *xgb.Cookie } -// Disable sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Disable(c *xgb.Conn) DisableCookie { +// GetTimeouts sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() +func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(disableRequest(c), cookie) - return DisableCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{cookie} } -// DisableChecked sends a checked request. -// If an error occurs, it can be retrieved using DisableCookie.Check() -func DisableChecked(c *xgb.Conn) DisableCookie { +// GetTimeoutsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(disableRequest(c), cookie) - return DisableCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{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 DisableCookie) Check() error { - return cook.Cookie.Check() +// GetTimeoutsReply represents the data returned from a GetTimeouts request. +type GetTimeoutsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + StandbyTimeout uint16 + SuspendTimeout uint16 + OffTimeout uint16 + // padding: 18 bytes } -// Write request to wire for Disable -// disableRequest writes a Disable request to a byte slice. -func disableRequest(c *xgb.Conn) []byte { +// Reply blocks and returns the reply data for a GetTimeouts request. +func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTimeoutsReply(buf), nil +} + +// getTimeoutsReply reads a byte slice into a GetTimeoutsReply value. +func getTimeoutsReply(buf []byte) *GetTimeoutsReply { + v := new(GetTimeoutsReply) + 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.StandbyTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.SuspendTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.OffTimeout = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + return v +} + +// Write request to wire for GetTimeouts +// getTimeoutsRequest writes a GetTimeouts request to a byte slice. +func getTimeoutsRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -510,7 +409,7 @@ func disableRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -519,42 +418,79 @@ func disableRequest(c *xgb.Conn) []byte { return buf } -// ForceLevelCookie is a cookie used only for ForceLevel requests. -type ForceLevelCookie struct { +// GetVersionCookie is a cookie used only for GetVersion requests. +type GetVersionCookie struct { *xgb.Cookie } -// ForceLevel sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { +// GetVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() +func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) - return ForceLevelCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} } -// ForceLevelChecked sends a checked request. -// If an error occurs, it can be retrieved using ForceLevelCookie.Check() -func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { +// GetVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) - return ForceLevelCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{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 ForceLevelCookie) Check() error { - return cook.Cookie.Check() +// GetVersionReply represents the data returned from a GetVersion request. +type GetVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ServerMajorVersion uint16 + ServerMinorVersion uint16 } -// Write request to wire for ForceLevel -// forceLevelRequest writes a ForceLevel request to a byte slice. -func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { +// Reply blocks and returns the reply data for a GetVersion request. +func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVersionReply(buf), nil +} + +// getVersionReply reads a byte slice into a GetVersionReply value. +func getVersionReply(buf []byte) *GetVersionReply { + v := new(GetVersionReply) + 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.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for GetVersion +// getVersionRequest writes a GetVersion request to a byte slice. +func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -562,13 +498,16 @@ func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], PowerLevel) + xgb.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) b += 2 return buf @@ -669,3 +608,64 @@ func infoRequest(c *xgb.Conn) []byte { return buf } + +// SetTimeoutsCookie is a cookie used only for SetTimeouts requests. +type SetTimeoutsCookie struct { + *xgb.Cookie +} + +// SetTimeouts sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{cookie} +} + +// SetTimeoutsChecked sends a checked request. +// If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() +func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{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 SetTimeoutsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetTimeouts +// setTimeoutsRequest writes a SetTimeouts request to a byte slice. +func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + 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.Put16(buf[b:], StandbyTimeout) + b += 2 + + xgb.Put16(buf[b:], SuspendTimeout) + b += 2 + + xgb.Put16(buf[b:], OffTimeout) + b += 2 + + return buf +} diff --git a/nexgb/dri2/dri2.go b/nexgb/dri2/dri2.go index f047e54..3c63af5 100644 --- a/nexgb/dri2/dri2.go +++ b/nexgb/dri2/dri2.go @@ -2,7 +2,7 @@ package dri2 /* - This file was generated by dri2.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by dri2.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,130 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DRI2"] = 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' - -const ( - AttachmentBufferFrontLeft = 0 - AttachmentBufferBackLeft = 1 - AttachmentBufferFrontRight = 2 - AttachmentBufferBackRight = 3 - AttachmentBufferDepth = 4 - AttachmentBufferStencil = 5 - AttachmentBufferAccum = 6 - AttachmentBufferFakeFrontLeft = 7 - AttachmentBufferFakeFrontRight = 8 - AttachmentBufferDepthStencil = 9 - AttachmentBufferHiz = 10 -) - -const ( - DriverTypeDri = 0 - DriverTypeVdpau = 1 -) - -const ( - EventTypeExchangeComplete = 1 - EventTypeBlitComplete = 2 - EventTypeFlipComplete = 3 -) - -type DRI2Buffer struct { - Attachment uint32 - Name uint32 - Pitch uint32 - Cpp uint32 - Flags uint32 -} - -// DRI2BufferRead reads a byte slice into a DRI2Buffer value. -func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { - b := 0 - - v.Attachment = xgb.Get32(buf[b:]) - b += 4 - - v.Name = xgb.Get32(buf[b:]) - b += 4 - - v.Pitch = xgb.Get32(buf[b:]) - b += 4 - - v.Cpp = xgb.Get32(buf[b:]) - b += 4 - - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// DRI2BufferReadList reads a byte slice into a list of DRI2Buffer values. -func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DRI2Buffer{} - b += DRI2BufferRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a DRI2Buffer value to a byte slice. -func (v DRI2Buffer) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - xgb.Put32(buf[b:], v.Attachment) - b += 4 - - xgb.Put32(buf[b:], v.Name) - b += 4 - - xgb.Put32(buf[b:], v.Pitch) - b += 4 - - xgb.Put32(buf[b:], v.Cpp) - b += 4 - - xgb.Put32(buf[b:], v.Flags) - b += 4 - - return buf -} - -// DRI2BufferListBytes writes a list of DRI2Buffer values to a byte slice. -func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - type AttachFormat struct { Attachment uint32 Format uint32 @@ -218,6 +94,20 @@ func AttachFormatListBytes(buf []byte, list []AttachFormat) int { return b } +const ( + AttachmentBufferFrontLeft = 0 + AttachmentBufferBackLeft = 1 + AttachmentBufferFrontRight = 2 + AttachmentBufferBackRight = 3 + AttachmentBufferDepth = 4 + AttachmentBufferStencil = 5 + AttachmentBufferAccum = 6 + AttachmentBufferFakeFrontLeft = 7 + AttachmentBufferFakeFrontRight = 8 + AttachmentBufferDepthStencil = 9 + AttachmentBufferHiz = 10 +) + // BufferSwapComplete is the event number for a BufferSwapCompleteEvent. const BufferSwapComplete = 0 @@ -334,6 +224,92 @@ func init() { xgb.NewExtEventFuncs["DRI2"][0] = BufferSwapCompleteEventNew } +type DRI2Buffer struct { + Attachment uint32 + Name uint32 + Pitch uint32 + Cpp uint32 + Flags uint32 +} + +// DRI2BufferRead reads a byte slice into a DRI2Buffer value. +func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { + b := 0 + + v.Attachment = xgb.Get32(buf[b:]) + b += 4 + + v.Name = xgb.Get32(buf[b:]) + b += 4 + + v.Pitch = xgb.Get32(buf[b:]) + b += 4 + + v.Cpp = xgb.Get32(buf[b:]) + b += 4 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// DRI2BufferReadList reads a byte slice into a list of DRI2Buffer values. +func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DRI2Buffer{} + b += DRI2BufferRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a DRI2Buffer value to a byte slice. +func (v DRI2Buffer) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + xgb.Put32(buf[b:], v.Attachment) + b += 4 + + xgb.Put32(buf[b:], v.Name) + b += 4 + + xgb.Put32(buf[b:], v.Pitch) + b += 4 + + xgb.Put32(buf[b:], v.Cpp) + b += 4 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + return buf +} + +// DRI2BufferListBytes writes a list of DRI2Buffer values to a byte slice. +func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + DriverTypeDri = 0 + DriverTypeVdpau = 1 +) + +const ( + EventTypeExchangeComplete = 1 + EventTypeBlitComplete = 2 + EventTypeFlipComplete = 3 +) + // InvalidateBuffers is the event number for a InvalidateBuffersEvent. const InvalidateBuffers = 1 @@ -397,44 +373,67 @@ func init() { xgb.NewExtEventFuncs["DRI2"][1] = InvalidateBuffersEventNew } -// 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' + +// AuthenticateCookie is a cookie used only for Authenticate requests. +type AuthenticateCookie 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +// Authenticate sends a checked request. +// If an error occurs, it will be returned with the reply by calling AuthenticateCookie.Reply() +func Authenticate(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// AuthenticateUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +func AuthenticateUnchecked(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// AuthenticateReply represents the data returned from a Authenticate request. +type AuthenticateReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MajorVersion uint32 - MinorVersion 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 Authenticate request. +func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -442,12 +441,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return authenticateReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// authenticateReply reads a byte slice into a AuthenticateReply value. +func authenticateReply(buf []byte) *AuthenticateReply { + v := new(AuthenticateReply) b := 1 // skip reply determinant b += 1 // padding @@ -458,18 +457,15 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = 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, MajorVersion uint32, MinorVersion uint32) []byte { +// Write request to wire for Authenticate +// authenticateRequest writes a Authenticate request to a byte slice. +func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -477,16 +473,16 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 0 // request opcode + 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:], MajorVersion) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], MinorVersion) + xgb.Put32(buf[b:], Magic) b += 4 return buf @@ -611,43 +607,42 @@ func connectRequest(c *xgb.Conn, Window xproto.Window, DriverType uint32) []byte return buf } -// AuthenticateCookie is a cookie used only for Authenticate requests. -type AuthenticateCookie struct { +// CopyRegionCookie is a cookie used only for CopyRegion requests. +type CopyRegionCookie struct { *xgb.Cookie } -// Authenticate sends a checked request. -// If an error occurs, it will be returned with the reply by calling AuthenticateCookie.Reply() -func Authenticate(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { +// CopyRegion sends a checked request. +// If an error occurs, it will be returned with the reply by calling CopyRegionCookie.Reply() +func CopyRegion(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(authenticateRequest(c, Window, Magic), cookie) - return AuthenticateCookie{cookie} + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} } -// AuthenticateUnchecked sends an unchecked request. +// CopyRegionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AuthenticateUnchecked(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { +func CopyRegionUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(authenticateRequest(c, Window, Magic), cookie) - return AuthenticateCookie{cookie} + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} } -// AuthenticateReply represents the data returned from a Authenticate request. -type AuthenticateReply struct { +// CopyRegionReply represents the data returned from a CopyRegion request. +type CopyRegionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Authenticated uint32 } -// Reply blocks and returns the reply data for a Authenticate request. -func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { +// Reply blocks and returns the reply data for a CopyRegion request. +func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -655,12 +650,12 @@ func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { if buf == nil { return nil, nil } - return authenticateReply(buf), nil + return copyRegionReply(buf), nil } -// authenticateReply reads a byte slice into a AuthenticateReply value. -func authenticateReply(buf []byte) *AuthenticateReply { - v := new(AuthenticateReply) +// copyRegionReply reads a byte slice into a CopyRegionReply value. +func copyRegionReply(buf []byte) *CopyRegionReply { + v := new(CopyRegionReply) b := 1 // skip reply determinant b += 1 // padding @@ -671,32 +666,35 @@ func authenticateReply(buf []byte) *AuthenticateReply { 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 Authenticate -// authenticateRequest writes a Authenticate request to a byte slice. -func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte { - size := 12 +// Write request to wire for CopyRegion +// copyRegionRequest writes a CopyRegion request to a byte slice. +func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 2 // request opcode + 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:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], Magic) + xgb.Put32(buf[b:], Region) + b += 4 + + xgb.Put32(buf[b:], Dest) + b += 4 + + xgb.Put32(buf[b:], Src) b += 4 return buf @@ -924,42 +922,47 @@ func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Atta return buf } -// CopyRegionCookie is a cookie used only for CopyRegion requests. -type CopyRegionCookie struct { +// GetBuffersWithFormatCookie is a cookie used only for GetBuffersWithFormat requests. +type GetBuffersWithFormatCookie struct { *xgb.Cookie } -// CopyRegion sends a checked request. -// If an error occurs, it will be returned with the reply by calling CopyRegionCookie.Reply() -func CopyRegion(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { +// GetBuffersWithFormat sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetBuffersWithFormatCookie.Reply() +func GetBuffersWithFormat(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) - return CopyRegionCookie{cookie} + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} } -// CopyRegionUnchecked sends an unchecked request. +// GetBuffersWithFormatUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyRegionUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { +func GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) - return CopyRegionCookie{cookie} + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} } -// CopyRegionReply represents the data returned from a CopyRegion request. -type CopyRegionReply struct { +// GetBuffersWithFormatReply represents the data returned from a GetBuffersWithFormat request. +type GetBuffersWithFormatReply struct { 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 + Count uint32 + // padding: 12 bytes + Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) } -// Reply blocks and returns the reply data for a CopyRegion request. -func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { +// Reply blocks and returns the reply data for a GetBuffersWithFormat request. +func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -967,12 +970,12 @@ func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { if buf == nil { return nil, nil } - return copyRegionReply(buf), nil + return getBuffersWithFormatReply(buf), nil } -// copyRegionReply reads a byte slice into a CopyRegionReply value. -func copyRegionReply(buf []byte) *CopyRegionReply { - v := new(CopyRegionReply) +// getBuffersWithFormatReply reads a byte slice into a GetBuffersWithFormatReply value. +func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { + v := new(GetBuffersWithFormatReply) b := 1 // skip reply determinant b += 1 // padding @@ -983,20 +986,34 @@ func copyRegionReply(buf []byte) *CopyRegionReply { 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.Count = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Buffers = make([]DRI2Buffer, v.Count) + b += DRI2BufferReadList(buf[b:], v.Buffers) + return v } -// Write request to wire for CopyRegion -// copyRegionRequest writes a CopyRegion request to a byte slice. -func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { - size := 20 +// Write request to wire for GetBuffersWithFormat +// getBuffersWithFormatRequest writes a GetBuffersWithFormat request to a byte slice. +func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1005,59 +1022,56 @@ func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Des xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], Region) - b += 4 - - xgb.Put32(buf[b:], Dest) + xgb.Put32(buf[b:], Count) b += 4 - xgb.Put32(buf[b:], Src) - b += 4 + b += AttachFormatListBytes(buf[b:], Attachments) return buf } -// GetBuffersWithFormatCookie is a cookie used only for GetBuffersWithFormat requests. -type GetBuffersWithFormatCookie struct { +// GetMSCCookie is a cookie used only for GetMSC requests. +type GetMSCCookie struct { *xgb.Cookie } -// GetBuffersWithFormat sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetBuffersWithFormatCookie.Reply() -func GetBuffersWithFormat(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { +// GetMSC sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMSCCookie.Reply() +func GetMSC(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) - return GetBuffersWithFormatCookie{cookie} + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} } -// GetBuffersWithFormatUnchecked sends an unchecked request. +// GetMSCUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { +func GetMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) - return GetBuffersWithFormatCookie{cookie} + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} } -// GetBuffersWithFormatReply represents the data returned from a GetBuffersWithFormat request. -type GetBuffersWithFormatReply struct { +// GetMSCReply represents the data returned from a GetMSC request. +type GetMSCReply struct { 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 - Count uint32 - // padding: 12 bytes - Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 } -// Reply blocks and returns the reply data for a GetBuffersWithFormat request. -func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, error) { +// Reply blocks and returns the reply data for a GetMSC request. +func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1065,12 +1079,12 @@ func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, erro if buf == nil { return nil, nil } - return getBuffersWithFormatReply(buf), nil + return getMSCReply(buf), nil } -// getBuffersWithFormatReply reads a byte slice into a GetBuffersWithFormatReply value. -func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { - v := new(GetBuffersWithFormatReply) +// getMSCReply reads a byte slice into a GetMSCReply value. +func getMSCReply(buf []byte) *GetMSCReply { + v := new(GetMSCReply) b := 1 // skip reply determinant b += 1 // padding @@ -1081,34 +1095,38 @@ func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Width = xgb.Get32(buf[b:]) + v.UstHi = xgb.Get32(buf[b:]) b += 4 - v.Height = xgb.Get32(buf[b:]) + v.UstLo = xgb.Get32(buf[b:]) b += 4 - v.Count = xgb.Get32(buf[b:]) + v.MscHi = xgb.Get32(buf[b:]) b += 4 - b += 12 // padding + v.MscLo = xgb.Get32(buf[b:]) + b += 4 - v.Buffers = make([]DRI2Buffer, v.Count) - b += DRI2BufferReadList(buf[b:], v.Buffers) + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 return v } -// Write request to wire for GetBuffersWithFormat -// getBuffersWithFormatRequest writes a GetBuffersWithFormat request to a byte slice. -func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) +// Write request to wire for GetMSC +// getMSCRequest writes a GetMSC request to a byte slice. +func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1117,10 +1135,200 @@ func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count ui xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], Count) + return buf +} + +// GetParamCookie is a cookie used only for GetParam requests. +type GetParamCookie struct { + *xgb.Cookie +} + +// GetParam sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetParamCookie.Reply() +func GetParam(c *xgb.Conn, Drawable xproto.Drawable, Param uint32) GetParamCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'GetParam' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getParamRequest(c, Drawable, Param), cookie) + return GetParamCookie{cookie} +} + +// GetParamUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetParamUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Param uint32) GetParamCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'GetParam' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getParamRequest(c, Drawable, Param), cookie) + return GetParamCookie{cookie} +} + +// GetParamReply represents the data returned from a GetParam request. +type GetParamReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + IsParamRecognized bool + ValueHi uint32 + ValueLo uint32 +} + +// Reply blocks and returns the reply data for a GetParam request. +func (cook GetParamCookie) Reply() (*GetParamReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getParamReply(buf), nil +} + +// getParamReply reads a byte slice into a GetParamReply value. +func getParamReply(buf []byte) *GetParamReply { + v := new(GetParamReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.IsParamRecognized = true + } else { + v.IsParamRecognized = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += AttachFormatListBytes(buf[b:], Attachments) + v.ValueHi = xgb.Get32(buf[b:]) + b += 4 + + v.ValueLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetParam +// getParamRequest writes a GetParam request to a byte slice. +func getParamRequest(c *xgb.Conn, Drawable xproto.Drawable, Param uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 13 // 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Param) + b += 4 + + 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), 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 + MajorVersion uint32 + MinorVersion 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.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = 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, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 return buf } @@ -1235,103 +1443,50 @@ func swapBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint3 return buf } -// GetMSCCookie is a cookie used only for GetMSC requests. -type GetMSCCookie struct { +// SwapIntervalCookie is a cookie used only for SwapInterval requests. +type SwapIntervalCookie struct { *xgb.Cookie } -// GetMSC sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMSCCookie.Reply() -func GetMSC(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getMSCRequest(c, Drawable), cookie) - return GetMSCCookie{cookie} -} - -// GetMSCUnchecked sends an unchecked request. +// SwapInterval sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { +func SwapInterval(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getMSCRequest(c, Drawable), cookie) - return GetMSCCookie{cookie} -} - -// GetMSCReply represents the data returned from a GetMSC request. -type GetMSCReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 + cookie := c.NewCookie(false, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} } -// Reply blocks and returns the reply data for a GetMSC request. -func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SwapIntervalChecked sends a checked request. +// If an error occurs, it can be retrieved using SwapIntervalCookie.Check() +func SwapIntervalChecked(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } - return getMSCReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} } -// getMSCReply reads a byte slice into a GetMSCReply value. -func getMSCReply(buf []byte) *GetMSCReply { - v := new(GetMSCReply) - 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.UstHi = xgb.Get32(buf[b:]) - b += 4 - - v.UstLo = xgb.Get32(buf[b:]) - b += 4 - - v.MscHi = xgb.Get32(buf[b:]) - b += 4 - - v.MscLo = xgb.Get32(buf[b:]) - b += 4 - - v.SbcHi = xgb.Get32(buf[b:]) - b += 4 - - v.SbcLo = 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 SwapIntervalCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetMSC -// getMSCRequest writes a GetMSC request to a byte slice. -func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { - size := 8 +// Write request to wire for SwapInterval +// swapIntervalRequest writes a SwapInterval request to a byte slice. +func swapIntervalRequest(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1340,6 +1495,9 @@ func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { xgb.Put32(buf[b:], uint32(Drawable)) b += 4 + xgb.Put32(buf[b:], Interval) + b += 4 + return buf } @@ -1582,61 +1740,3 @@ func waitSBCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, T return buf } - -// SwapIntervalCookie is a cookie used only for SwapInterval requests. -type SwapIntervalCookie struct { - *xgb.Cookie -} - -// SwapInterval sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SwapInterval(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) - return SwapIntervalCookie{cookie} -} - -// SwapIntervalChecked sends a checked request. -// If an error occurs, it can be retrieved using SwapIntervalCookie.Check() -func SwapIntervalChecked(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) - return SwapIntervalCookie{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 SwapIntervalCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SwapInterval -// swapIntervalRequest writes a SwapInterval request to a byte slice. -func swapIntervalRequest(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["DRI2"] - b += 1 - - buf[b] = 12 // 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], Interval) - b += 4 - - return buf -} diff --git a/nexgb/ge/ge.go b/nexgb/ge/ge.go index 9084275..5e01d1e 100644 --- a/nexgb/ge/ge.go +++ b/nexgb/ge/ge.go @@ -2,7 +2,7 @@ package ge /* - This file was generated by ge.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by ge.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,29 +40,29 @@ func init() { xgb.NewExtErrorFuncs["Generic Event Extension"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card16' +// 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 'Card32' +// Skipping definition for base type 'Void' // 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 'Int8' -// Skipping definition for base type 'Byte' +// Skipping definition for base type 'Card16' -// Skipping definition for base type 'Int8' +// Skipping definition for base type 'Card32' // QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { diff --git a/nexgb/glx/glx.go b/nexgb/glx/glx.go index cc6ab68..facf12e 100644 --- a/nexgb/glx/glx.go +++ b/nexgb/glx/glx.go @@ -2,7 +2,7 @@ package glx /* - This file was generated by glx.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by glx.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,342 +40,6 @@ func init() { xgb.NewExtErrorFuncs["GLX"] = 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' - -const ( - PbcetDamaged = 32791 - PbcetSaved = 32792 -) - -const ( - PbcdtWindow = 32793 - PbcdtPbuffer = 32794 -) - -const ( - GcGlCurrentBit = 1 - GcGlPointBit = 2 - GcGlLineBit = 4 - GcGlPolygonBit = 8 - GcGlPolygonStippleBit = 16 - GcGlPixelModeBit = 32 - GcGlLightingBit = 64 - GcGlFogBit = 128 - GcGlDepthBufferBit = 256 - GcGlAccumBufferBit = 512 - GcGlStencilBufferBit = 1024 - GcGlViewportBit = 2048 - GcGlTransformBit = 4096 - GcGlEnableBit = 8192 - GcGlColorBufferBit = 16384 - GcGlHintBit = 32768 - GcGlEvalBit = 65536 - GcGlListBit = 131072 - GcGlTextureBit = 262144 - GcGlScissorBit = 524288 - GcGlAllAttribBits = 16777215 -) - -const ( - RmGlRender = 7168 - RmGlFeedback = 7169 - RmGlSelect = 7170 -) - -type Pixmap uint32 - -func NewPixmapId(c *xgb.Conn) (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} - -type Context uint32 - -func NewContextId(c *xgb.Conn) (Context, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Context(id), nil -} - -type Pbuffer uint32 - -func NewPbufferId(c *xgb.Conn) (Pbuffer, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pbuffer(id), nil -} - -type Window uint32 - -func NewWindowId(c *xgb.Conn) (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} - -type Fbconfig uint32 - -func NewFbconfigId(c *xgb.Conn) (Fbconfig, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fbconfig(id), nil -} - -type Drawable uint32 - -func NewDrawableId(c *xgb.Conn) (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil -} - -type Float32 float64 - -type Float64 float64 - -type Bool32 uint32 - -type ContextTag uint32 - -// PbufferClobber is the event number for a PbufferClobberEvent. -const PbufferClobber = 0 - -type PbufferClobberEvent struct { - Sequence uint16 - // padding: 1 bytes - EventType uint16 - DrawType uint16 - Drawable Drawable - BMask uint32 - AuxBuffer uint16 - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 4 bytes -} - -// PbufferClobberEventNew constructs a PbufferClobberEvent value that implements xgb.Event from a byte slice. -func PbufferClobberEventNew(buf []byte) xgb.Event { - v := PbufferClobberEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.EventType = xgb.Get16(buf[b:]) - b += 2 - - v.DrawType = xgb.Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(xgb.Get32(buf[b:])) - b += 4 - - v.BMask = xgb.Get32(buf[b:]) - b += 4 - - v.AuxBuffer = xgb.Get16(buf[b:]) - b += 2 - - v.X = xgb.Get16(buf[b:]) - b += 2 - - v.Y = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.Count = xgb.Get16(buf[b:]) - b += 2 - - b += 4 // padding - - return v -} - -// Bytes writes a PbufferClobberEvent value to a byte slice. -func (v PbufferClobberEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put16(buf[b:], v.EventType) - b += 2 - - xgb.Put16(buf[b:], v.DrawType) - b += 2 - - xgb.Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - xgb.Put32(buf[b:], v.BMask) - b += 4 - - xgb.Put16(buf[b:], v.AuxBuffer) - b += 2 - - xgb.Put16(buf[b:], v.X) - b += 2 - - xgb.Put16(buf[b:], v.Y) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], v.Count) - b += 2 - - b += 4 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the PbufferClobber event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v PbufferClobberEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of PbufferClobberEvent. -func (v PbufferClobberEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("EventType: %d", v.EventType)) - fieldVals = append(fieldVals, xgb.Sprintf("DrawType: %d", v.DrawType)) - fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, xgb.Sprintf("BMask: %d", v.BMask)) - fieldVals = append(fieldVals, xgb.Sprintf("AuxBuffer: %d", v.AuxBuffer)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "PbufferClobber {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["GLX"][0] = PbufferClobberEventNew -} - -// BadGeneric is the error number for a BadGeneric. -const BadGeneric = -1 - -type GenericError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 21 bytes -} - -// GenericErrorNew constructs a GenericError value that implements xgb.Error from a byte slice. -func GenericErrorNew(buf []byte) xgb.Error { - v := GenericError{} - v.NiceName = "Generic" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.BadValue = xgb.Get32(buf[b:]) - b += 4 - - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 21 // padding - - return v -} - -// SequenceId returns the sequence id attached to the BadGeneric error. -// This is mostly used internally. -func (err GenericError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadGeneric error. If no bad value exists, 0 is returned. -func (err GenericError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadGeneric error. - -func (err GenericError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew -} - // BadBadContext is the error number for a BadBadContext. const BadBadContext = 0 @@ -452,118 +116,80 @@ func init() { xgb.NewExtErrorFuncs["GLX"][1] = BadContextStateErrorNew } -// BadBadDrawable is the error number for a BadBadDrawable. -const BadBadDrawable = 2 - -type BadDrawableError GenericError - -// BadDrawableErrorNew constructs a BadDrawableError value that implements xgb.Error from a byte slice. -func BadDrawableErrorNew(buf []byte) xgb.Error { - v := BadDrawableError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadDrawable" - return v -} - -// SequenceId returns the sequence id attached to the BadBadDrawable error. -// This is mostly used internally. -func (err BadDrawableError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadBadDrawable error. If no bad value exists, 0 is returned. -func (err BadDrawableError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadBadDrawable error. -func (err BadDrawableError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["GLX"][2] = BadDrawableErrorNew -} - -// BadBadPixmap is the error number for a BadBadPixmap. -const BadBadPixmap = 3 +// BadBadContextTag is the error number for a BadBadContextTag. +const BadBadContextTag = 4 -type BadPixmapError GenericError +type BadContextTagError GenericError -// BadPixmapErrorNew constructs a BadPixmapError value that implements xgb.Error from a byte slice. -func BadPixmapErrorNew(buf []byte) xgb.Error { - v := BadPixmapError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadPixmap" +// BadContextTagErrorNew constructs a BadContextTagError value that implements xgb.Error from a byte slice. +func BadContextTagErrorNew(buf []byte) xgb.Error { + v := BadContextTagError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContextTag" return v } -// SequenceId returns the sequence id attached to the BadBadPixmap error. +// SequenceId returns the sequence id attached to the BadBadContextTag error. // This is mostly used internally. -func (err BadPixmapError) SequenceId() uint16 { +func (err BadContextTagError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadBadPixmap error. If no bad value exists, 0 is returned. -func (err BadPixmapError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadContextTag error. If no bad value exists, 0 is returned. +func (err BadContextTagError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadBadPixmap error. -func (err BadPixmapError) Error() string { +// Error returns a rudimentary string representation of the BadBadContextTag error. +func (err BadContextTagError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadContextTag {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew + xgb.NewExtErrorFuncs["GLX"][4] = BadContextTagErrorNew } -// BadBadContextTag is the error number for a BadBadContextTag. -const BadBadContextTag = 4 +// BadBadCurrentDrawable is the error number for a BadBadCurrentDrawable. +const BadBadCurrentDrawable = 11 -type BadContextTagError GenericError +type BadCurrentDrawableError GenericError -// BadContextTagErrorNew constructs a BadContextTagError value that implements xgb.Error from a byte slice. -func BadContextTagErrorNew(buf []byte) xgb.Error { - v := BadContextTagError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadContextTag" +// BadCurrentDrawableErrorNew constructs a BadCurrentDrawableError value that implements xgb.Error from a byte slice. +func BadCurrentDrawableErrorNew(buf []byte) xgb.Error { + v := BadCurrentDrawableError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadCurrentDrawable" return v } -// SequenceId returns the sequence id attached to the BadBadContextTag error. +// SequenceId returns the sequence id attached to the BadBadCurrentDrawable error. // This is mostly used internally. -func (err BadContextTagError) SequenceId() uint16 { +func (err BadCurrentDrawableError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadBadContextTag error. If no bad value exists, 0 is returned. -func (err BadContextTagError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadCurrentDrawable error. If no bad value exists, 0 is returned. +func (err BadCurrentDrawableError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadBadContextTag error. -func (err BadContextTagError) Error() string { +// Error returns a rudimentary string representation of the BadBadCurrentDrawable error. +func (err BadCurrentDrawableError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadContextTag {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadCurrentDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][4] = BadContextTagErrorNew + xgb.NewExtErrorFuncs["GLX"][11] = BadCurrentDrawableErrorNew } // BadBadCurrentWindow is the error number for a BadBadCurrentWindow. @@ -604,232 +230,232 @@ func init() { xgb.NewExtErrorFuncs["GLX"][5] = BadCurrentWindowErrorNew } -// BadBadRenderRequest is the error number for a BadBadRenderRequest. -const BadBadRenderRequest = 6 +// BadBadDrawable is the error number for a BadBadDrawable. +const BadBadDrawable = 2 -type BadRenderRequestError GenericError +type BadDrawableError GenericError -// BadRenderRequestErrorNew constructs a BadRenderRequestError value that implements xgb.Error from a byte slice. -func BadRenderRequestErrorNew(buf []byte) xgb.Error { - v := BadRenderRequestError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadRenderRequest" +// BadDrawableErrorNew constructs a BadDrawableError value that implements xgb.Error from a byte slice. +func BadDrawableErrorNew(buf []byte) xgb.Error { + v := BadDrawableError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadDrawable" return v } -// SequenceId returns the sequence id attached to the BadBadRenderRequest error. +// SequenceId returns the sequence id attached to the BadBadDrawable error. // This is mostly used internally. -func (err BadRenderRequestError) SequenceId() uint16 { +func (err BadDrawableError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadBadRenderRequest error. If no bad value exists, 0 is returned. -func (err BadRenderRequestError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadDrawable error. If no bad value exists, 0 is returned. +func (err BadDrawableError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadBadRenderRequest error. -func (err BadRenderRequestError) Error() string { +// Error returns a rudimentary string representation of the BadBadDrawable error. +func (err BadDrawableError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadRenderRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][6] = BadRenderRequestErrorNew + xgb.NewExtErrorFuncs["GLX"][2] = BadDrawableErrorNew } -// BadBadLargeRequest is the error number for a BadBadLargeRequest. -const BadBadLargeRequest = 7 +// BadBadFBConfig is the error number for a BadBadFBConfig. +const BadBadFBConfig = 9 -type BadLargeRequestError GenericError +type BadFBConfigError GenericError -// BadLargeRequestErrorNew constructs a BadLargeRequestError value that implements xgb.Error from a byte slice. -func BadLargeRequestErrorNew(buf []byte) xgb.Error { - v := BadLargeRequestError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadLargeRequest" +// BadFBConfigErrorNew constructs a BadFBConfigError value that implements xgb.Error from a byte slice. +func BadFBConfigErrorNew(buf []byte) xgb.Error { + v := BadFBConfigError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadFBConfig" return v } -// SequenceId returns the sequence id attached to the BadBadLargeRequest error. +// SequenceId returns the sequence id attached to the BadBadFBConfig error. // This is mostly used internally. -func (err BadLargeRequestError) SequenceId() uint16 { +func (err BadFBConfigError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadBadLargeRequest error. If no bad value exists, 0 is returned. -func (err BadLargeRequestError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadFBConfig error. If no bad value exists, 0 is returned. +func (err BadFBConfigError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadBadLargeRequest error. -func (err BadLargeRequestError) Error() string { +// Error returns a rudimentary string representation of the BadBadFBConfig error. +func (err BadFBConfigError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadLargeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadFBConfig {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][7] = BadLargeRequestErrorNew + xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew } -// BadUnsupportedPrivateRequest is the error number for a BadUnsupportedPrivateRequest. -const BadUnsupportedPrivateRequest = 8 +// BadBadLargeRequest is the error number for a BadBadLargeRequest. +const BadBadLargeRequest = 7 -type UnsupportedPrivateRequestError GenericError +type BadLargeRequestError GenericError -// UnsupportedPrivateRequestErrorNew constructs a UnsupportedPrivateRequestError value that implements xgb.Error from a byte slice. -func UnsupportedPrivateRequestErrorNew(buf []byte) xgb.Error { - v := UnsupportedPrivateRequestError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "UnsupportedPrivateRequest" +// BadLargeRequestErrorNew constructs a BadLargeRequestError value that implements xgb.Error from a byte slice. +func BadLargeRequestErrorNew(buf []byte) xgb.Error { + v := BadLargeRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadLargeRequest" return v } -// SequenceId returns the sequence id attached to the BadUnsupportedPrivateRequest error. +// SequenceId returns the sequence id attached to the BadBadLargeRequest error. // This is mostly used internally. -func (err UnsupportedPrivateRequestError) SequenceId() uint16 { +func (err BadLargeRequestError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadUnsupportedPrivateRequest error. If no bad value exists, 0 is returned. -func (err UnsupportedPrivateRequestError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadLargeRequest error. If no bad value exists, 0 is returned. +func (err BadLargeRequestError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadUnsupportedPrivateRequest error. -func (err UnsupportedPrivateRequestError) Error() string { +// Error returns a rudimentary string representation of the BadBadLargeRequest error. +func (err BadLargeRequestError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadUnsupportedPrivateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadLargeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew + xgb.NewExtErrorFuncs["GLX"][7] = BadLargeRequestErrorNew } -// BadBadFBConfig is the error number for a BadBadFBConfig. -const BadBadFBConfig = 9 +// BadBadPbuffer is the error number for a BadBadPbuffer. +const BadBadPbuffer = 10 -type BadFBConfigError GenericError +type BadPbufferError GenericError -// BadFBConfigErrorNew constructs a BadFBConfigError value that implements xgb.Error from a byte slice. -func BadFBConfigErrorNew(buf []byte) xgb.Error { - v := BadFBConfigError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadFBConfig" +// BadPbufferErrorNew constructs a BadPbufferError value that implements xgb.Error from a byte slice. +func BadPbufferErrorNew(buf []byte) xgb.Error { + v := BadPbufferError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadPbuffer" return v } -// SequenceId returns the sequence id attached to the BadBadFBConfig error. +// SequenceId returns the sequence id attached to the BadBadPbuffer error. // This is mostly used internally. -func (err BadFBConfigError) SequenceId() uint16 { +func (err BadPbufferError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadBadFBConfig error. If no bad value exists, 0 is returned. -func (err BadFBConfigError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadPbuffer error. If no bad value exists, 0 is returned. +func (err BadPbufferError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadBadFBConfig error. -func (err BadFBConfigError) Error() string { +// Error returns a rudimentary string representation of the BadBadPbuffer error. +func (err BadPbufferError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadFBConfig {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadPbuffer {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew + xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew } -// BadBadPbuffer is the error number for a BadBadPbuffer. -const BadBadPbuffer = 10 +// BadBadPixmap is the error number for a BadBadPixmap. +const BadBadPixmap = 3 -type BadPbufferError GenericError +type BadPixmapError GenericError -// BadPbufferErrorNew constructs a BadPbufferError value that implements xgb.Error from a byte slice. -func BadPbufferErrorNew(buf []byte) xgb.Error { - v := BadPbufferError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadPbuffer" +// BadPixmapErrorNew constructs a BadPixmapError value that implements xgb.Error from a byte slice. +func BadPixmapErrorNew(buf []byte) xgb.Error { + v := BadPixmapError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadPixmap" return v } -// SequenceId returns the sequence id attached to the BadBadPbuffer error. +// SequenceId returns the sequence id attached to the BadBadPixmap error. // This is mostly used internally. -func (err BadPbufferError) SequenceId() uint16 { +func (err BadPixmapError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadBadPbuffer error. If no bad value exists, 0 is returned. -func (err BadPbufferError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadPixmap error. If no bad value exists, 0 is returned. +func (err BadPixmapError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadBadPbuffer error. -func (err BadPbufferError) Error() string { +// Error returns a rudimentary string representation of the BadBadPixmap error. +func (err BadPixmapError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadPbuffer {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew + xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew } -// BadBadCurrentDrawable is the error number for a BadBadCurrentDrawable. -const BadBadCurrentDrawable = 11 +// BadBadRenderRequest is the error number for a BadBadRenderRequest. +const BadBadRenderRequest = 6 -type BadCurrentDrawableError GenericError +type BadRenderRequestError GenericError -// BadCurrentDrawableErrorNew constructs a BadCurrentDrawableError value that implements xgb.Error from a byte slice. -func BadCurrentDrawableErrorNew(buf []byte) xgb.Error { - v := BadCurrentDrawableError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadCurrentDrawable" +// BadRenderRequestErrorNew constructs a BadRenderRequestError value that implements xgb.Error from a byte slice. +func BadRenderRequestErrorNew(buf []byte) xgb.Error { + v := BadRenderRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadRenderRequest" return v } -// SequenceId returns the sequence id attached to the BadBadCurrentDrawable error. +// SequenceId returns the sequence id attached to the BadBadRenderRequest error. // This is mostly used internally. -func (err BadCurrentDrawableError) SequenceId() uint16 { +func (err BadRenderRequestError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadBadCurrentDrawable error. If no bad value exists, 0 is returned. -func (err BadCurrentDrawableError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadBadRenderRequest error. If no bad value exists, 0 is returned. +func (err BadRenderRequestError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadBadCurrentDrawable error. -func (err BadCurrentDrawableError) Error() string { +// Error returns a rudimentary string representation of the BadBadRenderRequest error. +func (err BadRenderRequestError) Error() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadCurrentDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadBadRenderRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][11] = BadCurrentDrawableErrorNew + xgb.NewExtErrorFuncs["GLX"][6] = BadRenderRequestErrorNew } // BadBadWindow is the error number for a BadBadWindow. @@ -870,6 +496,44 @@ func init() { xgb.NewExtErrorFuncs["GLX"][12] = BadWindowErrorNew } +type Bool32 uint32 + +type Context uint32 + +func NewContextId(c *xgb.Conn) (Context, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Context(id), nil +} + +type ContextTag uint32 + +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Drawable(id), nil +} + +type Fbconfig uint32 + +func NewFbconfigId(c *xgb.Conn) (Fbconfig, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fbconfig(id), nil +} + +type Float32 float64 + +type Float64 float64 + // BadGLXBadProfileARB is the error number for a BadGLXBadProfileARB. const BadGLXBadProfileARB = 13 @@ -908,490 +572,381 @@ func init() { xgb.NewExtErrorFuncs["GLX"][13] = GLXBadProfileARBErrorNew } -// RenderCookie is a cookie used only for Render requests. -type RenderCookie struct { - *xgb.Cookie -} +const ( + GcGlCurrentBit = 1 + GcGlPointBit = 2 + GcGlLineBit = 4 + GcGlPolygonBit = 8 + GcGlPolygonStippleBit = 16 + GcGlPixelModeBit = 32 + GcGlLightingBit = 64 + GcGlFogBit = 128 + GcGlDepthBufferBit = 256 + GcGlAccumBufferBit = 512 + GcGlStencilBufferBit = 1024 + GcGlViewportBit = 2048 + GcGlTransformBit = 4096 + GcGlEnableBit = 8192 + GcGlColorBufferBit = 16384 + GcGlHintBit = 32768 + GcGlEvalBit = 65536 + GcGlListBit = 131072 + GcGlTextureBit = 262144 + GcGlScissorBit = 524288 + GcGlAllAttribBits = 16777215 +) -// Render sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Render(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Render' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(renderRequest(c, ContextTag, Data), cookie) - return RenderCookie{cookie} -} +// BadGeneric is the error number for a BadGeneric. +const BadGeneric = -1 -// RenderChecked sends a checked request. -// If an error occurs, it can be retrieved using RenderCookie.Check() -func RenderChecked(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Render' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(renderRequest(c, ContextTag, Data), cookie) - return RenderCookie{cookie} +type GenericError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 21 bytes } -// 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 RenderCookie) Check() error { - return cook.Cookie.Check() -} +// GenericErrorNew constructs a GenericError value that implements xgb.Error from a byte slice. +func GenericErrorNew(buf []byte) xgb.Error { + v := GenericError{} + v.NiceName = "Generic" -// Write request to wire for Render -// renderRequest writes a Render request to a byte slice. -func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) + b := 1 // skip error determinant + b += 1 // don't read error number - buf[b] = c.Extensions["GLX"] - b += 1 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - buf[b] = 1 // request opcode - b += 1 + v.BadValue = xgb.Get32(buf[b:]) + b += 4 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.MinorOpcode = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 + v.MajorOpcode = buf[b] + b += 1 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += 21 // padding - return buf + return v } -// RenderLargeCookie is a cookie used only for RenderLarge requests. -type RenderLargeCookie struct { - *xgb.Cookie +// SequenceId returns the sequence id attached to the BadGeneric error. +// This is mostly used internally. +func (err GenericError) SequenceId() uint16 { + return err.Sequence } -// RenderLarge sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RenderLarge(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return RenderLargeCookie{cookie} +// BadId returns the 'BadValue' number if one exists for the BadGeneric error. If no bad value exists, 0 is returned. +func (err GenericError) BadId() uint32 { + return 0 } -// RenderLargeChecked sends a checked request. -// If an error occurs, it can be retrieved using RenderLargeCookie.Check() -func RenderLargeChecked(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") +// Error returns a rudimentary string representation of the BadGeneric error. + +func (err GenericError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew +} + +const ( + PbcdtWindow = 32793 + PbcdtPbuffer = 32794 +) + +const ( + PbcetDamaged = 32791 + PbcetSaved = 32792 +) + +type Pbuffer uint32 + +func NewPbufferId(c *xgb.Conn) (Pbuffer, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - cookie := c.NewCookie(true, false) - c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return RenderLargeCookie{cookie} + return Pbuffer(id), nil } -// 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 RenderLargeCookie) Check() error { - return cook.Cookie.Check() +// PbufferClobber is the event number for a PbufferClobberEvent. +const PbufferClobber = 0 + +type PbufferClobberEvent struct { + Sequence uint16 + // padding: 1 bytes + EventType uint16 + DrawType uint16 + Drawable Drawable + BMask uint32 + AuxBuffer uint16 + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 4 bytes } -// Write request to wire for RenderLarge -// renderLargeRequest writes a RenderLarge request to a byte slice. -func renderLargeRequest(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) []byte { - size := xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) - b := 0 - buf := make([]byte, size) +// PbufferClobberEventNew constructs a PbufferClobberEvent value that implements xgb.Event from a byte slice. +func PbufferClobberEventNew(buf []byte) xgb.Event { + v := PbufferClobberEvent{} + b := 1 // don't read event number - buf[b] = c.Extensions["GLX"] - b += 1 + b += 1 // padding - buf[b] = 2 // request opcode - b += 1 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.EventType = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + v.DrawType = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], RequestNum) - b += 2 + v.BMask = xgb.Get32(buf[b:]) + b += 4 - xgb.Put16(buf[b:], RequestTotal) + v.AuxBuffer = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], DataLen) - b += 4 + v.X = xgb.Get16(buf[b:]) + b += 2 - copy(buf[b:], Data[:DataLen]) - b += xgb.Pad(int(DataLen)) + v.Y = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.Width = xgb.Get16(buf[b:]) + b += 2 -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { - *xgb.Cookie -} + v.Height = xgb.Get16(buf[b:]) + b += 2 -// CreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateContext(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) - return CreateContextCookie{cookie} -} + v.Count = xgb.Get16(buf[b:]) + b += 2 -// CreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateContextCookie.Check() -func CreateContextChecked(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) - return CreateContextCookie{cookie} -} + b += 4 // padding -// 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 CreateContextCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for CreateContext -// createContextRequest writes a CreateContext request to a byte slice. -func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) []byte { - size := 24 +// Bytes writes a PbufferClobberEvent value to a byte slice. +func (v PbufferClobberEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf := make([]byte, size) - buf[b] = c.Extensions["GLX"] + // write event number + buf[b] = 0 b += 1 - buf[b] = 3 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(Context)) - b += 4 + xgb.Put16(buf[b:], v.EventType) + b += 2 - xgb.Put32(buf[b:], uint32(Visual)) - b += 4 + xgb.Put16(buf[b:], v.DrawType) + b += 2 - xgb.Put32(buf[b:], Screen) + xgb.Put32(buf[b:], uint32(v.Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(ShareList)) + xgb.Put32(buf[b:], v.BMask) b += 4 - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// DestroyContextCookie is a cookie used only for DestroyContext requests. -type DestroyContextCookie struct { - *xgb.Cookie -} - -// 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, Context Context) DestroyContextCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyContextRequest(c, 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, Context Context) DestroyContextCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyContextRequest(c, Context), cookie) - return DestroyContextCookie{cookie} -} + xgb.Put16(buf[b:], v.AuxBuffer) + b += 2 -// 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() -} + xgb.Put16(buf[b:], v.X) + b += 2 -// Write request to wire for DestroyContext -// destroyContextRequest writes a DestroyContext request to a byte slice. -func destroyContextRequest(c *xgb.Conn, Context Context) []byte { - size := 8 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], v.Y) + b += 2 - buf[b] = c.Extensions["GLX"] - b += 1 + xgb.Put16(buf[b:], v.Width) + b += 2 - buf[b] = 4 // request opcode - b += 1 + xgb.Put16(buf[b:], v.Height) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], v.Count) b += 2 - xgb.Put32(buf[b:], uint32(Context)) - b += 4 + b += 4 // padding return buf } -// MakeCurrentCookie is a cookie used only for MakeCurrent requests. -type MakeCurrentCookie struct { - *xgb.Cookie +// SequenceId returns the sequence id attached to the PbufferClobber event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v PbufferClobberEvent) SequenceId() uint16 { + return v.Sequence } -// MakeCurrent sends a checked request. -// If an error occurs, it will be returned with the reply by calling MakeCurrentCookie.Reply() -func MakeCurrent(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) - return MakeCurrentCookie{cookie} +// String is a rudimentary string representation of PbufferClobberEvent. +func (v PbufferClobberEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("EventType: %d", v.EventType)) + fieldVals = append(fieldVals, xgb.Sprintf("DrawType: %d", v.DrawType)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("BMask: %d", v.BMask)) + fieldVals = append(fieldVals, xgb.Sprintf("AuxBuffer: %d", v.AuxBuffer)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "PbufferClobber {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// MakeCurrentUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) - return MakeCurrentCookie{cookie} +func init() { + xgb.NewExtEventFuncs["GLX"][0] = PbufferClobberEventNew } -// MakeCurrentReply represents the data returned from a MakeCurrent request. -type MakeCurrentReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ContextTag ContextTag - // padding: 20 bytes -} +type Pixmap uint32 -// Reply blocks and returns the reply data for a MakeCurrent request. -func (cook MakeCurrentCookie) Reply() (*MakeCurrentReply, error) { - buf, err := cook.Cookie.Reply() +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() if err != nil { - return nil, err - } - if buf == nil { - return nil, nil + return 0, err } - return makeCurrentReply(buf), nil + return Pixmap(id), nil } -// makeCurrentReply reads a byte slice into a MakeCurrentReply value. -func makeCurrentReply(buf []byte) *MakeCurrentReply { - v := new(MakeCurrentReply) - 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 +const ( + RmGlRender = 7168 + RmGlFeedback = 7169 + RmGlSelect = 7170 +) - v.ContextTag = ContextTag(xgb.Get32(buf[b:])) - b += 4 +// BadUnsupportedPrivateRequest is the error number for a BadUnsupportedPrivateRequest. +const BadUnsupportedPrivateRequest = 8 - b += 20 // padding +type UnsupportedPrivateRequestError GenericError +// UnsupportedPrivateRequestErrorNew constructs a UnsupportedPrivateRequestError value that implements xgb.Error from a byte slice. +func UnsupportedPrivateRequestErrorNew(buf []byte) xgb.Error { + v := UnsupportedPrivateRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "UnsupportedPrivateRequest" return v } -// Write request to wire for MakeCurrent -// makeCurrentRequest writes a MakeCurrent request to a byte slice. -func makeCurrentRequest(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - 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:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Context)) - b += 4 - - xgb.Put32(buf[b:], uint32(OldContextTag)) - b += 4 - - return buf +// SequenceId returns the sequence id attached to the BadUnsupportedPrivateRequest error. +// This is mostly used internally. +func (err UnsupportedPrivateRequestError) SequenceId() uint16 { + return err.Sequence } -// IsDirectCookie is a cookie used only for IsDirect requests. -type IsDirectCookie struct { - *xgb.Cookie +// BadId returns the 'BadValue' number if one exists for the BadUnsupportedPrivateRequest error. If no bad value exists, 0 is returned. +func (err UnsupportedPrivateRequestError) BadId() uint32 { + return 0 } -// IsDirect sends a checked request. -// If an error occurs, it will be returned with the reply by calling IsDirectCookie.Reply() -func IsDirect(c *xgb.Conn, Context Context) IsDirectCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsDirect' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(isDirectRequest(c, Context), cookie) - return IsDirectCookie{cookie} +// Error returns a rudimentary string representation of the BadUnsupportedPrivateRequest error. +func (err UnsupportedPrivateRequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadUnsupportedPrivateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// IsDirectUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsDirect' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(isDirectRequest(c, Context), cookie) - return IsDirectCookie{cookie} +func init() { + xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew } -// IsDirectReply represents the data returned from a IsDirect request. -type IsDirectReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - IsDirect bool - // padding: 23 bytes -} +type Window uint32 -// Reply blocks and returns the reply data for a IsDirect request. -func (cook IsDirectCookie) Reply() (*IsDirectReply, error) { - buf, err := cook.Cookie.Reply() +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() if err != nil { - return nil, err - } - if buf == nil { - return nil, nil + return 0, err } - return isDirectReply(buf), nil + return Window(id), nil } -// isDirectReply reads a byte slice into a IsDirectReply value. -func isDirectReply(buf []byte) *IsDirectReply { - v := new(IsDirectReply) - b := 1 // skip reply determinant - - b += 1 // padding +// Skipping definition for base type 'Bool' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Byte' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Card8' - if buf[b] == 1 { - v.IsDirect = true - } else { - v.IsDirect = false - } - b += 1 +// Skipping definition for base type 'Char' - b += 23 // padding +// Skipping definition for base type 'Void' - return v -} +// Skipping definition for base type 'Double' -// Write request to wire for IsDirect -// isDirectRequest writes a IsDirect request to a byte slice. -func isDirectRequest(c *xgb.Conn, Context Context) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Float' - buf[b] = c.Extensions["GLX"] - b += 1 +// Skipping definition for base type 'Int16' - buf[b] = 6 // 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(Context)) - b += 4 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// AreTexturesResidentCookie is a cookie used only for AreTexturesResident requests. +type AreTexturesResidentCookie 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +// AreTexturesResident sends a checked request. +// If an error occurs, it will be returned with the reply by calling AreTexturesResidentCookie.Reply() +func AreTexturesResident(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'AreTexturesResident' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) + return AreTexturesResidentCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// AreTexturesResidentUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +func AreTexturesResidentUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'AreTexturesResident' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) + return AreTexturesResidentCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// AreTexturesResidentReply represents the data returned from a AreTexturesResident request. +type AreTexturesResidentReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + RetVal Bool32 + // padding: 20 bytes + Data []bool // size: xgb.Pad(((int(Length) * 4) * 1)) } -// 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 AreTexturesResident request. +func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1399,12 +954,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return areTexturesResidentReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// areTexturesResidentReply reads a byte slice into a AreTexturesResidentReply value. +func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { + v := new(AreTexturesResidentReply) b := 1 // skip reply determinant b += 1 // padding @@ -1415,149 +970,181 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get32(buf[b:]) + v.RetVal = Bool32(xgb.Get32(buf[b:])) b += 4 - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 + b += 20 // padding - b += 16 // padding + v.Data = make([]bool, (int(v.Length) * 4)) + for i := 0; i < int((int(v.Length) * 4)); i++ { + if buf[b] == 1 { + v.Data[i] = true + } else { + v.Data[i] = false + } + b += 1 + } + b = xgb.Pad(b) return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 +// Write request to wire for AreTexturesResident +// areTexturesResidentRequest writes a AreTexturesResident request to a byte slice. +func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 143 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], MajorVersion) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], MinorVersion) + xgb.Put32(buf[b:], uint32(N)) b += 4 + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// WaitGLCookie is a cookie used only for WaitGL requests. -type WaitGLCookie struct { +// ChangeDrawableAttributesCookie is a cookie used only for ChangeDrawableAttributes requests. +type ChangeDrawableAttributesCookie struct { *xgb.Cookie } -// WaitGL sends an unchecked request. +// ChangeDrawableAttributes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func WaitGL(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { +func ChangeDrawableAttributes(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'WaitGL' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(waitGLRequest(c, ContextTag), cookie) - return WaitGLCookie{cookie} + c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{cookie} } -// WaitGLChecked sends a checked request. -// If an error occurs, it can be retrieved using WaitGLCookie.Check() -func WaitGLChecked(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { +// ChangeDrawableAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeDrawableAttributesCookie.Check() +func ChangeDrawableAttributesChecked(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'WaitGL' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(waitGLRequest(c, ContextTag), cookie) - return WaitGLCookie{cookie} + c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{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 WaitGLCookie) Check() error { +func (cook ChangeDrawableAttributesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for WaitGL -// waitGLRequest writes a WaitGL request to a byte slice. -func waitGLRequest(c *xgb.Conn, ContextTag ContextTag) []byte { - size := 8 +// Write request to wire for ChangeDrawableAttributes +// changeDrawableAttributesRequest writes a ChangeDrawableAttributes request to a byte slice. +func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// WaitXCookie is a cookie used only for WaitX requests. -type WaitXCookie struct { +// ClientInfoCookie is a cookie used only for ClientInfo requests. +type ClientInfoCookie struct { *xgb.Cookie } -// WaitX sends an unchecked request. +// ClientInfo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func WaitX(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { +func ClientInfo(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'WaitX' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'ClientInfo' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(waitXRequest(c, ContextTag), cookie) - return WaitXCookie{cookie} + c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) + return ClientInfoCookie{cookie} } -// WaitXChecked sends a checked request. -// If an error occurs, it can be retrieved using WaitXCookie.Check() -func WaitXChecked(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { +// ClientInfoChecked sends a checked request. +// If an error occurs, it can be retrieved using ClientInfoCookie.Check() +func ClientInfoChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'WaitX' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'ClientInfo' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(waitXRequest(c, ContextTag), cookie) - return WaitXCookie{cookie} + c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) + return ClientInfoCookie{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 WaitXCookie) Check() error { +func (cook ClientInfoCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for WaitX -// waitXRequest writes a WaitX request to a byte slice. -func waitXRequest(c *xgb.Conn, ContextTag ContextTag) []byte { - size := 8 +// Write request to wire for ClientInfo +// clientInfoRequest writes a ClientInfo request to a byte slice. +func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 20 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], StrLen) b += 4 + copy(buf[b:], String[:StrLen]) + b += xgb.Pad(int(StrLen)) + return buf } @@ -1625,128 +1212,158 @@ func copyContextRequest(c *xgb.Conn, Src Context, Dest Context, Mask uint32, Src return buf } -// SwapBuffersCookie is a cookie used only for SwapBuffers requests. -type SwapBuffersCookie struct { +// CreateContextCookie is a cookie used only for CreateContext requests. +type CreateContextCookie struct { *xgb.Cookie } -// SwapBuffers sends an unchecked request. +// CreateContext sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SwapBuffers(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { +func CreateContext(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SwapBuffers' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) - return SwapBuffersCookie{cookie} + c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) + return CreateContextCookie{cookie} } -// SwapBuffersChecked sends a checked request. -// If an error occurs, it can be retrieved using SwapBuffersCookie.Check() -func SwapBuffersChecked(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { +// CreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateContextCookie.Check() +func CreateContextChecked(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SwapBuffers' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) - return SwapBuffersCookie{cookie} + c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) + return CreateContextCookie{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 SwapBuffersCookie) Check() error { +func (cook CreateContextCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SwapBuffers -// swapBuffersRequest writes a SwapBuffers request to a byte slice. -func swapBuffersRequest(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) []byte { - size := 12 +// Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. +func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) []byte { + size := 24 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 11 // request opcode + 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(ContextTag)) + xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + return buf } -// UseXFontCookie is a cookie used only for UseXFont requests. -type UseXFontCookie struct { +// CreateContextAttribsARBCookie is a cookie used only for CreateContextAttribsARB requests. +type CreateContextAttribsARBCookie struct { *xgb.Cookie } -// UseXFont sends an unchecked request. +// CreateContextAttribsARB sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UseXFont(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { +func CreateContextAttribsARB(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'UseXFont' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContextAttribsARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) - return UseXFontCookie{cookie} + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{cookie} } -// UseXFontChecked sends a checked request. -// If an error occurs, it can be retrieved using UseXFontCookie.Check() -func UseXFontChecked(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { +// CreateContextAttribsARBChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateContextAttribsARBCookie.Check() +func CreateContextAttribsARBChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'UseXFont' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContextAttribsARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) - return UseXFontCookie{cookie} + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{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 UseXFontCookie) Check() error { +func (cook CreateContextAttribsARBCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UseXFont -// useXFontRequest writes a UseXFont request to a byte slice. -func useXFontRequest(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) []byte { - size := 24 +// Write request to wire for CreateContextAttribsARB +// createContextAttribsARBRequest writes a CreateContextAttribsARB request to a byte slice. +func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 34 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], uint32(Font)) + xgb.Put32(buf[b:], uint32(Fbconfig)) b += 4 - xgb.Put32(buf[b:], First) + xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Count) + xgb.Put32(buf[b:], uint32(ShareList)) b += 4 - xgb.Put32(buf[b:], ListBase) + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumAttribs) b += 4 + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } @@ -1814,98 +1431,126 @@ func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, return buf } -// GetVisualConfigsCookie is a cookie used only for GetVisualConfigs requests. -type GetVisualConfigsCookie struct { +// CreateNewContextCookie is a cookie used only for CreateNewContext requests. +type CreateNewContextCookie struct { *xgb.Cookie } -// GetVisualConfigs sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetVisualConfigsCookie.Reply() -func GetVisualConfigs(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { +// CreateNewContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateNewContext(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetVisualConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateNewContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) - return GetVisualConfigsCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{cookie} } -// GetVisualConfigsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { +// CreateNewContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateNewContextCookie.Check() +func CreateNewContextChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetVisualConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateNewContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) - return GetVisualConfigsCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{cookie} } -// GetVisualConfigsReply represents the data returned from a GetVisualConfigs request. -type GetVisualConfigsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumVisuals uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) +// 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 CreateNewContextCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetVisualConfigs request. -func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getVisualConfigsReply(buf), nil -} +// Write request to wire for CreateNewContext +// createNewContextRequest writes a CreateNewContext request to a byte slice. +func createNewContextRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) -// getVisualConfigsReply reads a byte slice into a GetVisualConfigsReply value. -func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { - v := new(GetVisualConfigsReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 24 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Context)) b += 4 - v.NumVisuals = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(Fbconfig)) b += 4 - v.NumProperties = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], Screen) b += 4 - b += 16 // padding + xgb.Put32(buf[b:], RenderType) + b += 4 - v.PropertyList = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PropertyList[i] = xgb.Get32(buf[b:]) - b += 4 + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 } - b = xgb.Pad(b) + b += 1 - return v + b += 3 // padding + + return buf } -// Write request to wire for GetVisualConfigs -// getVisualConfigsRequest writes a GetVisualConfigs request to a byte slice. -func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 +// CreatePbufferCookie is a cookie used only for CreatePbuffer requests. +type CreatePbufferCookie struct { + *xgb.Cookie +} + +// CreatePbuffer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreatePbuffer(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'CreatePbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) + return CreatePbufferCookie{cookie} +} + +// CreatePbufferChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePbufferCookie.Check() +func CreatePbufferChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'CreatePbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) + return CreatePbufferCookie{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 CreatePbufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePbuffer +// createPbufferRequest writes a CreatePbuffer request to a byte slice. +func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 27 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1914,576 +1559,505 @@ func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pbuffer)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// DestroyGLXPixmapCookie is a cookie used only for DestroyGLXPixmap requests. -type DestroyGLXPixmapCookie struct { +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { *xgb.Cookie } -// DestroyGLXPixmap sends an unchecked request. +// CreatePixmap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { +func CreatePixmap(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) - return DestroyGLXPixmapCookie{cookie} + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{cookie} } -// DestroyGLXPixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyGLXPixmapCookie.Check() -func DestroyGLXPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() +func CreatePixmapChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) - return DestroyGLXPixmapCookie{cookie} + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{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 DestroyGLXPixmapCookie) Check() error { +func (cook CreatePixmapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyGLXPixmap -// destroyGLXPixmapRequest writes a DestroyGLXPixmap request to a byte slice. -func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { - size := 8 +// Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. +func createPixmapRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 15 // request opcode + buf[b] = 22 // 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:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + xgb.Put32(buf[b:], uint32(GlxPixmap)) b += 4 + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// VendorPrivateCookie is a cookie used only for VendorPrivate requests. -type VendorPrivateCookie struct { +// CreateWindowCookie is a cookie used only for CreateWindow requests. +type CreateWindowCookie struct { *xgb.Cookie } -// VendorPrivate sends an unchecked request. +// CreateWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func VendorPrivate(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { +func CreateWindow(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'VendorPrivate' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateCookie{cookie} + c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) + return CreateWindowCookie{cookie} } -// VendorPrivateChecked sends a checked request. -// If an error occurs, it can be retrieved using VendorPrivateCookie.Check() -func VendorPrivateChecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { +// CreateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateWindowCookie.Check() +func CreateWindowChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'VendorPrivate' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateCookie{cookie} + c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) + return CreateWindowCookie{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 VendorPrivateCookie) Check() error { +func (cook CreateWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for VendorPrivate -// vendorPrivateRequest writes a VendorPrivate request to a byte slice. -func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +// Write request to wire for CreateWindow +// createWindowRequest writes a CreateWindow request to a byte slice. +func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 16 // request opcode + buf[b] = 31 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], VendorCode) + xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], uint32(Fbconfig)) b += 4 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxWindow)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// VendorPrivateWithReplyCookie is a cookie used only for VendorPrivateWithReply requests. -type VendorPrivateWithReplyCookie struct { +// DeleteListsCookie is a cookie used only for DeleteLists requests. +type DeleteListsCookie struct { *xgb.Cookie } -// VendorPrivateWithReply sends a checked request. -// If an error occurs, it will be returned with the reply by calling VendorPrivateWithReplyCookie.Reply() -func VendorPrivateWithReply(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateWithReplyCookie{cookie} -} - -// VendorPrivateWithReplyUnchecked sends an unchecked request. +// DeleteLists sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func VendorPrivateWithReplyUnchecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { +func DeleteLists(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateWithReplyCookie{cookie} -} - -// VendorPrivateWithReplyReply represents the data returned from a VendorPrivateWithReply request. -type VendorPrivateWithReplyReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Retval uint32 - Data1 []byte // size: 24 - Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + cookie := c.NewCookie(false, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} } -// Reply blocks and returns the reply data for a VendorPrivateWithReply request. -func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DeleteListsChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteListsCookie.Check() +func DeleteListsChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return vendorPrivateWithReplyReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} } -// vendorPrivateWithReplyReply reads a byte slice into a VendorPrivateWithReplyReply value. -func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { - v := new(VendorPrivateWithReplyReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Retval = xgb.Get32(buf[b:]) - b += 4 - - v.Data1 = make([]byte, 24) - copy(v.Data1[:24], buf[b:]) - b += xgb.Pad(int(24)) - - v.Data2 = make([]byte, (int(v.Length) * 4)) - copy(v.Data2[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 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 DeleteListsCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for VendorPrivateWithReply -// vendorPrivateWithReplyRequest writes a VendorPrivateWithReply request to a byte slice. -func vendorPrivateWithReplyRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +// Write request to wire for DeleteLists +// deleteListsRequest writes a DeleteLists request to a byte slice. +func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 17 // request opcode + buf[b] = 103 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], VendorCode) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], List) b += 4 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + xgb.Put32(buf[b:], uint32(Range)) + b += 4 return buf } -// QueryExtensionsStringCookie is a cookie used only for QueryExtensionsString requests. -type QueryExtensionsStringCookie struct { +// DeleteQueriesARBCookie is a cookie used only for DeleteQueriesARB requests. +type DeleteQueriesARBCookie struct { *xgb.Cookie } -// QueryExtensionsString sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryExtensionsStringCookie.Reply() -func QueryExtensionsString(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) - return QueryExtensionsStringCookie{cookie} -} - -// QueryExtensionsStringUnchecked sends an unchecked request. +// DeleteQueriesARB sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { +func DeleteQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) - return QueryExtensionsStringCookie{cookie} -} - -// QueryExtensionsStringReply represents the data returned from a QueryExtensionsString request. -type QueryExtensionsStringReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - // padding: 16 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} } -// Reply blocks and returns the reply data for a QueryExtensionsString request. -func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DeleteQueriesARBChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteQueriesARBCookie.Check() +func DeleteQueriesARBChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return queryExtensionsStringReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} } -// queryExtensionsStringReply reads a byte slice into a QueryExtensionsStringReply value. -func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { - v := new(QueryExtensionsStringReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - 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 DeleteQueriesARBCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryExtensionsString -// queryExtensionsStringRequest writes a QueryExtensionsString request to a byte slice. -func queryExtensionsStringRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 +// Write request to wire for DeleteQueriesARB +// deleteQueriesARBRequest writes a DeleteQueriesARB request to a byte slice. +func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 161 // 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) + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) b += 4 + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Ids[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// QueryServerStringCookie is a cookie used only for QueryServerString requests. -type QueryServerStringCookie struct { +// DeleteTexturesCookie is a cookie used only for DeleteTextures requests. +type DeleteTexturesCookie struct { *xgb.Cookie } -// QueryServerString sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryServerStringCookie.Reply() -func QueryServerString(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryServerString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) - return QueryServerStringCookie{cookie} -} - -// QueryServerStringUnchecked sends an unchecked request. +// DeleteTextures sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryServerStringUnchecked(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { +func DeleteTextures(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryServerString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) - return QueryServerStringCookie{cookie} -} - -// QueryServerStringReply represents the data returned from a QueryServerString request. -type QueryServerStringReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - StrLen uint32 - // padding: 16 bytes - String string // size: xgb.Pad((int(StrLen) * 1)) + cookie := c.NewCookie(false, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} } -// Reply blocks and returns the reply data for a QueryServerString request. -func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DeleteTexturesChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteTexturesCookie.Check() +func DeleteTexturesChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return queryServerStringReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} } -// queryServerStringReply reads a byte slice into a QueryServerStringReply value. -func queryServerStringReply(buf []byte) *QueryServerStringReply { - v := new(QueryServerStringReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.StrLen = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.StrLen) - copy(byteString[:v.StrLen], buf[b:]) - v.String = string(byteString) - b += xgb.Pad(int(v.StrLen)) - } - - 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 DeleteTexturesCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryServerString -// queryServerStringRequest writes a QueryServerString request to a byte slice. -func queryServerStringRequest(c *xgb.Conn, Screen uint32, Name uint32) []byte { - size := 12 +// Write request to wire for DeleteTextures +// deleteTexturesRequest writes a DeleteTextures request to a byte slice. +func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 144 // 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) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Name) + xgb.Put32(buf[b:], uint32(N)) b += 4 + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// ClientInfoCookie is a cookie used only for ClientInfo requests. -type ClientInfoCookie struct { +// DeleteWindowCookie is a cookie used only for DeleteWindow requests. +type DeleteWindowCookie struct { *xgb.Cookie } -// ClientInfo sends an unchecked request. +// DeleteWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ClientInfo(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { +func DeleteWindow(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ClientInfo' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) - return ClientInfoCookie{cookie} + c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) + return DeleteWindowCookie{cookie} } -// ClientInfoChecked sends a checked request. -// If an error occurs, it can be retrieved using ClientInfoCookie.Check() -func ClientInfoChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { +// DeleteWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteWindowCookie.Check() +func DeleteWindowChecked(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ClientInfo' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) - return ClientInfoCookie{cookie} + c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) + return DeleteWindowCookie{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 ClientInfoCookie) Check() error { +func (cook DeleteWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ClientInfo -// clientInfoRequest writes a ClientInfo request to a byte slice. -func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { - size := xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) +// Write request to wire for DeleteWindow +// deleteWindowRequest writes a DeleteWindow request to a byte slice. +func deleteWindowRequest(c *xgb.Conn, Glxwindow Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 32 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], MajorVersion) - b += 4 - - xgb.Put32(buf[b:], MinorVersion) - b += 4 - - xgb.Put32(buf[b:], StrLen) + xgb.Put32(buf[b:], uint32(Glxwindow)) b += 4 - copy(buf[b:], String[:StrLen]) - b += xgb.Pad(int(StrLen)) - return buf } -// GetFBConfigsCookie is a cookie used only for GetFBConfigs requests. -type GetFBConfigsCookie struct { +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { *xgb.Cookie } -// GetFBConfigs sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetFBConfigsCookie.Reply() -func GetFBConfigs(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { +// 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, Context Context) DestroyContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetFBConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getFBConfigsRequest(c, Screen), cookie) - return GetFBConfigsCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{cookie} } -// GetFBConfigsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetFBConfigsUnchecked(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { +// DestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyContextCookie.Check() +func DestroyContextChecked(c *xgb.Conn, Context Context) DestroyContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetFBConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getFBConfigsRequest(c, Screen), cookie) - return GetFBConfigsCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{cookie} } -// GetFBConfigsReply represents the data returned from a GetFBConfigs request. -type GetFBConfigsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumFbConfigs uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) +// 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() } -// Reply blocks and returns the reply data for a GetFBConfigs request. -func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getFBConfigsReply(buf), nil -} +// Write request to wire for DestroyContext +// destroyContextRequest writes a DestroyContext request to a byte slice. +func destroyContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) -// getFBConfigsReply reads a byte slice into a GetFBConfigsReply value. -func getFBConfigsReply(buf []byte) *GetFBConfigsReply { - v := new(GetFBConfigsReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 4 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Context)) b += 4 - v.NumFbConfigs = xgb.Get32(buf[b:]) - b += 4 + return buf +} - v.NumProperties = xgb.Get32(buf[b:]) - b += 4 +// DestroyGLXPixmapCookie is a cookie used only for DestroyGLXPixmap requests. +type DestroyGLXPixmapCookie struct { + *xgb.Cookie +} - b += 16 // padding +// DestroyGLXPixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DestroyGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{cookie} +} - v.PropertyList = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PropertyList[i] = xgb.Get32(buf[b:]) - b += 4 +// DestroyGLXPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyGLXPixmapCookie.Check() +func DestroyGLXPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DestroyGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{cookie} +} - 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 DestroyGLXPixmapCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetFBConfigs -// getFBConfigsRequest writes a GetFBConfigs request to a byte slice. -func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { +// Write request to wire for DestroyGLXPixmap +// destroyGLXPixmapRequest writes a DestroyGLXPixmap request to a byte slice. +func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -2491,88 +2065,70 @@ func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 21 // request opcode + buf[b] = 15 // 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) + xgb.Put32(buf[b:], uint32(GlxPixmap)) b += 4 return buf } -// CreatePixmapCookie is a cookie used only for CreatePixmap requests. -type CreatePixmapCookie struct { +// DestroyPbufferCookie is a cookie used only for DestroyPbuffer requests. +type DestroyPbufferCookie struct { *xgb.Cookie } -// CreatePixmap sends an unchecked request. +// DestroyPbuffer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreatePixmap(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { +func DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyPbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) - return CreatePixmapCookie{cookie} + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{cookie} } -// CreatePixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() -func CreatePixmapChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { +// DestroyPbufferChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyPbufferCookie.Check() +func DestroyPbufferChecked(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyPbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) - return CreatePixmapCookie{cookie} + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{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 CreatePixmapCookie) Check() error { +func (cook DestroyPbufferCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreatePixmap -// createPixmapRequest writes a CreatePixmap request to a byte slice. -func createPixmapRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) []byte { - size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// Write request to wire for DestroyPbuffer +// destroyPbufferRequest writes a DestroyPbuffer request to a byte slice. +func destroyPbufferRequest(c *xgb.Conn, Pbuffer Pbuffer) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 22 // request opcode + buf[b] = 28 // 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:], uint32(Fbconfig)) - b += 4 - - xgb.Put32(buf[b:], uint32(Pixmap)) - b += 4 - - xgb.Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - xgb.Put32(buf[b:], NumAttribs) + xgb.Put32(buf[b:], uint32(Pbuffer)) b += 4 - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } @@ -2631,121 +2187,158 @@ func destroyPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { return buf } -// CreateNewContextCookie is a cookie used only for CreateNewContext requests. -type CreateNewContextCookie struct { +// EndListCookie is a cookie used only for EndList requests. +type EndListCookie struct { *xgb.Cookie } -// CreateNewContext sends an unchecked request. +// EndList sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateNewContext(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { +func EndList(c *xgb.Conn, ContextTag ContextTag) EndListCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateNewContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'EndList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) - return CreateNewContextCookie{cookie} + c.NewRequest(endListRequest(c, ContextTag), cookie) + return EndListCookie{cookie} } -// CreateNewContextChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateNewContextCookie.Check() -func CreateNewContextChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { +// EndListChecked sends a checked request. +// If an error occurs, it can be retrieved using EndListCookie.Check() +func EndListChecked(c *xgb.Conn, ContextTag ContextTag) EndListCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateNewContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'EndList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) - return CreateNewContextCookie{cookie} + c.NewRequest(endListRequest(c, ContextTag), cookie) + return EndListCookie{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 CreateNewContextCookie) Check() error { +func (cook EndListCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateNewContext -// createNewContextRequest writes a CreateNewContext request to a byte slice. -func createNewContextRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) []byte { - size := 28 +// Write request to wire for EndList +// endListRequest writes a EndList request to a byte slice. +func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 24 // request opcode + buf[b] = 102 // 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(Context)) - b += 4 - - xgb.Put32(buf[b:], uint32(Fbconfig)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Screen) - b += 4 + return buf +} - xgb.Put32(buf[b:], RenderType) - b += 4 +// FeedbackBufferCookie is a cookie used only for FeedbackBuffer requests. +type FeedbackBufferCookie struct { + *xgb.Cookie +} - xgb.Put32(buf[b:], uint32(ShareList)) - b += 4 +// FeedbackBuffer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FeedbackBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{cookie} +} - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 +// FeedbackBufferChecked sends a checked request. +// If an error occurs, it can be retrieved using FeedbackBufferCookie.Check() +func FeedbackBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } + cookie := c.NewCookie(true, false) + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{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 FeedbackBufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FeedbackBuffer +// feedbackBufferRequest writes a FeedbackBuffer request to a byte slice. +func feedbackBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] b += 1 - b += 3 // padding + buf[b] = 105 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Size)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 return buf } -// QueryContextCookie is a cookie used only for QueryContext requests. -type QueryContextCookie struct { +// FinishCookie is a cookie used only for Finish requests. +type FinishCookie struct { *xgb.Cookie } -// QueryContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryContextCookie.Reply() -func QueryContext(c *xgb.Conn, Context Context) QueryContextCookie { +// Finish sends a checked request. +// If an error occurs, it will be returned with the reply by calling FinishCookie.Reply() +func Finish(c *xgb.Conn, ContextTag ContextTag) FinishCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'Finish' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryContextRequest(c, Context), cookie) - return QueryContextCookie{cookie} + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} } -// QueryContextUnchecked sends an unchecked request. +// FinishUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryContextUnchecked(c *xgb.Conn, Context Context) QueryContextCookie { +func FinishUnchecked(c *xgb.Conn, ContextTag ContextTag) FinishCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'Finish' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryContextRequest(c, Context), cookie) - return QueryContextCookie{cookie} + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} } -// QueryContextReply represents the data returned from a QueryContext request. -type QueryContextReply struct { +// FinishReply represents the data returned from a Finish request. +type FinishReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) } -// Reply blocks and returns the reply data for a QueryContext request. -func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { +// Reply blocks and returns the reply data for a Finish request. +func (cook FinishCookie) Reply() (*FinishReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2753,12 +2346,12 @@ func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { if buf == nil { return nil, nil } - return queryContextReply(buf), nil + return finishReply(buf), nil } -// queryContextReply reads a byte slice into a QueryContextReply value. -func queryContextReply(buf []byte) *QueryContextReply { - v := new(QueryContextReply) +// finishReply reads a byte slice into a FinishReply value. +func finishReply(buf []byte) *FinishReply { + v := new(FinishReply) b := 1 // skip reply determinant b += 1 // padding @@ -2769,24 +2362,67 @@ func queryContextReply(buf []byte) *QueryContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAttribs = xgb.Get32(buf[b:]) + return v +} + +// Write request to wire for Finish +// finishRequest writes a Finish request to a byte slice. +func finishRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 108 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - b += 20 // padding + return buf +} - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = xgb.Get32(buf[b:]) - b += 4 +// FlushCookie is a cookie used only for Flush requests. +type FlushCookie struct { + *xgb.Cookie +} + +// Flush sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Flush(c *xgb.Conn, ContextTag ContextTag) FlushCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'Flush' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(false, false) + c.NewRequest(flushRequest(c, ContextTag), cookie) + return FlushCookie{cookie} +} - return v +// FlushChecked sends a checked request. +// If an error occurs, it can be retrieved using FlushCookie.Check() +func FlushChecked(c *xgb.Conn, ContextTag ContextTag) FlushCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'Flush' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(flushRequest(c, ContextTag), cookie) + return FlushCookie{cookie} } -// Write request to wire for QueryContext -// queryContextRequest writes a QueryContext request to a byte slice. -func queryContextRequest(c *xgb.Conn, Context Context) []byte { +// 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 FlushCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Flush +// flushRequest writes a Flush request to a byte slice. +func flushRequest(c *xgb.Conn, ContextTag ContextTag) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -2794,56 +2430,55 @@ func queryContextRequest(c *xgb.Conn, Context Context) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 25 // request opcode + buf[b] = 142 // 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(Context)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 return buf } -// MakeContextCurrentCookie is a cookie used only for MakeContextCurrent requests. -type MakeContextCurrentCookie struct { +// GenListsCookie is a cookie used only for GenLists requests. +type GenListsCookie struct { *xgb.Cookie } -// MakeContextCurrent sends a checked request. -// If an error occurs, it will be returned with the reply by calling MakeContextCurrentCookie.Reply() -func MakeContextCurrent(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { +// GenLists sends a checked request. +// If an error occurs, it will be returned with the reply by calling GenListsCookie.Reply() +func GenLists(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeContextCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GenLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) - return MakeContextCurrentCookie{cookie} + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{cookie} } -// MakeContextCurrentUnchecked sends an unchecked request. +// GenListsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func MakeContextCurrentUnchecked(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { +func GenListsUnchecked(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeContextCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GenLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) - return MakeContextCurrentCookie{cookie} + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{cookie} } -// MakeContextCurrentReply represents the data returned from a MakeContextCurrent request. -type MakeContextCurrentReply struct { +// GenListsReply represents the data returned from a GenLists request. +type GenListsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ContextTag ContextTag - // padding: 20 bytes + RetVal uint32 } -// Reply blocks and returns the reply data for a MakeContextCurrent request. -func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { +// Reply blocks and returns the reply data for a GenLists request. +func (cook GenListsCookie) Reply() (*GenListsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2851,12 +2486,12 @@ func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { if buf == nil { return nil, nil } - return makeContextCurrentReply(buf), nil + return genListsReply(buf), nil } -// makeContextCurrentReply reads a byte slice into a MakeContextCurrentReply value. -func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { - v := new(MakeContextCurrentReply) +// genListsReply reads a byte slice into a GenListsReply value. +func genListsReply(buf []byte) *GenListsReply { + v := new(GenListsReply) b := 1 // skip reply determinant b += 1 // padding @@ -2867,209 +2502,173 @@ func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextTag = ContextTag(xgb.Get32(buf[b:])) + v.RetVal = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding - return v } -// Write request to wire for MakeContextCurrent -// makeContextCurrentRequest writes a MakeContextCurrent request to a byte slice. -func makeContextCurrentRequest(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) []byte { - size := 20 +// Write request to wire for GenLists +// genListsRequest writes a GenLists request to a byte slice. +func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 104 // 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(OldContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(ReadDrawable)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Context)) + xgb.Put32(buf[b:], uint32(Range)) b += 4 return buf } -// CreatePbufferCookie is a cookie used only for CreatePbuffer requests. -type CreatePbufferCookie struct { +// GenQueriesARBCookie is a cookie used only for GenQueriesARB requests. +type GenQueriesARBCookie struct { *xgb.Cookie } -// CreatePbuffer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreatePbuffer(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { +// GenQueriesARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GenQueriesARBCookie.Reply() +func GenQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreatePbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GenQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) - return CreatePbufferCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} } -// CreatePbufferChecked sends a checked request. -// If an error occurs, it can be retrieved using CreatePbufferCookie.Check() -func CreatePbufferChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { +// GenQueriesARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreatePbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GenQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) - return CreatePbufferCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{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 CreatePbufferCookie) Check() error { - return cook.Cookie.Check() +// GenQueriesARBReply represents the data returned from a GenQueriesARB request. +type GenQueriesARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Write request to wire for CreatePbuffer -// createPbufferRequest writes a CreatePbuffer request to a byte slice. -func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) []byte { - size := xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GenQueriesARB request. +func (cook GenQueriesARBCookie) Reply() (*GenQueriesARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return genQueriesARBReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// genQueriesARBReply reads a byte slice into a GenQueriesARBReply value. +func genQueriesARBReply(buf []byte) *GenQueriesARBReply { + v := new(GenQueriesARBReply) + b := 1 // skip reply determinant - buf[b] = 27 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], Screen) - b += 4 - - xgb.Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - xgb.Put32(buf[b:], uint32(Pbuffer)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], NumAttribs) - b += 4 + b += 24 // padding - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) + v.Data = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Data[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) - return buf -} - -// DestroyPbufferCookie is a cookie used only for DestroyPbuffer requests. -type DestroyPbufferCookie struct { - *xgb.Cookie -} - -// DestroyPbuffer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyPbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) - return DestroyPbufferCookie{cookie} -} - -// DestroyPbufferChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyPbufferCookie.Check() -func DestroyPbufferChecked(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyPbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) - return DestroyPbufferCookie{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 DestroyPbufferCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for DestroyPbuffer -// destroyPbufferRequest writes a DestroyPbuffer request to a byte slice. -func destroyPbufferRequest(c *xgb.Conn, Pbuffer Pbuffer) []byte { - size := 8 +// Write request to wire for GenQueriesARB +// genQueriesARBRequest writes a GenQueriesARB request to a byte slice. +func genQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 28 // request opcode + buf[b] = 162 // 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(Pbuffer)) + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) b += 4 return buf } -// GetDrawableAttributesCookie is a cookie used only for GetDrawableAttributes requests. -type GetDrawableAttributesCookie struct { +// GenTexturesCookie is a cookie used only for GenTextures requests. +type GenTexturesCookie struct { *xgb.Cookie } -// GetDrawableAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDrawableAttributesCookie.Reply() -func GetDrawableAttributes(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { +// GenTextures sends a checked request. +// If an error occurs, it will be returned with the reply by calling GenTexturesCookie.Reply() +func GenTextures(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GenTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) - return GetDrawableAttributesCookie{cookie} + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} } -// GetDrawableAttributesUnchecked sends an unchecked request. +// GenTexturesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDrawableAttributesUnchecked(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { +func GenTexturesUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GenTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) - return GetDrawableAttributesCookie{cookie} + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} } -// GetDrawableAttributesReply represents the data returned from a GetDrawableAttributes request. -type GetDrawableAttributesReply struct { +// GenTexturesReply represents the data returned from a GenTextures request. +type GenTexturesReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a GetDrawableAttributes request. -func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, error) { +// Reply blocks and returns the reply data for a GenTextures request. +func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3077,12 +2676,12 @@ func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, er if buf == nil { return nil, nil } - return getDrawableAttributesReply(buf), nil + return genTexturesReply(buf), nil } -// getDrawableAttributesReply reads a byte slice into a GetDrawableAttributesReply value. -func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { - v := new(GetDrawableAttributesReply) +// genTexturesReply reads a byte slice into a GenTexturesReply value. +func genTexturesReply(buf []byte) *GenTexturesReply { + v := new(GenTexturesReply) b := 1 // skip reply determinant b += 1 // padding @@ -3093,14 +2692,11 @@ func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAttribs = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding + b += 24 // padding - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = xgb.Get32(buf[b:]) + v.Data = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Data[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) @@ -3108,496 +2704,448 @@ func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { return v } -// Write request to wire for GetDrawableAttributes -// getDrawableAttributesRequest writes a GetDrawableAttributes request to a byte slice. -func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { - size := 8 +// Write request to wire for GenTextures +// genTexturesRequest writes a GenTextures request to a byte slice. +func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 29 // request opcode + buf[b] = 145 // 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(Drawable)) + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) b += 4 return buf } -// ChangeDrawableAttributesCookie is a cookie used only for ChangeDrawableAttributes requests. -type ChangeDrawableAttributesCookie struct { +// GetBooleanvCookie is a cookie used only for GetBooleanv requests. +type GetBooleanvCookie struct { *xgb.Cookie } -// ChangeDrawableAttributes sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeDrawableAttributes(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { +// GetBooleanv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetBooleanvCookie.Reply() +func GetBooleanv(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ChangeDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetBooleanv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) - return ChangeDrawableAttributesCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{cookie} } -// ChangeDrawableAttributesChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeDrawableAttributesCookie.Check() -func ChangeDrawableAttributesChecked(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { +// GetBooleanvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetBooleanvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ChangeDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetBooleanv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) - return ChangeDrawableAttributesCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{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 ChangeDrawableAttributesCookie) Check() error { - return cook.Cookie.Check() +// GetBooleanvReply represents the data returned from a GetBooleanv request. +type GetBooleanvReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum bool + // padding: 15 bytes + Data []bool // size: xgb.Pad((int(N) * 1)) } -// Write request to wire for ChangeDrawableAttributes -// changeDrawableAttributesRequest writes a ChangeDrawableAttributes request to a byte slice. -func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetBooleanv request. +func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getBooleanvReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getBooleanvReply reads a byte slice into a GetBooleanvReply value. +func getBooleanvReply(buf []byte) *GetBooleanvReply { + v := new(GetBooleanvReply) + b := 1 // skip reply determinant - buf[b] = 30 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], NumAttribs) + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) b += 4 - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) - b += 4 + if buf[b] == 1 { + v.Datum = true + } else { + v.Datum = false } - b = xgb.Pad(b) - - return buf -} - -// CreateWindowCookie is a cookie used only for CreateWindow requests. -type CreateWindowCookie struct { - *xgb.Cookie -} + b += 1 -// CreateWindow sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateWindow(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return CreateWindowCookie{cookie} -} + b += 15 // padding -// CreateWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateWindowCookie.Check() -func CreateWindowChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + v.Data = make([]bool, v.N) + for i := 0; i < int(v.N); i++ { + if buf[b] == 1 { + v.Data[i] = true + } else { + v.Data[i] = false + } + b += 1 } - cookie := c.NewCookie(true, false) - c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return CreateWindowCookie{cookie} -} + b = xgb.Pad(b) -// 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 CreateWindowCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for CreateWindow -// createWindowRequest writes a CreateWindow request to a byte slice. -func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) []byte { - size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// Write request to wire for GetBooleanv +// getBooleanvRequest writes a GetBooleanv request to a byte slice. +func getBooleanvRequest(c *xgb.Conn, ContextTag ContextTag, Pname int32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 31 // request opcode + buf[b] = 112 // 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:], uint32(Fbconfig)) - b += 4 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(GlxWindow)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], NumAttribs) + xgb.Put32(buf[b:], uint32(Pname)) b += 4 - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// DeleteWindowCookie is a cookie used only for DeleteWindow requests. -type DeleteWindowCookie struct { +// GetClipPlaneCookie is a cookie used only for GetClipPlane requests. +type GetClipPlaneCookie struct { *xgb.Cookie } -// DeleteWindow sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteWindow(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { +// GetClipPlane sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClipPlaneCookie.Reply() +func GetClipPlane(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClipPlane' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) - return DeleteWindowCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{cookie} } -// DeleteWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteWindowCookie.Check() -func DeleteWindowChecked(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { +// GetClipPlaneUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetClipPlaneUnchecked(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteWindow' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClipPlane' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) - return DeleteWindowCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{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 DeleteWindowCookie) Check() error { - return cook.Cookie.Check() +// GetClipPlaneReply represents the data returned from a GetClipPlane request. +type GetClipPlaneReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 24 bytes + Data []Float64 // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Write request to wire for DeleteWindow -// deleteWindowRequest writes a DeleteWindow request to a byte slice. -func deleteWindowRequest(c *xgb.Conn, Glxwindow Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetClipPlane request. +func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClipPlaneReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getClipPlaneReply reads a byte slice into a GetClipPlaneReply value. +func getClipPlaneReply(buf []byte) *GetClipPlaneReply { + v := new(GetClipPlaneReply) + b := 1 // skip reply determinant - buf[b] = 32 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Glxwindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} - -// SetClientInfoARBCookie is a cookie used only for SetClientInfoARB requests. -type SetClientInfoARBCookie struct { - *xgb.Cookie -} - -// SetClientInfoARB sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetClientInfoARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SetClientInfoARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfoARBCookie{cookie} -} + b += 24 // padding -// SetClientInfoARBChecked sends a checked request. -// If an error occurs, it can be retrieved using SetClientInfoARBCookie.Check() -func SetClientInfoARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SetClientInfoARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + v.Data = make([]Float64, (int(v.Length) / 2)) + for i := 0; i < int((int(v.Length) / 2)); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 } - cookie := c.NewCookie(true, false) - c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfoARBCookie{cookie} -} + b = xgb.Pad(b) -// 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 SetClientInfoARBCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for SetClientInfoARB -// setClientInfoARBRequest writes a SetClientInfoARB request to a byte slice. -func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { - size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) +// Write request to wire for GetClipPlane +// getClipPlaneRequest writes a GetClipPlane request to a byte slice. +func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 33 // request opcode + buf[b] = 113 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], MajorVersion) - b += 4 - - xgb.Put32(buf[b:], MinorVersion) - b += 4 - - xgb.Put32(buf[b:], NumVersions) - b += 4 - - xgb.Put32(buf[b:], GlStrLen) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], GlxStrLen) + xgb.Put32(buf[b:], uint32(Plane)) b += 4 - for i := 0; i < int((int(NumVersions) * 2)); i++ { - xgb.Put32(buf[b:], GlVersions[i]) - b += 4 - } - b = xgb.Pad(b) - - copy(buf[b:], GlExtensionString[:GlStrLen]) - b += xgb.Pad(int(GlStrLen)) - - copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += xgb.Pad(int(GlxStrLen)) - return buf } -// CreateContextAttribsARBCookie is a cookie used only for CreateContextAttribsARB requests. -type CreateContextAttribsARBCookie struct { +// GetColorTableCookie is a cookie used only for GetColorTable requests. +type GetColorTableCookie struct { *xgb.Cookie } -// CreateContextAttribsARB sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateContextAttribsARB(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { +// GetColorTable sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetColorTableCookie.Reply() +func GetColorTable(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateContextAttribsARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetColorTable' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return CreateContextAttribsARBCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{cookie} } -// CreateContextAttribsARBChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateContextAttribsARBCookie.Check() -func CreateContextAttribsARBChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { +// GetColorTableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetColorTableUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateContextAttribsARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetColorTable' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return CreateContextAttribsARBCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{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 CreateContextAttribsARBCookie) Check() error { - return cook.Cookie.Check() +// GetColorTableReply represents the data returned from a GetColorTable request. +type GetColorTableReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 8 bytes + Width int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Write request to wire for CreateContextAttribsARB -// createContextAttribsARBRequest writes a CreateContextAttribsARB request to a byte slice. -func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { - size := xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// Reply blocks and returns the reply data for a GetColorTable request. +func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableReply(buf), nil +} + +// getColorTableReply reads a byte slice into a GetColorTableReply value. +func getColorTableReply(buf []byte) *GetColorTableReply { + v := new(GetColorTableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetColorTable +// getColorTableRequest writes a GetColorTable request to a byte slice. +func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 34 // request opcode + buf[b] = 147 // 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(Context)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Fbconfig)) + xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], Screen) + xgb.Put32(buf[b:], Format) b += 4 - xgb.Put32(buf[b:], uint32(ShareList)) + xgb.Put32(buf[b:], Type) b += 4 - if IsDirect { + if SwapBytes { buf[b] = 1 } else { buf[b] = 0 } b += 1 - b += 3 // padding - - xgb.Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// SetClientInfo2ARBCookie is a cookie used only for SetClientInfo2ARB requests. -type SetClientInfo2ARBCookie struct { +// GetColorTableParameterfvCookie is a cookie used only for GetColorTableParameterfv requests. +type GetColorTableParameterfvCookie struct { *xgb.Cookie } -// SetClientInfo2ARB sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetClientInfo2ARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { +// GetColorTableParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetColorTableParameterfvCookie.Reply() +func GetColorTableParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SetClientInfo2ARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetColorTableParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfo2ARBCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{cookie} } -// SetClientInfo2ARBChecked sends a checked request. -// If an error occurs, it can be retrieved using SetClientInfo2ARBCookie.Check() -func SetClientInfo2ARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { +// GetColorTableParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SetClientInfo2ARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetColorTableParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfo2ARBCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{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 SetClientInfo2ARBCookie) Check() error { - return cook.Cookie.Check() +// GetColorTableParameterfvReply represents the data returned from a GetColorTableParameterfv request. +type GetColorTableParameterfvReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Write request to wire for SetClientInfo2ARB -// setClientInfo2ARBRequest writes a SetClientInfo2ARB request to a byte slice. -func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { - size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetColorTableParameterfv request. +func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterfvReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getColorTableParameterfvReply reads a byte slice into a GetColorTableParameterfvReply value. +func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { + v := new(GetColorTableParameterfvReply) + b := 1 // skip reply determinant - buf[b] = 35 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], MajorVersion) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], MinorVersion) - b += 4 + b += 4 // padding - xgb.Put32(buf[b:], NumVersions) + v.N = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], GlStrLen) + v.Datum = Float32(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], GlxStrLen) - b += 4 + b += 12 // padding - for i := 0; i < int((int(NumVersions) * 3)); i++ { - xgb.Put32(buf[b:], GlVersions[i]) + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) - copy(buf[b:], GlExtensionString[:GlStrLen]) - b += xgb.Pad(int(GlStrLen)) - - copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += xgb.Pad(int(GlxStrLen)) - - return buf -} - -// NewListCookie is a cookie used only for NewList requests. -type NewListCookie struct { - *xgb.Cookie -} - -// NewList sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func NewList(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'NewList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) - return NewListCookie{cookie} -} - -// NewListChecked sends a checked request. -// If an error occurs, it can be retrieved using NewListCookie.Check() -func NewListChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'NewList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) - return NewListCookie{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 NewListCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for NewList -// newListRequest writes a NewList request to a byte slice. -func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) []byte { +// Write request to wire for GetColorTableParameterfv +// getColorTableParameterfvRequest writes a GetColorTableParameterfv request to a byte slice. +func getColorTableParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 buf := make([]byte, size) @@ -3605,7 +3153,7 @@ func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32 buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 101 // request opcode + buf[b] = 148 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3614,106 +3162,102 @@ func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32 xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], List) + xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], Mode) + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// EndListCookie is a cookie used only for EndList requests. -type EndListCookie struct { +// GetColorTableParameterivCookie is a cookie used only for GetColorTableParameteriv requests. +type GetColorTableParameterivCookie struct { *xgb.Cookie } -// EndList sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func EndList(c *xgb.Conn, ContextTag ContextTag) EndListCookie { +// GetColorTableParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetColorTableParameterivCookie.Reply() +func GetColorTableParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'EndList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetColorTableParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(endListRequest(c, ContextTag), cookie) - return EndListCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{cookie} } -// EndListChecked sends a checked request. -// If an error occurs, it can be retrieved using EndListCookie.Check() -func EndListChecked(c *xgb.Conn, ContextTag ContextTag) EndListCookie { +// GetColorTableParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'EndList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetColorTableParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(endListRequest(c, ContextTag), cookie) - return EndListCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{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 EndListCookie) Check() error { - return cook.Cookie.Check() +// GetColorTableParameterivReply represents the data returned from a GetColorTableParameteriv request. +type GetColorTableParameterivReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Write request to wire for EndList -// endListRequest writes a EndList request to a byte slice. -func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetColorTableParameteriv request. +func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterivReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getColorTableParameterivReply reads a byte slice into a GetColorTableParameterivReply value. +func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { + v := new(GetColorTableParameterivReply) + b := 1 // skip reply determinant - buf[b] = 102 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} + b += 4 // padding -// DeleteListsCookie is a cookie used only for DeleteLists requests. -type DeleteListsCookie struct { - *xgb.Cookie -} + v.N = xgb.Get32(buf[b:]) + b += 4 -// DeleteLists sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteLists(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) - return DeleteListsCookie{cookie} -} + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 -// DeleteListsChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteListsCookie.Check() -func DeleteListsChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) - return DeleteListsCookie{cookie} -} + b = xgb.Pad(b) -// 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 DeleteListsCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for DeleteLists -// deleteListsRequest writes a DeleteLists request to a byte slice. -func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) []byte { +// Write request to wire for GetColorTableParameteriv +// getColorTableParameterivRequest writes a GetColorTableParameteriv request to a byte slice. +func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 buf := make([]byte, size) @@ -3721,7 +3265,7 @@ func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range i buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 103 // request opcode + buf[b] = 149 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3730,52 +3274,55 @@ func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range i xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], List) + xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], uint32(Range)) + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GenListsCookie is a cookie used only for GenLists requests. -type GenListsCookie struct { +// GetCompressedTexImageARBCookie is a cookie used only for GetCompressedTexImageARB requests. +type GetCompressedTexImageARBCookie struct { *xgb.Cookie } -// GenLists sends a checked request. -// If an error occurs, it will be returned with the reply by calling GenListsCookie.Reply() -func GenLists(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { +// GetCompressedTexImageARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCompressedTexImageARBCookie.Reply() +func GetCompressedTexImageARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) - return GenListsCookie{cookie} + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} } -// GenListsUnchecked sends an unchecked request. +// GetCompressedTexImageARBUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GenListsUnchecked(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { +func GetCompressedTexImageARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) - return GenListsCookie{cookie} + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} } -// GenListsReply represents the data returned from a GenLists request. -type GenListsReply struct { +// GetCompressedTexImageARBReply represents the data returned from a GetCompressedTexImageARB request. +type GetCompressedTexImageARBReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - RetVal uint32 + // padding: 8 bytes + Size int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Reply blocks and returns the reply data for a GenLists request. -func (cook GenListsCookie) Reply() (*GenListsReply, error) { +// Reply blocks and returns the reply data for a GetCompressedTexImageARB request. +func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3783,12 +3330,12 @@ func (cook GenListsCookie) Reply() (*GenListsReply, error) { if buf == nil { return nil, nil } - return genListsReply(buf), nil + return getCompressedTexImageARBReply(buf), nil } -// genListsReply reads a byte slice into a GenListsReply value. -func genListsReply(buf []byte) *GenListsReply { - v := new(GenListsReply) +// getCompressedTexImageARBReply reads a byte slice into a GetCompressedTexImageARBReply value. +func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { + v := new(GetCompressedTexImageARBReply) b := 1 // skip reply determinant b += 1 // padding @@ -3799,23 +3346,31 @@ func genListsReply(buf []byte) *GenListsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.RetVal = xgb.Get32(buf[b:]) + b += 8 // padding + + v.Size = int32(xgb.Get32(buf[b:])) b += 4 + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + return v } -// Write request to wire for GenLists -// genListsRequest writes a GenLists request to a byte slice. -func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { - size := 12 +// Write request to wire for GetCompressedTexImageARB +// getCompressedTexImageARBRequest writes a GetCompressedTexImageARB request to a byte slice. +func getCompressedTexImageARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 104 // request opcode + buf[b] = 160 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3824,117 +3379,107 @@ func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Range)) + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) b += 4 return buf } -// FeedbackBufferCookie is a cookie used only for FeedbackBuffer requests. -type FeedbackBufferCookie struct { +// GetConvolutionFilterCookie is a cookie used only for GetConvolutionFilter requests. +type GetConvolutionFilterCookie struct { *xgb.Cookie } -// FeedbackBuffer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FeedbackBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { +// GetConvolutionFilter sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionFilterCookie.Reply() +func GetConvolutionFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) - return FeedbackBufferCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} } -// FeedbackBufferChecked sends a checked request. -// If an error occurs, it can be retrieved using FeedbackBufferCookie.Check() -func FeedbackBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { +// GetConvolutionFilterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) - return FeedbackBufferCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{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 FeedbackBufferCookie) Check() error { - return cook.Cookie.Check() +// GetConvolutionFilterReply represents the data returned from a GetConvolutionFilter request. +type GetConvolutionFilterReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 8 bytes + Width int32 + Height int32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Write request to wire for FeedbackBuffer -// feedbackBufferRequest writes a FeedbackBuffer request to a byte slice. -func feedbackBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetConvolutionFilter request. +func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionFilterReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getConvolutionFilterReply reads a byte slice into a GetConvolutionFilterReply value. +func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { + v := new(GetConvolutionFilterReply) + b := 1 // skip reply determinant - buf[b] = 105 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Size)) - b += 4 + b += 8 // padding - xgb.Put32(buf[b:], uint32(Type)) + v.Width = int32(xgb.Get32(buf[b:])) b += 4 - return buf -} - -// SelectBufferCookie is a cookie used only for SelectBuffer requests. -type SelectBufferCookie struct { - *xgb.Cookie -} + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 -// SelectBuffer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SelectBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) - return SelectBufferCookie{cookie} -} + b += 8 // padding -// SelectBufferChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectBufferCookie.Check() -func SelectBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SelectBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) - return SelectBufferCookie{cookie} -} + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) -// 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 SelectBufferCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for SelectBuffer -// selectBufferRequest writes a SelectBuffer request to a byte slice. -func selectBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32) []byte { - size := 12 +// Write request to wire for GetConvolutionFilter +// getConvolutionFilterRequest writes a GetConvolutionFilter request to a byte slice. +func getConvolutionFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 106 // request opcode + buf[b] = 150 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3943,53 +3488,66 @@ func selectBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32) []byte xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Size)) + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) b += 4 + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + return buf } -// RenderModeCookie is a cookie used only for RenderMode requests. -type RenderModeCookie struct { +// GetConvolutionParameterfvCookie is a cookie used only for GetConvolutionParameterfv requests. +type GetConvolutionParameterfvCookie struct { *xgb.Cookie } -// RenderMode sends a checked request. -// If an error occurs, it will be returned with the reply by calling RenderModeCookie.Reply() -func RenderMode(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { +// GetConvolutionParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterfvCookie.Reply() +func GetConvolutionParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'RenderMode' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetConvolutionParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) - return RenderModeCookie{cookie} + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{cookie} } -// RenderModeUnchecked sends an unchecked request. +// GetConvolutionParameterfvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { +func GetConvolutionParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'RenderMode' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetConvolutionParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) - return RenderModeCookie{cookie} + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{cookie} } -// RenderModeReply represents the data returned from a RenderMode request. -type RenderModeReply struct { +// GetConvolutionParameterfvReply represents the data returned from a GetConvolutionParameterfv request. +type GetConvolutionParameterfvReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - RetVal uint32 - N uint32 - NewMode uint32 + // padding: 4 bytes + N uint32 + Datum Float32 // padding: 12 bytes - Data []uint32 // size: xgb.Pad((int(N) * 4)) + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a RenderMode request. -func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { +// Reply blocks and returns the reply data for a GetConvolutionParameterfv request. +func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3997,12 +3555,12 @@ func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { if buf == nil { return nil, nil } - return renderModeReply(buf), nil + return getConvolutionParameterfvReply(buf), nil } -// renderModeReply reads a byte slice into a RenderModeReply value. -func renderModeReply(buf []byte) *RenderModeReply { - v := new(RenderModeReply) +// getConvolutionParameterfvReply reads a byte slice into a GetConvolutionParameterfvReply value. +func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply { + v := new(GetConvolutionParameterfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -4013,20 +3571,19 @@ func renderModeReply(buf []byte) *RenderModeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.RetVal = xgb.Get32(buf[b:]) - b += 4 + b += 4 // padding v.N = xgb.Get32(buf[b:]) b += 4 - v.NewMode = xgb.Get32(buf[b:]) + v.Datum = Float32(xgb.Get32(buf[b:])) b += 4 b += 12 // padding - v.Data = make([]uint32, v.N) + v.Data = make([]Float32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = xgb.Get32(buf[b:]) + v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) @@ -4034,17 +3591,17 @@ func renderModeReply(buf []byte) *RenderModeReply { return v } -// Write request to wire for RenderMode -// renderModeRequest writes a RenderMode request to a byte slice. -func renderModeRequest(c *xgb.Conn, ContextTag ContextTag, Mode uint32) []byte { - size := 12 +// Write request to wire for GetConvolutionParameterfv +// getConvolutionParameterfvRequest writes a GetConvolutionParameterfv request to a byte slice. +func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 107 // request opcode + buf[b] = 151 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4053,48 +3610,56 @@ func renderModeRequest(c *xgb.Conn, ContextTag ContextTag, Mode uint32) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Mode) + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// FinishCookie is a cookie used only for Finish requests. -type FinishCookie struct { +// GetConvolutionParameterivCookie is a cookie used only for GetConvolutionParameteriv requests. +type GetConvolutionParameterivCookie struct { *xgb.Cookie } -// Finish sends a checked request. -// If an error occurs, it will be returned with the reply by calling FinishCookie.Reply() -func Finish(c *xgb.Conn, ContextTag ContextTag) FinishCookie { +// GetConvolutionParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterivCookie.Reply() +func GetConvolutionParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Finish' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(finishRequest(c, ContextTag), cookie) - return FinishCookie{cookie} + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} } -// FinishUnchecked sends an unchecked request. +// GetConvolutionParameterivUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FinishUnchecked(c *xgb.Conn, ContextTag ContextTag) FinishCookie { +func GetConvolutionParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Finish' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(finishRequest(c, ContextTag), cookie) - return FinishCookie{cookie} + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} } -// FinishReply represents the data returned from a Finish request. -type FinishReply struct { +// GetConvolutionParameterivReply represents the data returned from a GetConvolutionParameteriv request. +type GetConvolutionParameterivReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a Finish request. -func (cook FinishCookie) Reply() (*FinishReply, error) { +// Reply blocks and returns the reply data for a GetConvolutionParameteriv request. +func (cook GetConvolutionParameterivCookie) Reply() (*GetConvolutionParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4102,12 +3667,12 @@ func (cook FinishCookie) Reply() (*FinishReply, error) { if buf == nil { return nil, nil } - return finishReply(buf), nil + return getConvolutionParameterivReply(buf), nil } -// finishReply reads a byte slice into a FinishReply value. -func finishReply(buf []byte) *FinishReply { - v := new(FinishReply) +// getConvolutionParameterivReply reads a byte slice into a GetConvolutionParameterivReply value. +func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { + v := new(GetConvolutionParameterivReply) b := 1 // skip reply determinant b += 1 // padding @@ -4118,20 +3683,37 @@ func finishReply(buf []byte) *FinishReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + return v } -// Write request to wire for Finish -// finishRequest writes a Finish request to a byte slice. -func finishRequest(c *xgb.Conn, ContextTag ContextTag) []byte { - size := 8 +// Write request to wire for GetConvolutionParameteriv +// getConvolutionParameterivRequest writes a GetConvolutionParameteriv request to a byte slice. +func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 108 // request opcode + buf[b] = 152 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4140,53 +3722,110 @@ func finishRequest(c *xgb.Conn, ContextTag ContextTag) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + return buf } -// PixelStorefCookie is a cookie used only for PixelStoref requests. -type PixelStorefCookie struct { +// GetDoublevCookie is a cookie used only for GetDoublev requests. +type GetDoublevCookie struct { *xgb.Cookie } -// PixelStoref sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PixelStoref(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { +// GetDoublev sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDoublevCookie.Reply() +func GetDoublev(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'PixelStoref' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDoublev' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) - return PixelStorefCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{cookie} } -// PixelStorefChecked sends a checked request. -// If an error occurs, it can be retrieved using PixelStorefCookie.Check() -func PixelStorefChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { +// GetDoublevUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDoublevUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'PixelStoref' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDoublev' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) - return PixelStorefCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{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 PixelStorefCookie) Check() error { - return cook.Cookie.Check() +// GetDoublevReply represents the data returned from a GetDoublev request. +type GetDoublevReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) } -// Write request to wire for PixelStoref -// pixelStorefRequest writes a PixelStoref request to a byte slice. -func pixelStorefRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) []byte { - size := 16 +// Reply blocks and returns the reply data for a GetDoublev request. +func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDoublevReply(buf), nil +} + +// getDoublevReply reads a byte slice into a GetDoublevReply value. +func getDoublevReply(buf []byte) *GetDoublevReply { + v := new(GetDoublevReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float64(xgb.Get64(buf[b:])) + b += 8 + + b += 8 // padding + + v.Data = make([]Float64, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDoublev +// getDoublevRequest writes a GetDoublev request to a byte slice. +func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 109 // request opcode + buf[b] = 114 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4198,111 +3837,145 @@ func pixelStorefRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum xgb.Put32(buf[b:], Pname) b += 4 - xgb.Put32(buf[b:], uint32(Datum)) - b += 4 - return buf } -// PixelStoreiCookie is a cookie used only for PixelStorei requests. -type PixelStoreiCookie struct { +// GetDrawableAttributesCookie is a cookie used only for GetDrawableAttributes requests. +type GetDrawableAttributesCookie struct { *xgb.Cookie } -// PixelStorei sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PixelStorei(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { +// GetDrawableAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDrawableAttributesCookie.Reply() +func GetDrawableAttributes(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'PixelStorei' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) - return PixelStoreiCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) + return GetDrawableAttributesCookie{cookie} } -// PixelStoreiChecked sends a checked request. -// If an error occurs, it can be retrieved using PixelStoreiCookie.Check() -func PixelStoreiChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { +// GetDrawableAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDrawableAttributesUnchecked(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'PixelStorei' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) - return PixelStoreiCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) + return GetDrawableAttributesCookie{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 PixelStoreiCookie) Check() error { - return cook.Cookie.Check() +// GetDrawableAttributesReply represents the data returned from a GetDrawableAttributes request. +type GetDrawableAttributesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumAttribs uint32 + // padding: 20 bytes + Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) } -// Write request to wire for PixelStorei -// pixelStoreiRequest writes a PixelStorei request to a byte slice. -func pixelStoreiRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) []byte { - size := 16 +// Reply blocks and returns the reply data for a GetDrawableAttributes request. +func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDrawableAttributesReply(buf), nil +} + +// getDrawableAttributesReply reads a byte slice into a GetDrawableAttributesReply value. +func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { + v := new(GetDrawableAttributesReply) + 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.NumAttribs = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDrawableAttributes +// getDrawableAttributesRequest writes a GetDrawableAttributes request to a byte slice. +func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 110 // request opcode + buf[b] = 29 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - xgb.Put32(buf[b:], uint32(Datum)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 return buf } -// ReadPixelsCookie is a cookie used only for ReadPixels requests. -type ReadPixelsCookie struct { +// GetErrorCookie is a cookie used only for GetError requests. +type GetErrorCookie struct { *xgb.Cookie } -// ReadPixels sends a checked request. -// If an error occurs, it will be returned with the reply by calling ReadPixelsCookie.Reply() -func ReadPixels(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { +// GetError sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetErrorCookie.Reply() +func GetError(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ReadPixels' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetError' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) - return ReadPixelsCookie{cookie} + c.NewRequest(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{cookie} } -// ReadPixelsUnchecked sends an unchecked request. +// GetErrorUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ReadPixelsUnchecked(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { +func GetErrorUnchecked(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ReadPixels' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetError' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) - return ReadPixelsCookie{cookie} + c.NewRequest(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{cookie} } -// ReadPixelsReply represents the data returned from a ReadPixels request. -type ReadPixelsReply struct { +// GetErrorReply represents the data returned from a GetError request. +type GetErrorReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + Error int32 } -// Reply blocks and returns the reply data for a ReadPixels request. -func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { +// Reply blocks and returns the reply data for a GetError request. +func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4310,12 +3983,12 @@ func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { if buf == nil { return nil, nil } - return readPixelsReply(buf), nil + return getErrorReply(buf), nil } -// readPixelsReply reads a byte slice into a ReadPixelsReply value. -func readPixelsReply(buf []byte) *ReadPixelsReply { - v := new(ReadPixelsReply) +// getErrorReply reads a byte slice into a GetErrorReply value. +func getErrorReply(buf []byte) *GetErrorReply { + v := new(GetErrorReply) b := 1 // skip reply determinant b += 1 // padding @@ -4326,26 +3999,23 @@ func readPixelsReply(buf []byte) *ReadPixelsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 24 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) + v.Error = int32(xgb.Get32(buf[b:])) + b += 4 return v } -// Write request to wire for ReadPixels -// readPixelsRequest writes a ReadPixels request to a byte slice. -func readPixelsRequest(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) []byte { - size := 36 +// Write request to wire for GetError +// getErrorRequest writes a GetError request to a byte slice. +func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 111 // request opcode + buf[b] = 115 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4354,82 +4024,49 @@ func readPixelsRequest(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Wid xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(X)) - b += 4 - - xgb.Put32(buf[b:], uint32(Y)) - b += 4 - - xgb.Put32(buf[b:], uint32(Width)) - b += 4 - - xgb.Put32(buf[b:], uint32(Height)) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if LsbFirst { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - return buf } -// GetBooleanvCookie is a cookie used only for GetBooleanv requests. -type GetBooleanvCookie struct { +// GetFBConfigsCookie is a cookie used only for GetFBConfigs requests. +type GetFBConfigsCookie struct { *xgb.Cookie } -// GetBooleanv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetBooleanvCookie.Reply() -func GetBooleanv(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { +// GetFBConfigs sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFBConfigsCookie.Reply() +func GetFBConfigs(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetBooleanv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetFBConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) - return GetBooleanvCookie{cookie} + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{cookie} } -// GetBooleanvUnchecked sends an unchecked request. +// GetFBConfigsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetBooleanvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { +func GetFBConfigsUnchecked(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetBooleanv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetFBConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) - return GetBooleanvCookie{cookie} + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{cookie} } -// GetBooleanvReply represents the data returned from a GetBooleanv request. -type GetBooleanvReply struct { +// GetFBConfigsReply represents the data returned from a GetFBConfigs request. +type GetFBConfigsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum bool - // padding: 15 bytes - Data []bool // size: xgb.Pad((int(N) * 1)) + NumFbConfigs uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a GetBooleanv request. -func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { +// Reply blocks and returns the reply data for a GetFBConfigs request. +func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4437,12 +4074,12 @@ func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { if buf == nil { return nil, nil } - return getBooleanvReply(buf), nil + return getFBConfigsReply(buf), nil } -// getBooleanvReply reads a byte slice into a GetBooleanvReply value. -func getBooleanvReply(buf []byte) *GetBooleanvReply { - v := new(GetBooleanvReply) +// getFBConfigsReply reads a byte slice into a GetFBConfigsReply value. +func getFBConfigsReply(buf []byte) *GetFBConfigsReply { + v := new(GetFBConfigsReply) b := 1 // skip reply determinant b += 1 // padding @@ -4453,97 +4090,87 @@ func getBooleanvReply(buf []byte) *GetBooleanvReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) + v.NumFbConfigs = xgb.Get32(buf[b:]) b += 4 - if buf[b] == 1 { - v.Datum = true - } else { - v.Datum = false - } - b += 1 + v.NumProperties = xgb.Get32(buf[b:]) + b += 4 - b += 15 // padding + b += 16 // padding - v.Data = make([]bool, v.N) - for i := 0; i < int(v.N); i++ { - if buf[b] == 1 { - v.Data[i] = true - } else { - v.Data[i] = false - } - b += 1 + v.PropertyList = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PropertyList[i] = xgb.Get32(buf[b:]) + b += 4 } b = xgb.Pad(b) return v } -// Write request to wire for GetBooleanv -// getBooleanvRequest writes a GetBooleanv request to a byte slice. -func getBooleanvRequest(c *xgb.Conn, ContextTag ContextTag, Pname int32) []byte { - size := 12 +// Write request to wire for GetFBConfigs +// getFBConfigsRequest writes a GetFBConfigs request to a byte slice. +func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 112 // request opcode + buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(Pname)) + xgb.Put32(buf[b:], Screen) b += 4 return buf } -// GetClipPlaneCookie is a cookie used only for GetClipPlane requests. -type GetClipPlaneCookie struct { +// GetFloatvCookie is a cookie used only for GetFloatv requests. +type GetFloatvCookie struct { *xgb.Cookie } -// GetClipPlane sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetClipPlaneCookie.Reply() -func GetClipPlane(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { +// GetFloatv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFloatvCookie.Reply() +func GetFloatv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetClipPlane' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetFloatv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) - return GetClipPlaneCookie{cookie} + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{cookie} } -// GetClipPlaneUnchecked sends an unchecked request. +// GetFloatvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetClipPlaneUnchecked(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { +func GetFloatvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetClipPlane' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetFloatv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) - return GetClipPlaneCookie{cookie} + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{cookie} } -// GetClipPlaneReply represents the data returned from a GetClipPlane request. -type GetClipPlaneReply struct { +// GetFloatvReply represents the data returned from a GetFloatv request. +type GetFloatvReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 24 bytes - Data []Float64 // size: xgb.Pad(((int(Length) / 2) * 8)) + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetClipPlane request. -func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { +// Reply blocks and returns the reply data for a GetFloatv request. +func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4551,12 +4178,12 @@ func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { if buf == nil { return nil, nil } - return getClipPlaneReply(buf), nil + return getFloatvReply(buf), nil } -// getClipPlaneReply reads a byte slice into a GetClipPlaneReply value. -func getClipPlaneReply(buf []byte) *GetClipPlaneReply { - v := new(GetClipPlaneReply) +// getFloatvReply reads a byte slice into a GetFloatvReply value. +func getFloatvReply(buf []byte) *GetFloatvReply { + v := new(GetFloatvReply) b := 1 // skip reply determinant b += 1 // padding @@ -4567,21 +4194,29 @@ func getClipPlaneReply(buf []byte) *GetClipPlaneReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 24 // padding + b += 4 // padding - v.Data = make([]Float64, (int(v.Length) / 2)) - for i := 0; i < int((int(v.Length) / 2)); i++ { - v.Data[i] = Float64(xgb.Get64(buf[b:])) - b += 8 + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 } b = xgb.Pad(b) return v } -// Write request to wire for GetClipPlane -// getClipPlaneRequest writes a GetClipPlane request to a byte slice. -func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte { +// Write request to wire for GetFloatv +// getFloatvRequest writes a GetFloatv request to a byte slice. +func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -4589,7 +4224,7 @@ func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 113 // request opcode + buf[b] = 116 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4598,53 +4233,52 @@ func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Plane)) + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetDoublevCookie is a cookie used only for GetDoublev requests. -type GetDoublevCookie struct { +// GetHistogramCookie is a cookie used only for GetHistogram requests. +type GetHistogramCookie struct { *xgb.Cookie } -// GetDoublev sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDoublevCookie.Reply() -func GetDoublev(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { +// GetHistogram sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetHistogramCookie.Reply() +func GetHistogram(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetDoublev' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetHistogram' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) - return GetDoublevCookie{cookie} + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} } -// GetDoublevUnchecked sends an unchecked request. +// GetHistogramUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDoublevUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { +func GetHistogramUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetDoublev' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetHistogram' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) - return GetDoublevCookie{cookie} + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} } -// GetDoublevReply represents the data returned from a GetDoublev request. -type GetDoublevReply struct { +// GetHistogramReply represents the data returned from a GetHistogram request. +type GetHistogramReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum Float64 // padding: 8 bytes - Data []Float64 // size: xgb.Pad((int(N) * 8)) + Width int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Reply blocks and returns the reply data for a GetDoublev request. -func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { +// Reply blocks and returns the reply data for a GetHistogram request. +func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4652,12 +4286,12 @@ func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { if buf == nil { return nil, nil } - return getDoublevReply(buf), nil + return getHistogramReply(buf), nil } -// getDoublevReply reads a byte slice into a GetDoublevReply value. -func getDoublevReply(buf []byte) *GetDoublevReply { - v := new(GetDoublevReply) +// getHistogramReply reads a byte slice into a GetHistogramReply value. +func getHistogramReply(buf []byte) *GetHistogramReply { + v := new(GetHistogramReply) b := 1 // skip reply determinant b += 1 // padding @@ -4668,37 +4302,31 @@ func getDoublevReply(buf []byte) *GetDoublevReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding + b += 8 // padding - v.N = xgb.Get32(buf[b:]) + v.Width = int32(xgb.Get32(buf[b:])) b += 4 - v.Datum = Float64(xgb.Get64(buf[b:])) - b += 8 - - b += 8 // padding + b += 12 // padding - v.Data = make([]Float64, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Float64(xgb.Get64(buf[b:])) - b += 8 - } - b = xgb.Pad(b) + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) return v } -// Write request to wire for GetDoublev -// getDoublevRequest writes a GetDoublev request to a byte slice. -func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { - size := 12 +// Write request to wire for GetHistogram +// getHistogramRequest writes a GetHistogram request to a byte slice. +func getHistogramRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { + size := 24 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 114 // request opcode + buf[b] = 154 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4707,49 +4335,73 @@ func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], Target) b += 4 + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + return buf } -// GetErrorCookie is a cookie used only for GetError requests. -type GetErrorCookie struct { +// GetHistogramParameterfvCookie is a cookie used only for GetHistogramParameterfv requests. +type GetHistogramParameterfvCookie struct { *xgb.Cookie } -// GetError sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetErrorCookie.Reply() -func GetError(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { +// GetHistogramParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetHistogramParameterfvCookie.Reply() +func GetHistogramParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetError' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetHistogramParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getErrorRequest(c, ContextTag), cookie) - return GetErrorCookie{cookie} + c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{cookie} } -// GetErrorUnchecked sends an unchecked request. +// GetHistogramParameterfvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetErrorUnchecked(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { +func GetHistogramParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetError' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetHistogramParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getErrorRequest(c, ContextTag), cookie) - return GetErrorCookie{cookie} + c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{cookie} } -// GetErrorReply represents the data returned from a GetError request. -type GetErrorReply struct { +// GetHistogramParameterfvReply represents the data returned from a GetHistogramParameterfv request. +type GetHistogramParameterfvReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Error int32 + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetError request. -func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { +// Reply blocks and returns the reply data for a GetHistogramParameterfv request. +func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4757,12 +4409,12 @@ func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { if buf == nil { return nil, nil } - return getErrorReply(buf), nil + return getHistogramParameterfvReply(buf), nil } -// getErrorReply reads a byte slice into a GetErrorReply value. -func getErrorReply(buf []byte) *GetErrorReply { - v := new(GetErrorReply) +// getHistogramParameterfvReply reads a byte slice into a GetHistogramParameterfvReply value. +func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { + v := new(GetHistogramParameterfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -4773,23 +4425,37 @@ func getErrorReply(buf []byte) *GetErrorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Error = int32(xgb.Get32(buf[b:])) + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) b += 4 + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + return v } -// Write request to wire for GetError -// getErrorRequest writes a GetError request to a byte slice. -func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { - size := 8 +// Write request to wire for GetHistogramParameterfv +// getHistogramParameterfvRequest writes a GetHistogramParameterfv request to a byte slice. +func getHistogramParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 115 // request opcode + buf[b] = 155 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4798,50 +4464,56 @@ func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + return buf } -// GetFloatvCookie is a cookie used only for GetFloatv requests. -type GetFloatvCookie struct { +// GetHistogramParameterivCookie is a cookie used only for GetHistogramParameteriv requests. +type GetHistogramParameterivCookie struct { *xgb.Cookie } -// GetFloatv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetFloatvCookie.Reply() -func GetFloatv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { +// GetHistogramParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetHistogramParameterivCookie.Reply() +func GetHistogramParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetFloatv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetHistogramParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) - return GetFloatvCookie{cookie} + c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} } -// GetFloatvUnchecked sends an unchecked request. +// GetHistogramParameterivUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetFloatvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { +func GetHistogramParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetFloatv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetHistogramParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) - return GetFloatvCookie{cookie} + c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} } -// GetFloatvReply represents the data returned from a GetFloatv request. -type GetFloatvReply struct { +// GetHistogramParameterivReply represents the data returned from a GetHistogramParameteriv request. +type GetHistogramParameterivReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 - Datum Float32 + Datum int32 // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) + Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetFloatv request. -func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { +// Reply blocks and returns the reply data for a GetHistogramParameteriv request. +func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4849,12 +4521,12 @@ func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { if buf == nil { return nil, nil } - return getFloatvReply(buf), nil + return getHistogramParameterivReply(buf), nil } -// getFloatvReply reads a byte slice into a GetFloatvReply value. -func getFloatvReply(buf []byte) *GetFloatvReply { - v := new(GetFloatvReply) +// getHistogramParameterivReply reads a byte slice into a GetHistogramParameterivReply value. +func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { + v := new(GetHistogramParameterivReply) b := 1 // skip reply determinant b += 1 // padding @@ -4870,14 +4542,14 @@ func getFloatvReply(buf []byte) *GetFloatvReply { v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = Float32(xgb.Get32(buf[b:])) + v.Datum = int32(xgb.Get32(buf[b:])) b += 4 b += 12 // padding - v.Data = make([]Float32, v.N) + v.Data = make([]int32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) + v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) @@ -4885,17 +4557,17 @@ func getFloatvReply(buf []byte) *GetFloatvReply { return v } -// Write request to wire for GetFloatv -// getFloatvRequest writes a GetFloatv request to a byte slice. -func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { - size := 12 +// Write request to wire for GetHistogramParameteriv +// getHistogramParameterivRequest writes a GetHistogramParameteriv request to a byte slice. +func getHistogramParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 116 // request opcode + buf[b] = 156 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4904,6 +4576,9 @@ func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 + xgb.Put32(buf[b:], Target) + b += 4 + xgb.Put32(buf[b:], Pname) b += 4 @@ -5803,6 +5478,345 @@ func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname return buf } +// GetMinmaxCookie is a cookie used only for GetMinmax requests. +type GetMinmaxCookie struct { + *xgb.Cookie +} + +// GetMinmax sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxCookie.Reply() +func GetMinmax(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +// GetMinmaxUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMinmaxUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +// GetMinmaxReply represents the data returned from a GetMinmax request. +type GetMinmaxReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a GetMinmax request. +func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxReply(buf), nil +} + +// getMinmaxReply reads a byte slice into a GetMinmaxReply value. +func getMinmaxReply(buf []byte) *GetMinmaxReply { + v := new(GetMinmaxReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetMinmax +// getMinmaxRequest writes a GetMinmax request to a byte slice. +func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 157 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// GetMinmaxParameterfvCookie is a cookie used only for GetMinmaxParameterfv requests. +type GetMinmaxParameterfvCookie struct { + *xgb.Cookie +} + +// GetMinmaxParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterfvCookie.Reply() +func GetMinmaxParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +// GetMinmaxParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +// GetMinmaxParameterfvReply represents the data returned from a GetMinmaxParameterfv request. +type GetMinmaxParameterfvReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetMinmaxParameterfv request. +func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterfvReply(buf), nil +} + +// getMinmaxParameterfvReply reads a byte slice into a GetMinmaxParameterfvReply value. +func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { + v := new(GetMinmaxParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameterfv +// getMinmaxParameterfvRequest writes a GetMinmaxParameterfv request to a byte slice. +func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 158 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetMinmaxParameterivCookie is a cookie used only for GetMinmaxParameteriv requests. +type GetMinmaxParameterivCookie struct { + *xgb.Cookie +} + +// GetMinmaxParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterivCookie.Reply() +func GetMinmaxParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +// GetMinmaxParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +// GetMinmaxParameterivReply represents the data returned from a GetMinmaxParameteriv request. +type GetMinmaxParameterivReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetMinmaxParameteriv request. +func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterivReply(buf), nil +} + +// getMinmaxParameterivReply reads a byte slice into a GetMinmaxParameterivReply value. +func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { + v := new(GetMinmaxParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameteriv +// getMinmaxParameterivRequest writes a GetMinmaxParameteriv request to a byte slice. +func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 159 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + // GetPixelMapfvCookie is a cookie used only for GetPixelMapfv requests. type GetPixelMapfvCookie struct { *xgb.Cookie @@ -6229,6 +6243,461 @@ func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) return buf } +// GetQueryObjectivARBCookie is a cookie used only for GetQueryObjectivARB requests. +type GetQueryObjectivARBCookie struct { + *xgb.Cookie +} + +// GetQueryObjectivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryObjectivARBCookie.Reply() +func GetQueryObjectivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +// GetQueryObjectivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +// GetQueryObjectivARBReply represents the data returned from a GetQueryObjectivARB request. +type GetQueryObjectivARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetQueryObjectivARB request. +func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectivARBReply(buf), nil +} + +// getQueryObjectivARBReply reads a byte slice into a GetQueryObjectivARBReply value. +func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { + v := new(GetQueryObjectivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectivARB +// getQueryObjectivARBRequest writes a GetQueryObjectivARB request to a byte slice. +func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 165 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetQueryObjectuivARBCookie is a cookie used only for GetQueryObjectuivARB requests. +type GetQueryObjectuivARBCookie struct { + *xgb.Cookie +} + +// GetQueryObjectuivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryObjectuivARBCookie.Reply() +func GetQueryObjectuivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +// GetQueryObjectuivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +// GetQueryObjectuivARBReply represents the data returned from a GetQueryObjectuivARB request. +type GetQueryObjectuivARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetQueryObjectuivARB request. +func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectuivARBReply(buf), nil +} + +// getQueryObjectuivARBReply reads a byte slice into a GetQueryObjectuivARBReply value. +func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { + v := new(GetQueryObjectuivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectuivARB +// getQueryObjectuivARBRequest writes a GetQueryObjectuivARB request to a byte slice. +func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 166 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetQueryivARBCookie is a cookie used only for GetQueryivARB requests. +type GetQueryivARBCookie struct { + *xgb.Cookie +} + +// GetQueryivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryivARBCookie.Reply() +func GetQueryivARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +// GetQueryivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +// GetQueryivARBReply represents the data returned from a GetQueryivARB request. +type GetQueryivARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetQueryivARB request. +func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryivARBReply(buf), nil +} + +// getQueryivARBReply reads a byte slice into a GetQueryivARBReply value. +func getQueryivARBReply(buf []byte) *GetQueryivARBReply { + v := new(GetQueryivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryivARB +// getQueryivARBRequest writes a GetQueryivARB request to a byte slice. +func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 164 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetSeparableFilterCookie is a cookie used only for GetSeparableFilter requests. +type GetSeparableFilterCookie struct { + *xgb.Cookie +} + +// GetSeparableFilter sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSeparableFilterCookie.Reply() +func GetSeparableFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +// GetSeparableFilterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSeparableFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +// GetSeparableFilterReply represents the data returned from a GetSeparableFilter request. +type GetSeparableFilterReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 8 bytes + RowW int32 + ColH int32 + // padding: 8 bytes + RowsAndCols []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a GetSeparableFilter request. +func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSeparableFilterReply(buf), nil +} + +// getSeparableFilterReply reads a byte slice into a GetSeparableFilterReply value. +func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { + v := new(GetSeparableFilterReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.RowW = int32(xgb.Get32(buf[b:])) + b += 4 + + v.ColH = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + v.RowsAndCols = make([]byte, (int(v.Length) * 4)) + copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetSeparableFilter +// getSeparableFilterRequest writes a GetSeparableFilter request to a byte slice. +func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 153 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + // GetStringCookie is a cookie used only for GetString requests. type GetStringCookie struct { *xgb.Cookie @@ -7020,35 +7489,35 @@ func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level return buf } -// GetTexParameterfvCookie is a cookie used only for GetTexParameterfv requests. -type GetTexParameterfvCookie struct { +// GetTexLevelParameterfvCookie is a cookie used only for GetTexLevelParameterfv requests. +type GetTexLevelParameterfvCookie struct { *xgb.Cookie } -// GetTexParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetTexParameterfvCookie.Reply() -func GetTexParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { +// GetTexLevelParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexLevelParameterfvCookie.Reply() +func GetTexLevelParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexLevelParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetTexParameterfvCookie{cookie} + c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterfvCookie{cookie} } -// GetTexParameterfvUnchecked sends an unchecked request. +// GetTexLevelParameterfvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetTexParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { +func GetTexLevelParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexLevelParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetTexParameterfvCookie{cookie} + c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterfvCookie{cookie} } -// GetTexParameterfvReply represents the data returned from a GetTexParameterfv request. -type GetTexParameterfvReply struct { +// GetTexLevelParameterfvReply represents the data returned from a GetTexLevelParameterfv request. +type GetTexLevelParameterfvReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -7059,8 +7528,8 @@ type GetTexParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetTexParameterfv request. -func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { +// Reply blocks and returns the reply data for a GetTexLevelParameterfv request. +func (cook GetTexLevelParameterfvCookie) Reply() (*GetTexLevelParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7068,12 +7537,12 @@ func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { if buf == nil { return nil, nil } - return getTexParameterfvReply(buf), nil + return getTexLevelParameterfvReply(buf), nil } -// getTexParameterfvReply reads a byte slice into a GetTexParameterfvReply value. -func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { - v := new(GetTexParameterfvReply) +// getTexLevelParameterfvReply reads a byte slice into a GetTexLevelParameterfvReply value. +func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { + v := new(GetTexLevelParameterfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -7104,17 +7573,17 @@ func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { return v } -// Write request to wire for GetTexParameterfv -// getTexParameterfvRequest writes a GetTexParameterfv request to a byte slice. -func getTexParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for GetTexLevelParameterfv +// getTexLevelParameterfvRequest writes a GetTexLevelParameterfv request to a byte slice. +func getTexLevelParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 136 // request opcode + buf[b] = 138 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7126,41 +7595,44 @@ func getTexParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, xgb.Put32(buf[b:], Target) b += 4 + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetTexParameterivCookie is a cookie used only for GetTexParameteriv requests. -type GetTexParameterivCookie struct { +// GetTexLevelParameterivCookie is a cookie used only for GetTexLevelParameteriv requests. +type GetTexLevelParameterivCookie struct { *xgb.Cookie } -// GetTexParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetTexParameterivCookie.Reply() -func GetTexParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { +// GetTexLevelParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexLevelParameterivCookie.Reply() +func GetTexLevelParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexLevelParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetTexParameterivCookie{cookie} + c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterivCookie{cookie} } -// GetTexParameterivUnchecked sends an unchecked request. +// GetTexLevelParameterivUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetTexParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { +func GetTexLevelParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexLevelParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetTexParameterivCookie{cookie} + c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterivCookie{cookie} } -// GetTexParameterivReply represents the data returned from a GetTexParameteriv request. -type GetTexParameterivReply struct { +// GetTexLevelParameterivReply represents the data returned from a GetTexLevelParameteriv request. +type GetTexLevelParameterivReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -7171,8 +7643,8 @@ type GetTexParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetTexParameteriv request. -func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { +// Reply blocks and returns the reply data for a GetTexLevelParameteriv request. +func (cook GetTexLevelParameterivCookie) Reply() (*GetTexLevelParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7180,12 +7652,12 @@ func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { if buf == nil { return nil, nil } - return getTexParameterivReply(buf), nil + return getTexLevelParameterivReply(buf), nil } -// getTexParameterivReply reads a byte slice into a GetTexParameterivReply value. -func getTexParameterivReply(buf []byte) *GetTexParameterivReply { - v := new(GetTexParameterivReply) +// getTexLevelParameterivReply reads a byte slice into a GetTexLevelParameterivReply value. +func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { + v := new(GetTexLevelParameterivReply) b := 1 // skip reply determinant b += 1 // padding @@ -7216,17 +7688,17 @@ func getTexParameterivReply(buf []byte) *GetTexParameterivReply { return v } -// Write request to wire for GetTexParameteriv -// getTexParameterivRequest writes a GetTexParameteriv request to a byte slice. -func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for GetTexLevelParameteriv +// getTexLevelParameterivRequest writes a GetTexLevelParameteriv request to a byte slice. +func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 137 // request opcode + buf[b] = 139 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7238,41 +7710,44 @@ func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, xgb.Put32(buf[b:], Target) b += 4 + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetTexLevelParameterfvCookie is a cookie used only for GetTexLevelParameterfv requests. -type GetTexLevelParameterfvCookie struct { +// GetTexParameterfvCookie is a cookie used only for GetTexParameterfv requests. +type GetTexParameterfvCookie struct { *xgb.Cookie } -// GetTexLevelParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetTexLevelParameterfvCookie.Reply() -func GetTexLevelParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { +// GetTexParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexParameterfvCookie.Reply() +func GetTexParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexLevelParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) - return GetTexLevelParameterfvCookie{cookie} + c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} } -// GetTexLevelParameterfvUnchecked sends an unchecked request. +// GetTexParameterfvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetTexLevelParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { +func GetTexParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexLevelParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) - return GetTexLevelParameterfvCookie{cookie} + c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} } -// GetTexLevelParameterfvReply represents the data returned from a GetTexLevelParameterfv request. -type GetTexLevelParameterfvReply struct { +// GetTexParameterfvReply represents the data returned from a GetTexParameterfv request. +type GetTexParameterfvReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -7283,8 +7758,8 @@ type GetTexLevelParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetTexLevelParameterfv request. -func (cook GetTexLevelParameterfvCookie) Reply() (*GetTexLevelParameterfvReply, error) { +// Reply blocks and returns the reply data for a GetTexParameterfv request. +func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7292,12 +7767,12 @@ func (cook GetTexLevelParameterfvCookie) Reply() (*GetTexLevelParameterfvReply, if buf == nil { return nil, nil } - return getTexLevelParameterfvReply(buf), nil + return getTexParameterfvReply(buf), nil } -// getTexLevelParameterfvReply reads a byte slice into a GetTexLevelParameterfvReply value. -func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { - v := new(GetTexLevelParameterfvReply) +// getTexParameterfvReply reads a byte slice into a GetTexParameterfvReply value. +func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { + v := new(GetTexParameterfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -7328,17 +7803,17 @@ func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { return v } -// Write request to wire for GetTexLevelParameterfv -// getTexLevelParameterfvRequest writes a GetTexLevelParameterfv request to a byte slice. -func getTexLevelParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { - size := 20 +// Write request to wire for GetTexParameterfv +// getTexParameterfvRequest writes a GetTexParameterfv request to a byte slice. +func getTexParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 138 // request opcode + buf[b] = 136 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7350,44 +7825,41 @@ func getTexLevelParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target ui xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], uint32(Level)) - b += 4 - xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetTexLevelParameterivCookie is a cookie used only for GetTexLevelParameteriv requests. -type GetTexLevelParameterivCookie struct { +// GetTexParameterivCookie is a cookie used only for GetTexParameteriv requests. +type GetTexParameterivCookie struct { *xgb.Cookie } -// GetTexLevelParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetTexLevelParameterivCookie.Reply() -func GetTexLevelParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { +// GetTexParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexParameterivCookie.Reply() +func GetTexParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexLevelParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) - return GetTexLevelParameterivCookie{cookie} + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{cookie} } -// GetTexLevelParameterivUnchecked sends an unchecked request. +// GetTexParameterivUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetTexLevelParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { +func GetTexParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexLevelParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTexParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) - return GetTexLevelParameterivCookie{cookie} + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{cookie} } -// GetTexLevelParameterivReply represents the data returned from a GetTexLevelParameteriv request. -type GetTexLevelParameterivReply struct { +// GetTexParameterivReply represents the data returned from a GetTexParameteriv request. +type GetTexParameterivReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -7398,8 +7870,8 @@ type GetTexLevelParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetTexLevelParameteriv request. -func (cook GetTexLevelParameterivCookie) Reply() (*GetTexLevelParameterivReply, error) { +// Reply blocks and returns the reply data for a GetTexParameteriv request. +func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7407,12 +7879,12 @@ func (cook GetTexLevelParameterivCookie) Reply() (*GetTexLevelParameterivReply, if buf == nil { return nil, nil } - return getTexLevelParameterivReply(buf), nil + return getTexParameterivReply(buf), nil } -// getTexLevelParameterivReply reads a byte slice into a GetTexLevelParameterivReply value. -func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { - v := new(GetTexLevelParameterivReply) +// getTexParameterivReply reads a byte slice into a GetTexParameterivReply value. +func getTexParameterivReply(buf []byte) *GetTexParameterivReply { + v := new(GetTexParameterivReply) b := 1 // skip reply determinant b += 1 // padding @@ -7443,17 +7915,17 @@ func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { return v } -// Write request to wire for GetTexLevelParameteriv -// getTexLevelParameterivRequest writes a GetTexLevelParameteriv request to a byte slice. -func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { - size := 20 +// Write request to wire for GetTexParameteriv +// getTexParameterivRequest writes a GetTexParameteriv request to a byte slice. +func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 139 // request opcode + buf[b] = 137 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7465,52 +7937,52 @@ func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target ui xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], uint32(Level)) - b += 4 - xgb.Put32(buf[b:], Pname) b += 4 return buf } -// IsListCookie is a cookie used only for IsList requests. -type IsListCookie struct { +// GetVisualConfigsCookie is a cookie used only for GetVisualConfigs requests. +type GetVisualConfigsCookie struct { *xgb.Cookie } -// IsList sends a checked request. -// If an error occurs, it will be returned with the reply by calling IsListCookie.Reply() -func IsList(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { +// GetVisualConfigs sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVisualConfigsCookie.Reply() +func GetVisualConfigs(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVisualConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(isListRequest(c, ContextTag, List), cookie) - return IsListCookie{cookie} + c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} } -// IsListUnchecked sends an unchecked request. +// GetVisualConfigsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IsListUnchecked(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { +func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVisualConfigs' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(isListRequest(c, ContextTag, List), cookie) - return IsListCookie{cookie} + c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} } -// IsListReply represents the data returned from a IsList request. -type IsListReply struct { +// GetVisualConfigsReply represents the data returned from a GetVisualConfigs request. +type GetVisualConfigsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - RetVal Bool32 + NumVisuals uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a IsList request. -func (cook IsListCookie) Reply() (*IsListReply, error) { +// Reply blocks and returns the reply data for a GetVisualConfigs request. +func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7518,12 +7990,12 @@ func (cook IsListCookie) Reply() (*IsListReply, error) { if buf == nil { return nil, nil } - return isListReply(buf), nil + return getVisualConfigsReply(buf), nil } -// isListReply reads a byte slice into a IsListReply value. -func isListReply(buf []byte) *IsListReply { - v := new(IsListReply) +// getVisualConfigsReply reads a byte slice into a GetVisualConfigsReply value. +func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { + v := new(GetVisualConfigsReply) b := 1 // skip reply determinant b += 1 // padding @@ -7534,73 +8006,27 @@ func isListReply(buf []byte) *IsListReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.RetVal = Bool32(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for IsList -// isListRequest writes a IsList request to a byte slice. -func isListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 141 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) + v.NumVisuals = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], List) + v.NumProperties = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// FlushCookie is a cookie used only for Flush requests. -type FlushCookie struct { - *xgb.Cookie -} - -// Flush sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Flush(c *xgb.Conn, ContextTag ContextTag) FlushCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Flush' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(flushRequest(c, ContextTag), cookie) - return FlushCookie{cookie} -} + b += 16 // padding -// FlushChecked sends a checked request. -// If an error occurs, it can be retrieved using FlushCookie.Check() -func FlushChecked(c *xgb.Conn, ContextTag ContextTag) FlushCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Flush' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + v.PropertyList = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PropertyList[i] = xgb.Get32(buf[b:]) + b += 4 } - cookie := c.NewCookie(true, false) - c.NewRequest(flushRequest(c, ContextTag), cookie) - return FlushCookie{cookie} -} + b = xgb.Pad(b) -// 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 FlushCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for Flush -// flushRequest writes a Flush request to a byte slice. -func flushRequest(c *xgb.Conn, ContextTag ContextTag) []byte { +// Write request to wire for GetVisualConfigs +// getVisualConfigsRequest writes a GetVisualConfigs request to a byte slice. +func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -7608,57 +8034,56 @@ func flushRequest(c *xgb.Conn, ContextTag ContextTag) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 142 // request opcode + buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], Screen) b += 4 return buf } -// AreTexturesResidentCookie is a cookie used only for AreTexturesResident requests. -type AreTexturesResidentCookie struct { +// IsDirectCookie is a cookie used only for IsDirect requests. +type IsDirectCookie struct { *xgb.Cookie } -// AreTexturesResident sends a checked request. -// If an error occurs, it will be returned with the reply by calling AreTexturesResidentCookie.Reply() -func AreTexturesResident(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { +// IsDirect sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsDirectCookie.Reply() +func IsDirect(c *xgb.Conn, Context Context) IsDirectCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'AreTexturesResident' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsDirect' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) - return AreTexturesResidentCookie{cookie} + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} } -// AreTexturesResidentUnchecked sends an unchecked request. +// IsDirectUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AreTexturesResidentUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { +func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'AreTexturesResident' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsDirect' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) - return AreTexturesResidentCookie{cookie} + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} } -// AreTexturesResidentReply represents the data returned from a AreTexturesResident request. -type AreTexturesResidentReply struct { +// IsDirectReply represents the data returned from a IsDirect request. +type IsDirectReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - RetVal Bool32 - // padding: 20 bytes - Data []bool // size: xgb.Pad(((int(Length) * 4) * 1)) + IsDirect bool + // padding: 23 bytes } -// Reply blocks and returns the reply data for a AreTexturesResident request. -func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) { +// Reply blocks and returns the reply data for a IsDirect request. +func (cook IsDirectCookie) Reply() (*IsDirectReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7666,12 +8091,12 @@ func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) if buf == nil { return nil, nil } - return areTexturesResidentReply(buf), nil + return isDirectReply(buf), nil } -// areTexturesResidentReply reads a byte slice into a AreTexturesResidentReply value. -func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { - v := new(AreTexturesResidentReply) +// isDirectReply reads a byte slice into a IsDirectReply value. +func isDirectReply(buf []byte) *IsDirectReply { + v := new(IsDirectReply) b := 1 // skip reply determinant b += 1 // padding @@ -7682,158 +8107,77 @@ func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.RetVal = Bool32(xgb.Get32(buf[b:])) - b += 4 - - b += 20 // padding - - v.Data = make([]bool, (int(v.Length) * 4)) - for i := 0; i < int((int(v.Length) * 4)); i++ { - if buf[b] == 1 { - v.Data[i] = true - } else { - v.Data[i] = false - } - b += 1 + if buf[b] == 1 { + v.IsDirect = true + } else { + v.IsDirect = false } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for AreTexturesResident -// areTexturesResidentRequest writes a AreTexturesResident request to a byte slice. -func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 143 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Textures[i]) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// DeleteTexturesCookie is a cookie used only for DeleteTextures requests. -type DeleteTexturesCookie struct { - *xgb.Cookie -} - -// DeleteTextures sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteTextures(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) - return DeleteTexturesCookie{cookie} -} - -// DeleteTexturesChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteTexturesCookie.Check() -func DeleteTexturesChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) - return DeleteTexturesCookie{cookie} -} + b += 23 // padding -// 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 DeleteTexturesCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for DeleteTextures -// deleteTexturesRequest writes a DeleteTextures request to a byte slice. -func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +// Write request to wire for IsDirect +// isDirectRequest writes a IsDirect request to a byte slice. +func isDirectRequest(c *xgb.Conn, Context Context) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 144 // request opcode + 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:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], uint32(Context)) b += 4 - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Textures[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// GenTexturesCookie is a cookie used only for GenTextures requests. -type GenTexturesCookie struct { +// IsListCookie is a cookie used only for IsList requests. +type IsListCookie struct { *xgb.Cookie } -// GenTextures sends a checked request. -// If an error occurs, it will be returned with the reply by calling GenTexturesCookie.Reply() -func GenTextures(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { +// IsList sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsListCookie.Reply() +func IsList(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) - return GenTexturesCookie{cookie} + c.NewRequest(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} } -// GenTexturesUnchecked sends an unchecked request. +// IsListUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GenTexturesUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { +func IsListUnchecked(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) - return GenTexturesCookie{cookie} + c.NewRequest(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} } -// GenTexturesReply represents the data returned from a GenTextures request. -type GenTexturesReply struct { +// IsListReply represents the data returned from a IsList request. +type IsListReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 24 bytes - Data []uint32 // size: xgb.Pad((int(Length) * 4)) + RetVal Bool32 } -// Reply blocks and returns the reply data for a GenTextures request. -func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { +// Reply blocks and returns the reply data for a IsList request. +func (cook IsListCookie) Reply() (*IsListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7841,12 +8185,12 @@ func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { if buf == nil { return nil, nil } - return genTexturesReply(buf), nil + return isListReply(buf), nil } -// genTexturesReply reads a byte slice into a GenTexturesReply value. -func genTexturesReply(buf []byte) *GenTexturesReply { - v := new(GenTexturesReply) +// isListReply reads a byte slice into a IsListReply value. +func isListReply(buf []byte) *IsListReply { + v := new(IsListReply) b := 1 // skip reply determinant b += 1 // padding @@ -7857,21 +8201,15 @@ func genTexturesReply(buf []byte) *GenTexturesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 24 // padding - - v.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 return v } -// Write request to wire for GenTextures -// genTexturesRequest writes a GenTextures request to a byte slice. -func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { +// Write request to wire for IsList +// isListRequest writes a IsList request to a byte slice. +func isListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -7879,7 +8217,7 @@ func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 145 // request opcode + buf[b] = 141 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7888,49 +8226,49 @@ func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], List) b += 4 return buf } -// IsTextureCookie is a cookie used only for IsTexture requests. -type IsTextureCookie struct { +// IsQueryARBCookie is a cookie used only for IsQueryARB requests. +type IsQueryARBCookie struct { *xgb.Cookie } -// IsTexture sends a checked request. -// If an error occurs, it will be returned with the reply by calling IsTextureCookie.Reply() -func IsTexture(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { +// IsQueryARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsQueryARBCookie.Reply() +func IsQueryARB(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsTexture' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsQueryARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) - return IsTextureCookie{cookie} + c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} } -// IsTextureUnchecked sends an unchecked request. +// IsQueryARBUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { +func IsQueryARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsTexture' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsQueryARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) - return IsTextureCookie{cookie} + c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} } -// IsTextureReply represents the data returned from a IsTexture request. -type IsTextureReply struct { +// IsQueryARBReply represents the data returned from a IsQueryARB request. +type IsQueryARBReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes RetVal Bool32 } -// Reply blocks and returns the reply data for a IsTexture request. -func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { +// Reply blocks and returns the reply data for a IsQueryARB request. +func (cook IsQueryARBCookie) Reply() (*IsQueryARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7938,12 +8276,12 @@ func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { if buf == nil { return nil, nil } - return isTextureReply(buf), nil + return isQueryARBReply(buf), nil } -// isTextureReply reads a byte slice into a IsTextureReply value. -func isTextureReply(buf []byte) *IsTextureReply { - v := new(IsTextureReply) +// isQueryARBReply reads a byte slice into a IsQueryARBReply value. +func isQueryARBReply(buf []byte) *IsQueryARBReply { + v := new(IsQueryARBReply) b := 1 // skip reply determinant b += 1 // padding @@ -7960,9 +8298,9 @@ func isTextureReply(buf []byte) *IsTextureReply { return v } -// Write request to wire for IsTexture -// isTextureRequest writes a IsTexture request to a byte slice. -func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte { +// Write request to wire for IsQueryARB +// isQueryARBRequest writes a IsQueryARB request to a byte slice. +func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -7970,7 +8308,7 @@ func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 146 // request opcode + buf[b] = 163 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7979,52 +8317,49 @@ func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Texture) + xgb.Put32(buf[b:], Id) b += 4 return buf } -// GetColorTableCookie is a cookie used only for GetColorTable requests. -type GetColorTableCookie struct { +// IsTextureCookie is a cookie used only for IsTexture requests. +type IsTextureCookie struct { *xgb.Cookie } -// GetColorTable sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetColorTableCookie.Reply() -func GetColorTable(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { +// IsTexture sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsTextureCookie.Reply() +func IsTexture(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTable' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsTexture' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetColorTableCookie{cookie} + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} } -// GetColorTableUnchecked sends an unchecked request. +// IsTextureUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetColorTableUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { +func IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTable' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'IsTexture' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetColorTableCookie{cookie} + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} } -// GetColorTableReply represents the data returned from a GetColorTable request. -type GetColorTableReply struct { +// IsTextureReply represents the data returned from a IsTexture request. +type IsTextureReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 8 bytes - Width int32 - // padding: 12 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + RetVal Bool32 } -// Reply blocks and returns the reply data for a GetColorTable request. -func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { +// Reply blocks and returns the reply data for a IsTexture request. +func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8032,12 +8367,12 @@ func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { if buf == nil { return nil, nil } - return getColorTableReply(buf), nil + return isTextureReply(buf), nil } -// getColorTableReply reads a byte slice into a GetColorTableReply value. -func getColorTableReply(buf []byte) *GetColorTableReply { - v := new(GetColorTableReply) +// isTextureReply reads a byte slice into a IsTextureReply value. +func isTextureReply(buf []byte) *IsTextureReply { + v := new(IsTextureReply) b := 1 // skip reply determinant b += 1 // padding @@ -8048,31 +8383,23 @@ func getColorTableReply(buf []byte) *GetColorTableReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 8 // padding - - v.Width = int32(xgb.Get32(buf[b:])) + v.RetVal = Bool32(xgb.Get32(buf[b:])) b += 4 - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - return v } -// Write request to wire for GetColorTable -// getColorTableRequest writes a GetColorTable request to a byte slice. -func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 +// Write request to wire for IsTexture +// isTextureRequest writes a IsTexture request to a byte slice. +func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 147 // request opcode + buf[b] = 146 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8081,66 +8408,50 @@ func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, For xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) + xgb.Put32(buf[b:], Texture) b += 4 - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - return buf } -// GetColorTableParameterfvCookie is a cookie used only for GetColorTableParameterfv requests. -type GetColorTableParameterfvCookie struct { +// MakeContextCurrentCookie is a cookie used only for MakeContextCurrent requests. +type MakeContextCurrentCookie struct { *xgb.Cookie } -// GetColorTableParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetColorTableParameterfvCookie.Reply() -func GetColorTableParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { +// MakeContextCurrent sends a checked request. +// If an error occurs, it will be returned with the reply by calling MakeContextCurrentCookie.Reply() +func MakeContextCurrent(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'MakeContextCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetColorTableParameterfvCookie{cookie} + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} } -// GetColorTableParameterfvUnchecked sends an unchecked request. +// MakeContextCurrentUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { +func MakeContextCurrentUnchecked(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'MakeContextCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetColorTableParameterfvCookie{cookie} + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} } -// GetColorTableParameterfvReply represents the data returned from a GetColorTableParameterfv request. -type GetColorTableParameterfvReply struct { +// MakeContextCurrentReply represents the data returned from a MakeContextCurrent request. +type MakeContextCurrentReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) + ContextTag ContextTag + // padding: 20 bytes } -// Reply blocks and returns the reply data for a GetColorTableParameterfv request. -func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvReply, error) { +// Reply blocks and returns the reply data for a MakeContextCurrent request. +func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8148,12 +8459,12 @@ func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvRep if buf == nil { return nil, nil } - return getColorTableParameterfvReply(buf), nil + return makeContextCurrentReply(buf), nil } -// getColorTableParameterfvReply reads a byte slice into a GetColorTableParameterfvReply value. -func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { - v := new(GetColorTableParameterfvReply) +// makeContextCurrentReply reads a byte slice into a MakeContextCurrentReply value. +func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { + v := new(MakeContextCurrentReply) b := 1 // skip reply determinant b += 1 // padding @@ -8164,95 +8475,83 @@ func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = Float32(xgb.Get32(buf[b:])) + v.ContextTag = ContextTag(xgb.Get32(buf[b:])) b += 4 - b += 12 // padding - - v.Data = make([]Float32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + b += 20 // padding return v } -// Write request to wire for GetColorTableParameterfv -// getColorTableParameterfvRequest writes a GetColorTableParameterfv request to a byte slice. -func getColorTableParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for MakeContextCurrent +// makeContextCurrentRequest writes a MakeContextCurrent request to a byte slice. +func makeContextCurrentRequest(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 148 // request opcode + buf[b] = 26 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], uint32(OldContextTag)) b += 4 - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], uint32(ReadDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) b += 4 return buf } -// GetColorTableParameterivCookie is a cookie used only for GetColorTableParameteriv requests. -type GetColorTableParameterivCookie struct { +// MakeCurrentCookie is a cookie used only for MakeCurrent requests. +type MakeCurrentCookie struct { *xgb.Cookie } -// GetColorTableParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetColorTableParameterivCookie.Reply() -func GetColorTableParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { +// MakeCurrent sends a checked request. +// If an error occurs, it will be returned with the reply by calling MakeCurrentCookie.Reply() +func MakeCurrent(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'MakeCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetColorTableParameterivCookie{cookie} + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} } -// GetColorTableParameterivUnchecked sends an unchecked request. +// MakeCurrentUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { +func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'MakeCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetColorTableParameterivCookie{cookie} + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} } -// GetColorTableParameterivReply represents the data returned from a GetColorTableParameteriv request. -type GetColorTableParameterivReply struct { +// MakeCurrentReply represents the data returned from a MakeCurrent request. +type MakeCurrentReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + ContextTag ContextTag + // padding: 20 bytes } -// Reply blocks and returns the reply data for a GetColorTableParameteriv request. -func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivReply, error) { +// Reply blocks and returns the reply data for a MakeCurrent request. +func (cook MakeCurrentCookie) Reply() (*MakeCurrentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8260,12 +8559,12 @@ func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivRep if buf == nil { return nil, nil } - return getColorTableParameterivReply(buf), nil + return makeCurrentReply(buf), nil } -// getColorTableParameterivReply reads a byte slice into a GetColorTableParameterivReply value. -func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { - v := new(GetColorTableParameterivReply) +// makeCurrentReply reads a byte slice into a MakeCurrentReply value. +func makeCurrentReply(buf []byte) *MakeCurrentReply { + v := new(MakeCurrentReply) b := 1 // skip reply determinant b += 1 // padding @@ -8276,29 +8575,17 @@ func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = int32(xgb.Get32(buf[b:])) + v.ContextTag = ContextTag(xgb.Get32(buf[b:])) b += 4 - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + b += 20 // padding return v } -// Write request to wire for GetColorTableParameteriv -// getColorTableParameterivRequest writes a GetColorTableParameteriv request to a byte slice. -func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { +// Write request to wire for MakeCurrent +// makeCurrentRequest writes a MakeCurrent request to a byte slice. +func makeCurrentRequest(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) []byte { size := 16 b := 0 buf := make([]byte, size) @@ -8306,116 +8593,68 @@ func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 149 // request opcode + 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:], uint32(ContextTag)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], uint32(OldContextTag)) b += 4 return buf } -// GetConvolutionFilterCookie is a cookie used only for GetConvolutionFilter requests. -type GetConvolutionFilterCookie struct { +// NewListCookie is a cookie used only for NewList requests. +type NewListCookie struct { *xgb.Cookie } -// GetConvolutionFilter sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetConvolutionFilterCookie.Reply() -func GetConvolutionFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetConvolutionFilterCookie{cookie} -} - -// GetConvolutionFilterUnchecked sends an unchecked request. +// NewList sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { +func NewList(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'NewList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetConvolutionFilterCookie{cookie} -} - -// GetConvolutionFilterReply represents the data returned from a GetConvolutionFilter request. -type GetConvolutionFilterReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 8 bytes - Width int32 - Height int32 - // padding: 8 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + cookie := c.NewCookie(false, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} } -// Reply blocks and returns the reply data for a GetConvolutionFilter request. -func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// NewListChecked sends a checked request. +// If an error occurs, it can be retrieved using NewListCookie.Check() +func NewListChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'NewList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return getConvolutionFilterReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} } -// getConvolutionFilterReply reads a byte slice into a GetConvolutionFilterReply value. -func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { - v := new(GetConvolutionFilterReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Height = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 8 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 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 NewListCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetConvolutionFilter -// getConvolutionFilterRequest writes a GetConvolutionFilter request to a byte slice. -func getConvolutionFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 +// Write request to wire for NewList +// newListRequest writes a NewList request to a byte slice. +func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 150 // request opcode + buf[b] = 101 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8424,112 +8663,51 @@ func getConvolutionFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Format) + xgb.Put32(buf[b:], List) b += 4 - xgb.Put32(buf[b:], Type) + xgb.Put32(buf[b:], Mode) b += 4 - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - return buf } -// GetConvolutionParameterfvCookie is a cookie used only for GetConvolutionParameterfv requests. -type GetConvolutionParameterfvCookie struct { +// PixelStorefCookie is a cookie used only for PixelStoref requests. +type PixelStorefCookie struct { *xgb.Cookie } -// GetConvolutionParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterfvCookie.Reply() -func GetConvolutionParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterfvCookie{cookie} -} - -// GetConvolutionParameterfvUnchecked sends an unchecked request. +// PixelStoref sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetConvolutionParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { +func PixelStoref(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'PixelStoref' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterfvCookie{cookie} -} - -// GetConvolutionParameterfvReply represents the data returned from a GetConvolutionParameterfv request. -type GetConvolutionParameterfvReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{cookie} } -// Reply blocks and returns the reply data for a GetConvolutionParameterfv request. -func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// PixelStorefChecked sends a checked request. +// If an error occurs, it can be retrieved using PixelStorefCookie.Check() +func PixelStorefChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'PixelStoref' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return getConvolutionParameterfvReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{cookie} } -// getConvolutionParameterfvReply reads a byte slice into a GetConvolutionParameterfvReply value. -func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply { - v := new(GetConvolutionParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = Float32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]Float32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - 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 PixelStorefCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetConvolutionParameterfv -// getConvolutionParameterfvRequest writes a GetConvolutionParameterfv request to a byte slice. -func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { +// Write request to wire for PixelStoref +// pixelStorefRequest writes a PixelStoref request to a byte slice. +func pixelStorefRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) []byte { size := 16 b := 0 buf := make([]byte, size) @@ -8537,7 +8715,7 @@ func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 151 // request opcode + buf[b] = 109 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8546,102 +8724,51 @@ func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], Pname) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], uint32(Datum)) b += 4 return buf } -// GetConvolutionParameterivCookie is a cookie used only for GetConvolutionParameteriv requests. -type GetConvolutionParameterivCookie struct { +// PixelStoreiCookie is a cookie used only for PixelStorei requests. +type PixelStoreiCookie struct { *xgb.Cookie } -// GetConvolutionParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterivCookie.Reply() -func GetConvolutionParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterivCookie{cookie} -} - -// GetConvolutionParameterivUnchecked sends an unchecked request. +// PixelStorei sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetConvolutionParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { +func PixelStorei(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'PixelStorei' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterivCookie{cookie} -} - -// GetConvolutionParameterivReply represents the data returned from a GetConvolutionParameteriv request. -type GetConvolutionParameterivReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} } -// Reply blocks and returns the reply data for a GetConvolutionParameteriv request. -func (cook GetConvolutionParameterivCookie) Reply() (*GetConvolutionParameterivReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// PixelStoreiChecked sends a checked request. +// If an error occurs, it can be retrieved using PixelStoreiCookie.Check() +func PixelStoreiChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'PixelStorei' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return getConvolutionParameterivReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} } -// getConvolutionParameterivReply reads a byte slice into a GetConvolutionParameterivReply value. -func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { - v := new(GetConvolutionParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - 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 PixelStoreiCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetConvolutionParameteriv -// getConvolutionParameterivRequest writes a GetConvolutionParameteriv request to a byte slice. -func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { +// Write request to wire for PixelStorei +// pixelStoreiRequest writes a PixelStorei request to a byte slice. +func pixelStoreiRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) []byte { size := 16 b := 0 buf := make([]byte, size) @@ -8649,7 +8776,7 @@ func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 152 // request opcode + buf[b] = 110 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8658,56 +8785,54 @@ func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], Pname) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], uint32(Datum)) b += 4 return buf } -// GetSeparableFilterCookie is a cookie used only for GetSeparableFilter requests. -type GetSeparableFilterCookie struct { +// QueryContextCookie is a cookie used only for QueryContext requests. +type QueryContextCookie struct { *xgb.Cookie } -// GetSeparableFilter sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSeparableFilterCookie.Reply() -func GetSeparableFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { +// QueryContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryContextCookie.Reply() +func QueryContext(c *xgb.Conn, Context Context) QueryContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetSeparableFilterCookie{cookie} + c.NewRequest(queryContextRequest(c, Context), cookie) + return QueryContextCookie{cookie} } -// GetSeparableFilterUnchecked sends an unchecked request. +// QueryContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSeparableFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { +func QueryContextUnchecked(c *xgb.Conn, Context Context) QueryContextCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetSeparableFilterCookie{cookie} + c.NewRequest(queryContextRequest(c, Context), cookie) + return QueryContextCookie{cookie} } -// GetSeparableFilterReply represents the data returned from a GetSeparableFilter request. -type GetSeparableFilterReply struct { +// QueryContextReply represents the data returned from a QueryContext request. +type QueryContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 8 bytes - RowW int32 - ColH int32 - // padding: 8 bytes - RowsAndCols []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + NumAttribs uint32 + // padding: 20 bytes + Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) } -// Reply blocks and returns the reply data for a GetSeparableFilter request. -func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { +// Reply blocks and returns the reply data for a QueryContext request. +func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8715,12 +8840,12 @@ func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { if buf == nil { return nil, nil } - return getSeparableFilterReply(buf), nil + return queryContextReply(buf), nil } -// getSeparableFilterReply reads a byte slice into a GetSeparableFilterReply value. -func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { - v := new(GetSeparableFilterReply) +// queryContextReply reads a byte slice into a QueryContextReply value. +func queryContextReply(buf []byte) *QueryContextReply { + v := new(QueryContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -8731,101 +8856,82 @@ func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 8 // padding - - v.RowW = int32(xgb.Get32(buf[b:])) - b += 4 - - v.ColH = int32(xgb.Get32(buf[b:])) + v.NumAttribs = xgb.Get32(buf[b:]) b += 4 - b += 8 // padding + b += 20 // padding - v.RowsAndCols = make([]byte, (int(v.Length) * 4)) - copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for GetSeparableFilter -// getSeparableFilterRequest writes a GetSeparableFilter request to a byte slice. -func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 +// Write request to wire for QueryContext +// queryContextRequest writes a QueryContext request to a byte slice. +func queryContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 153 // request opcode + buf[b] = 25 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) + xgb.Put32(buf[b:], uint32(Context)) b += 4 - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - return buf } -// GetHistogramCookie is a cookie used only for GetHistogram requests. -type GetHistogramCookie struct { +// QueryExtensionsStringCookie is a cookie used only for QueryExtensionsString requests. +type QueryExtensionsStringCookie struct { *xgb.Cookie } -// GetHistogram sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetHistogramCookie.Reply() -func GetHistogram(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { +// QueryExtensionsString sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionsStringCookie.Reply() +func QueryExtensionsString(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogram' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GetHistogramCookie{cookie} + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} } -// GetHistogramUnchecked sends an unchecked request. +// QueryExtensionsStringUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetHistogramUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { +func QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogram' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GetHistogramCookie{cookie} + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} } -// GetHistogramReply represents the data returned from a GetHistogram request. -type GetHistogramReply struct { +// QueryExtensionsStringReply represents the data returned from a QueryExtensionsString request. +type QueryExtensionsStringReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 8 bytes - Width int32 - // padding: 12 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + // padding: 4 bytes + N uint32 + // padding: 16 bytes } -// Reply blocks and returns the reply data for a GetHistogram request. -func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { +// Reply blocks and returns the reply data for a QueryExtensionsString request. +func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8833,12 +8939,12 @@ func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { if buf == nil { return nil, nil } - return getHistogramReply(buf), nil + return queryExtensionsStringReply(buf), nil } -// getHistogramReply reads a byte slice into a GetHistogramReply value. -func getHistogramReply(buf []byte) *GetHistogramReply { - v := new(GetHistogramReply) +// queryExtensionsStringReply reads a byte slice into a QueryExtensionsStringReply value. +func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { + v := new(QueryExtensionsStringReply) b := 1 // skip reply determinant b += 1 // padding @@ -8849,106 +8955,78 @@ func getHistogramReply(buf []byte) *GetHistogramReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 8 // padding + b += 4 // padding - v.Width = int32(xgb.Get32(buf[b:])) + v.N = xgb.Get32(buf[b:]) b += 4 - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) + b += 16 // padding return v } -// Write request to wire for GetHistogram -// getHistogramRequest writes a GetHistogram request to a byte slice. -func getHistogramRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { - size := 24 +// Write request to wire for QueryExtensionsString +// queryExtensionsStringRequest writes a QueryExtensionsString request to a byte slice. +func queryExtensionsStringRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 154 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) + xgb.Put32(buf[b:], Screen) b += 4 - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Reset { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - return buf } -// GetHistogramParameterfvCookie is a cookie used only for GetHistogramParameterfv requests. -type GetHistogramParameterfvCookie struct { +// QueryServerStringCookie is a cookie used only for QueryServerString requests. +type QueryServerStringCookie struct { *xgb.Cookie } -// GetHistogramParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetHistogramParameterfvCookie.Reply() -func GetHistogramParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { +// QueryServerString sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryServerStringCookie.Reply() +func QueryServerString(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogramParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryServerString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetHistogramParameterfvCookie{cookie} + c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} } -// GetHistogramParameterfvUnchecked sends an unchecked request. +// QueryServerStringUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetHistogramParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { +func QueryServerStringUnchecked(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogramParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryServerString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetHistogramParameterfvCookie{cookie} + c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} } -// GetHistogramParameterfvReply represents the data returned from a GetHistogramParameterfv request. -type GetHistogramParameterfvReply struct { +// QueryServerStringReply represents the data returned from a QueryServerString request. +type QueryServerStringReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) + StrLen uint32 + // padding: 16 bytes + String string // size: xgb.Pad((int(StrLen) * 1)) } -// Reply blocks and returns the reply data for a GetHistogramParameterfv request. -func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply, error) { +// Reply blocks and returns the reply data for a QueryServerString request. +func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8956,12 +9034,12 @@ func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply if buf == nil { return nil, nil } - return getHistogramParameterfvReply(buf), nil + return queryServerStringReply(buf), nil } -// getHistogramParameterfvReply reads a byte slice into a GetHistogramParameterfvReply value. -func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { - v := new(GetHistogramParameterfvReply) +// queryServerStringReply reads a byte slice into a QueryServerStringReply value. +func queryServerStringReply(buf []byte) *QueryServerStringReply { + v := new(QueryServerStringReply) b := 1 // skip reply determinant b += 1 // padding @@ -8974,93 +9052,85 @@ func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { b += 4 // padding - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = Float32(xgb.Get32(buf[b:])) + v.StrLen = xgb.Get32(buf[b:]) b += 4 - b += 12 // padding + b += 16 // padding - v.Data = make([]Float32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) - b += 4 + { + byteString := make([]byte, v.StrLen) + copy(byteString[:v.StrLen], buf[b:]) + v.String = string(byteString) + b += xgb.Pad(int(v.StrLen)) } - b = xgb.Pad(b) return v } -// Write request to wire for GetHistogramParameterfv -// getHistogramParameterfvRequest writes a GetHistogramParameterfv request to a byte slice. -func getHistogramParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for QueryServerString +// queryServerStringRequest writes a QueryServerString request to a byte slice. +func queryServerStringRequest(c *xgb.Conn, Screen uint32, Name uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 155 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], Name) b += 4 return buf } -// GetHistogramParameterivCookie is a cookie used only for GetHistogramParameteriv requests. -type GetHistogramParameterivCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// GetHistogramParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetHistogramParameterivCookie.Reply() -func GetHistogramParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { +// 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogramParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetHistogramParameterivCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetHistogramParameterivUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetHistogramParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogramParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetHistogramParameterivCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetHistogramParameterivReply represents the data returned from a GetHistogramParameteriv request. -type GetHistogramParameterivReply struct { +// 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 - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes } -// Reply blocks and returns the reply data for a GetHistogramParameteriv request. -func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply, error) { +// 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 @@ -9068,12 +9138,12 @@ func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply if buf == nil { return nil, nil } - return getHistogramParameterivReply(buf), nil + return queryVersionReply(buf), nil } -// getHistogramParameterivReply reads a byte slice into a GetHistogramParameterivReply value. -func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { - v := new(GetHistogramParameterivReply) +// 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 @@ -9084,83 +9154,71 @@ func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) + v.MajorVersion = xgb.Get32(buf[b:]) b += 4 - v.Datum = int32(xgb.Get32(buf[b:])) + v.MinorVersion = xgb.Get32(buf[b:]) b += 4 - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + b += 16 // padding return v } -// Write request to wire for GetHistogramParameteriv -// getHistogramParameterivRequest writes a GetHistogramParameteriv request to a byte slice. -func getHistogramParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 156 // request opcode + 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:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], MajorVersion) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], MinorVersion) b += 4 return buf } -// GetMinmaxCookie is a cookie used only for GetMinmax requests. -type GetMinmaxCookie struct { +// ReadPixelsCookie is a cookie used only for ReadPixels requests. +type ReadPixelsCookie struct { *xgb.Cookie } -// GetMinmax sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMinmaxCookie.Reply() -func GetMinmax(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { +// ReadPixels sends a checked request. +// If an error occurs, it will be returned with the reply by calling ReadPixelsCookie.Reply() +func ReadPixels(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'ReadPixels' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GetMinmaxCookie{cookie} + c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) + return ReadPixelsCookie{cookie} } -// GetMinmaxUnchecked sends an unchecked request. +// ReadPixelsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMinmaxUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { +func ReadPixelsUnchecked(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'ReadPixels' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GetMinmaxCookie{cookie} + c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) + return ReadPixelsCookie{cookie} } -// GetMinmaxReply represents the data returned from a GetMinmax request. -type GetMinmaxReply struct { +// ReadPixelsReply represents the data returned from a ReadPixels request. +type ReadPixelsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -9168,8 +9226,8 @@ type GetMinmaxReply struct { Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Reply blocks and returns the reply data for a GetMinmax request. -func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { +// Reply blocks and returns the reply data for a ReadPixels request. +func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9177,12 +9235,12 @@ func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { if buf == nil { return nil, nil } - return getMinmaxReply(buf), nil + return readPixelsReply(buf), nil } -// getMinmaxReply reads a byte slice into a GetMinmaxReply value. -func getMinmaxReply(buf []byte) *GetMinmaxReply { - v := new(GetMinmaxReply) +// readPixelsReply reads a byte slice into a ReadPixelsReply value. +func readPixelsReply(buf []byte) *ReadPixelsReply { + v := new(ReadPixelsReply) b := 1 // skip reply determinant b += 1 // padding @@ -9202,17 +9260,17 @@ func getMinmaxReply(buf []byte) *GetMinmaxReply { return v } -// Write request to wire for GetMinmax -// getMinmaxRequest writes a GetMinmax request to a byte slice. -func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { - size := 24 +// Write request to wire for ReadPixels +// readPixelsRequest writes a ReadPixels request to a byte slice. +func readPixelsRequest(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) []byte { + size := 36 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 157 // request opcode + buf[b] = 111 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9221,7 +9279,16 @@ func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], uint32(X)) + b += 4 + + xgb.Put32(buf[b:], uint32(Y)) + b += 4 + + xgb.Put32(buf[b:], uint32(Width)) + b += 4 + + xgb.Put32(buf[b:], uint32(Height)) b += 4 xgb.Put32(buf[b:], Format) @@ -9237,7 +9304,7 @@ func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format } b += 1 - if Reset { + if LsbFirst { buf[b] = 1 } else { buf[b] = 0 @@ -9247,101 +9314,108 @@ func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format return buf } -// GetMinmaxParameterfvCookie is a cookie used only for GetMinmaxParameterfv requests. -type GetMinmaxParameterfvCookie struct { +// RenderCookie is a cookie used only for Render requests. +type RenderCookie struct { *xgb.Cookie } -// GetMinmaxParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterfvCookie.Reply() -func GetMinmaxParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { +// Render sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Render(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'Render' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterfvCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} } -// GetMinmaxParameterfvUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { +// RenderChecked sends a checked request. +// If an error occurs, it can be retrieved using RenderCookie.Check() +func RenderChecked(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'Render' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterfvCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} } -// GetMinmaxParameterfvReply represents the data returned from a GetMinmaxParameterfv request. -type GetMinmaxParameterfvReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) +// 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 RenderCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetMinmaxParameterfv request. -func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getMinmaxParameterfvReply(buf), nil -} +// Write request to wire for Render +// renderRequest writes a Render request to a byte slice. +func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) -// getMinmaxParameterfvReply reads a byte slice into a GetMinmaxParameterfvReply value. -func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { - v := new(GetMinmaxParameterfvReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 1 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - b += 4 // padding + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) - v.N = xgb.Get32(buf[b:]) - b += 4 + return buf +} - v.Datum = Float32(xgb.Get32(buf[b:])) - b += 4 +// RenderLargeCookie is a cookie used only for RenderLarge requests. +type RenderLargeCookie struct { + *xgb.Cookie +} - b += 12 // padding +// RenderLarge sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func RenderLarge(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} - v.Data = make([]Float32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) - b += 4 +// RenderLargeChecked sends a checked request. +// If an error occurs, it can be retrieved using RenderLargeCookie.Check() +func RenderLargeChecked(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} - 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 RenderLargeCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetMinmaxParameterfv -// getMinmaxParameterfvRequest writes a GetMinmaxParameterfv request to a byte slice. -func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for RenderLarge +// renderLargeRequest writes a RenderLarge request to a byte slice. +func renderLargeRequest(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 158 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9350,56 +9424,62 @@ func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) - b += 4 + xgb.Put16(buf[b:], RequestNum) + b += 2 - xgb.Put32(buf[b:], Pname) + xgb.Put16(buf[b:], RequestTotal) + b += 2 + + xgb.Put32(buf[b:], DataLen) b += 4 + copy(buf[b:], Data[:DataLen]) + b += xgb.Pad(int(DataLen)) + return buf } -// GetMinmaxParameterivCookie is a cookie used only for GetMinmaxParameteriv requests. -type GetMinmaxParameterivCookie struct { +// RenderModeCookie is a cookie used only for RenderMode requests. +type RenderModeCookie struct { *xgb.Cookie } -// GetMinmaxParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterivCookie.Reply() -func GetMinmaxParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { +// RenderMode sends a checked request. +// If an error occurs, it will be returned with the reply by calling RenderModeCookie.Reply() +func RenderMode(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'RenderMode' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterivCookie{cookie} + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} } -// GetMinmaxParameterivUnchecked sends an unchecked request. +// RenderModeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { +func RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'RenderMode' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterivCookie{cookie} + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} } -// GetMinmaxParameterivReply represents the data returned from a GetMinmaxParameteriv request. -type GetMinmaxParameterivReply struct { +// RenderModeReply represents the data returned from a RenderMode request. +type RenderModeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 + RetVal uint32 + N uint32 + NewMode uint32 // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + Data []uint32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetMinmaxParameteriv request. -func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, error) { +// Reply blocks and returns the reply data for a RenderMode request. +func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9407,12 +9487,12 @@ func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, erro if buf == nil { return nil, nil } - return getMinmaxParameterivReply(buf), nil + return renderModeReply(buf), nil } -// getMinmaxParameterivReply reads a byte slice into a GetMinmaxParameterivReply value. -func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { - v := new(GetMinmaxParameterivReply) +// renderModeReply reads a byte slice into a RenderModeReply value. +func renderModeReply(buf []byte) *RenderModeReply { + v := new(RenderModeReply) b := 1 // skip reply determinant b += 1 // padding @@ -9423,19 +9503,20 @@ func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding + v.RetVal = xgb.Get32(buf[b:]) + b += 4 v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = int32(xgb.Get32(buf[b:])) + v.NewMode = xgb.Get32(buf[b:]) b += 4 b += 12 // padding - v.Data = make([]int32, v.N) + v.Data = make([]uint32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) + v.Data[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) @@ -9443,17 +9524,17 @@ func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { return v } -// Write request to wire for GetMinmaxParameteriv -// getMinmaxParameterivRequest writes a GetMinmaxParameteriv request to a byte slice. -func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for RenderMode +// renderModeRequest writes a RenderMode request to a byte slice. +func renderModeRequest(c *xgb.Conn, ContextTag ContextTag, Mode uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 159 // request opcode + buf[b] = 107 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9462,103 +9543,56 @@ func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], Mode) b += 4 return buf } -// GetCompressedTexImageARBCookie is a cookie used only for GetCompressedTexImageARB requests. -type GetCompressedTexImageARBCookie struct { +// SelectBufferCookie is a cookie used only for SelectBuffer requests. +type SelectBufferCookie struct { *xgb.Cookie } -// GetCompressedTexImageARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCompressedTexImageARBCookie.Reply() -func GetCompressedTexImageARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) - return GetCompressedTexImageARBCookie{cookie} -} - -// GetCompressedTexImageARBUnchecked sends an unchecked request. +// SelectBuffer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCompressedTexImageARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { +func SelectBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) - return GetCompressedTexImageARBCookie{cookie} -} - -// GetCompressedTexImageARBReply represents the data returned from a GetCompressedTexImageARB request. -type GetCompressedTexImageARBReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 8 bytes - Size int32 - // padding: 12 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + cookie := c.NewCookie(false, false) + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{cookie} } -// Reply blocks and returns the reply data for a GetCompressedTexImageARB request. -func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SelectBufferChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectBufferCookie.Check() +func SelectBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'SelectBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return getCompressedTexImageARBReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{cookie} } -// getCompressedTexImageARBReply reads a byte slice into a GetCompressedTexImageARBReply value. -func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { - v := new(GetCompressedTexImageARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Size = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 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 SelectBufferCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetCompressedTexImageARB -// getCompressedTexImageARBRequest writes a GetCompressedTexImageARB request to a byte slice. -func getCompressedTexImageARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) []byte { - size := 16 +// Write request to wire for SelectBuffer +// selectBufferRequest writes a SelectBuffer request to a byte slice. +func selectBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 160 // request opcode + buf[b] = 106 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9567,246 +9601,206 @@ func getCompressedTexImageARBRequest(c *xgb.Conn, ContextTag ContextTag, Target xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], uint32(Level)) + xgb.Put32(buf[b:], uint32(Size)) b += 4 return buf } -// DeleteQueriesARBCookie is a cookie used only for DeleteQueriesARB requests. -type DeleteQueriesARBCookie struct { +// SetClientInfo2ARBCookie is a cookie used only for SetClientInfo2ARB requests. +type SetClientInfo2ARBCookie struct { *xgb.Cookie } -// DeleteQueriesARB sends an unchecked request. +// SetClientInfo2ARB sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { +func SetClientInfo2ARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'SetClientInfo2ARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) - return DeleteQueriesARBCookie{cookie} + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{cookie} } -// DeleteQueriesARBChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteQueriesARBCookie.Check() -func DeleteQueriesARBChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { +// SetClientInfo2ARBChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClientInfo2ARBCookie.Check() +func SetClientInfo2ARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'SetClientInfo2ARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) - return DeleteQueriesARBCookie{cookie} + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{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 DeleteQueriesARBCookie) Check() error { +func (cook SetClientInfo2ARBCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DeleteQueriesARB -// deleteQueriesARBRequest writes a DeleteQueriesARB request to a byte slice. -func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +// Write request to wire for SetClientInfo2ARB +// setClientInfo2ARBRequest writes a SetClientInfo2ARB request to a byte slice. +func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { + size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 161 // request opcode + buf[b] = 35 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], MajorVersion) b += 4 - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], MinorVersion) b += 4 - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Ids[i]) + xgb.Put32(buf[b:], NumVersions) + b += 4 + + xgb.Put32(buf[b:], GlStrLen) + b += 4 + + xgb.Put32(buf[b:], GlxStrLen) + b += 4 + + for i := 0; i < int((int(NumVersions) * 3)); i++ { + xgb.Put32(buf[b:], GlVersions[i]) b += 4 } b = xgb.Pad(b) + copy(buf[b:], GlExtensionString[:GlStrLen]) + b += xgb.Pad(int(GlStrLen)) + + copy(buf[b:], GlxExtensionString[:GlxStrLen]) + b += xgb.Pad(int(GlxStrLen)) + return buf } -// GenQueriesARBCookie is a cookie used only for GenQueriesARB requests. -type GenQueriesARBCookie struct { +// SetClientInfoARBCookie is a cookie used only for SetClientInfoARB requests. +type SetClientInfoARBCookie struct { *xgb.Cookie } -// GenQueriesARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling GenQueriesARBCookie.Reply() -func GenQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) - return GenQueriesARBCookie{cookie} -} - -// GenQueriesARBUnchecked sends an unchecked request. +// SetClientInfoARB sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { +func SetClientInfoARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'SetClientInfoARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) - return GenQueriesARBCookie{cookie} -} - -// GenQueriesARBReply represents the data returned from a GenQueriesARB request. -type GenQueriesARBReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 24 bytes - Data []uint32 // size: xgb.Pad((int(Length) * 4)) + cookie := c.NewCookie(false, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{cookie} } -// Reply blocks and returns the reply data for a GenQueriesARB request. -func (cook GenQueriesARBCookie) Reply() (*GenQueriesARBReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SetClientInfoARBChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClientInfoARBCookie.Check() +func SetClientInfoARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'SetClientInfoARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return genQueriesARBReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{cookie} } -// genQueriesARBReply reads a byte slice into a GenQueriesARBReply value. -func genQueriesARBReply(buf []byte) *GenQueriesARBReply { - v := new(GenQueriesARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - 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 SetClientInfoARBCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GenQueriesARB -// genQueriesARBRequest writes a GenQueriesARB request to a byte slice. -func genQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { - size := 12 +// Write request to wire for SetClientInfoARB +// setClientInfoARBRequest writes a SetClientInfoARB request to a byte slice. +func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { + size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 162 // request opcode + buf[b] = 33 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], MajorVersion) b += 4 - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], NumVersions) b += 4 + xgb.Put32(buf[b:], GlStrLen) + b += 4 + + xgb.Put32(buf[b:], GlxStrLen) + b += 4 + + for i := 0; i < int((int(NumVersions) * 2)); i++ { + xgb.Put32(buf[b:], GlVersions[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], GlExtensionString[:GlStrLen]) + b += xgb.Pad(int(GlStrLen)) + + copy(buf[b:], GlxExtensionString[:GlxStrLen]) + b += xgb.Pad(int(GlxStrLen)) + return buf } -// IsQueryARBCookie is a cookie used only for IsQueryARB requests. -type IsQueryARBCookie struct { +// SwapBuffersCookie is a cookie used only for SwapBuffers requests. +type SwapBuffersCookie struct { *xgb.Cookie } -// IsQueryARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling IsQueryARBCookie.Reply() -func IsQueryARB(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsQueryARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) - return IsQueryARBCookie{cookie} -} - -// IsQueryARBUnchecked sends an unchecked request. +// SwapBuffers sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IsQueryARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { +func SwapBuffers(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsQueryARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'SwapBuffers' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) - return IsQueryARBCookie{cookie} -} - -// IsQueryARBReply represents the data returned from a IsQueryARB request. -type IsQueryARBReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - RetVal Bool32 + cookie := c.NewCookie(false, false) + c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) + return SwapBuffersCookie{cookie} } -// Reply blocks and returns the reply data for a IsQueryARB request. -func (cook IsQueryARBCookie) Reply() (*IsQueryARBReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SwapBuffersChecked sends a checked request. +// If an error occurs, it can be retrieved using SwapBuffersCookie.Check() +func SwapBuffersChecked(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'SwapBuffers' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - return isQueryARBReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) + return SwapBuffersCookie{cookie} } -// isQueryARBReply reads a byte slice into a IsQueryARBReply value. -func isQueryARBReply(buf []byte) *IsQueryARBReply { - v := new(IsQueryARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = Bool32(xgb.Get32(buf[b:])) - b += 4 - - return v +// 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 SwapBuffersCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for IsQueryARB -// isQueryARBRequest writes a IsQueryARB request to a byte slice. -func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { +// Write request to wire for SwapBuffers +// swapBuffersRequest writes a SwapBuffers request to a byte slice. +func swapBuffersRequest(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -9814,7 +9808,7 @@ func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 163 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9823,165 +9817,179 @@ func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Id) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 return buf } -// GetQueryivARBCookie is a cookie used only for GetQueryivARB requests. -type GetQueryivARBCookie struct { +// UseXFontCookie is a cookie used only for UseXFont requests. +type UseXFontCookie struct { *xgb.Cookie } -// GetQueryivARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetQueryivARBCookie.Reply() -func GetQueryivARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { +// UseXFont sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func UseXFont(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'UseXFont' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) - return GetQueryivARBCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) + return UseXFontCookie{cookie} } -// GetQueryivARBUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { +// UseXFontChecked sends a checked request. +// If an error occurs, it can be retrieved using UseXFontCookie.Check() +func UseXFontChecked(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'UseXFont' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) - return GetQueryivARBCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) + return UseXFontCookie{cookie} } -// GetQueryivARBReply represents the data returned from a GetQueryivARB request. -type GetQueryivARBReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) +// 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 UseXFontCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetQueryivARB request. -func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getQueryivARBReply(buf), nil -} +// Write request to wire for UseXFont +// useXFontRequest writes a UseXFont request to a byte slice. +func useXFontRequest(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) []byte { + size := 24 + b := 0 + buf := make([]byte, size) -// getQueryivARBReply reads a byte slice into a GetQueryivARBReply value. -func getQueryivARBReply(buf []byte) *GetQueryivARBReply { - v := new(GetQueryivARBReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 12 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - b += 4 // padding + xgb.Put32(buf[b:], uint32(Font)) + b += 4 - v.N = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], First) b += 4 - v.Datum = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], Count) b += 4 - b += 12 // padding + xgb.Put32(buf[b:], ListBase) + b += 4 - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 + return buf +} + +// VendorPrivateCookie is a cookie used only for VendorPrivate requests. +type VendorPrivateCookie struct { + *xgb.Cookie +} + +// VendorPrivate sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func VendorPrivate(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'VendorPrivate' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(false, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{cookie} +} - return v +// VendorPrivateChecked sends a checked request. +// If an error occurs, it can be retrieved using VendorPrivateCookie.Check() +func VendorPrivateChecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'VendorPrivate' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{cookie} } -// Write request to wire for GetQueryivARB -// getQueryivARBRequest writes a GetQueryivARB request to a byte slice. -func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// 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 VendorPrivateCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for VendorPrivate +// vendorPrivateRequest writes a VendorPrivate request to a byte slice. +func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 164 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], VendorCode) b += 4 - xgb.Put32(buf[b:], Target) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Pname) - b += 4 + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) return buf } -// GetQueryObjectivARBCookie is a cookie used only for GetQueryObjectivARB requests. -type GetQueryObjectivARBCookie struct { +// VendorPrivateWithReplyCookie is a cookie used only for VendorPrivateWithReply requests. +type VendorPrivateWithReplyCookie struct { *xgb.Cookie } -// GetQueryObjectivARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetQueryObjectivARBCookie.Reply() -func GetQueryObjectivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { +// VendorPrivateWithReply sends a checked request. +// If an error occurs, it will be returned with the reply by calling VendorPrivateWithReplyCookie.Reply() +func VendorPrivateWithReply(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) - return GetQueryObjectivARBCookie{cookie} + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} } -// GetQueryObjectivARBUnchecked sends an unchecked request. +// VendorPrivateWithReplyUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { +func VendorPrivateWithReplyUnchecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) - return GetQueryObjectivARBCookie{cookie} + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} } -// GetQueryObjectivARBReply represents the data returned from a GetQueryObjectivARB request. -type GetQueryObjectivARBReply struct { +// VendorPrivateWithReplyReply represents the data returned from a VendorPrivateWithReply request. +type VendorPrivateWithReplyReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + Retval uint32 + Data1 []byte // size: 24 + Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Reply blocks and returns the reply data for a GetQueryObjectivARB request. -func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) { +// Reply blocks and returns the reply data for a VendorPrivateWithReply request. +func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9989,12 +9997,12 @@ func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) if buf == nil { return nil, nil } - return getQueryObjectivARBReply(buf), nil + return vendorPrivateWithReplyReply(buf), nil } -// getQueryObjectivARBReply reads a byte slice into a GetQueryObjectivARBReply value. -func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { - v := new(GetQueryObjectivARBReply) +// vendorPrivateWithReplyReply reads a byte slice into a VendorPrivateWithReplyReply value. +func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { + v := new(VendorPrivateWithReplyReply) b := 1 // skip reply determinant b += 1 // padding @@ -10005,149 +10013,147 @@ func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = int32(xgb.Get32(buf[b:])) + v.Retval = xgb.Get32(buf[b:]) b += 4 - b += 12 // padding + v.Data1 = make([]byte, 24) + copy(v.Data1[:24], buf[b:]) + b += xgb.Pad(int(24)) - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + v.Data2 = make([]byte, (int(v.Length) * 4)) + copy(v.Data2[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) return v } -// Write request to wire for GetQueryObjectivARB -// getQueryObjectivARBRequest writes a GetQueryObjectivARB request to a byte slice. -func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for VendorPrivateWithReply +// vendorPrivateWithReplyRequest writes a VendorPrivateWithReply request to a byte slice. +func vendorPrivateWithReplyRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 165 // request opcode + buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], VendorCode) b += 4 - xgb.Put32(buf[b:], Id) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Pname) - b += 4 + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) return buf } -// GetQueryObjectuivARBCookie is a cookie used only for GetQueryObjectuivARB requests. -type GetQueryObjectuivARBCookie struct { +// WaitGLCookie is a cookie used only for WaitGL requests. +type WaitGLCookie struct { *xgb.Cookie } -// GetQueryObjectuivARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetQueryObjectuivARBCookie.Reply() -func GetQueryObjectuivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { +// WaitGL sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func WaitGL(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'WaitGL' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) - return GetQueryObjectuivARBCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(waitGLRequest(c, ContextTag), cookie) + return WaitGLCookie{cookie} } -// GetQueryObjectuivARBUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { +// WaitGLChecked sends a checked request. +// If an error occurs, it can be retrieved using WaitGLCookie.Check() +func WaitGLChecked(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'WaitGL' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) - return GetQueryObjectuivARBCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(waitGLRequest(c, ContextTag), cookie) + return WaitGLCookie{cookie} } -// GetQueryObjectuivARBReply represents the data returned from a GetQueryObjectuivARB request. -type GetQueryObjectuivARBReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint32 - // padding: 12 bytes - Data []uint32 // size: xgb.Pad((int(N) * 4)) +// 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 WaitGLCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetQueryObjectuivARB request. -func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getQueryObjectuivARBReply(buf), nil -} +// Write request to wire for WaitGL +// waitGLRequest writes a WaitGL request to a byte slice. +func waitGLRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) -// getQueryObjectuivARBReply reads a byte slice into a GetQueryObjectuivARBReply value. -func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { - v := new(GetQueryObjectuivARBReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 8 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 + return buf +} - v.Datum = xgb.Get32(buf[b:]) - b += 4 +// WaitXCookie is a cookie used only for WaitX requests. +type WaitXCookie struct { + *xgb.Cookie +} - b += 12 // padding +// WaitX sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func WaitX(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'WaitX' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(waitXRequest(c, ContextTag), cookie) + return WaitXCookie{cookie} +} - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = xgb.Get32(buf[b:]) - b += 4 +// WaitXChecked sends a checked request. +// If an error occurs, it can be retrieved using WaitXCookie.Check() +func WaitXChecked(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'WaitX' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(waitXRequest(c, ContextTag), cookie) + return WaitXCookie{cookie} +} - 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 WaitXCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetQueryObjectuivARB -// getQueryObjectuivARBRequest writes a GetQueryObjectuivARB request to a byte slice. -func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for WaitX +// waitXRequest writes a WaitX request to a byte slice. +func waitXRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 166 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -10156,11 +10162,5 @@ func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Id) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - return buf } diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go index 6e2eecc..81104eb 100644 --- a/nexgb/randr/randr.go +++ b/nexgb/randr/randr.go @@ -2,7 +2,7 @@ package randr /* - This file was generated by randr.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by randr.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,69 +41,143 @@ func init() { xgb.NewExtErrorFuncs["RANDR"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card16' +// BadBadCrtc is the error number for a BadBadCrtc. +const BadBadCrtc = 1 -// Skipping definition for base type 'Char' +type BadCrtcError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Card32' +// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice. +func BadCrtcErrorNew(buf []byte) xgb.Error { + v := BadCrtcError{} + v.NiceName = "BadCrtc" -// Skipping definition for base type 'Double' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Bool' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Float' + return v +} -// Skipping definition for base type 'Card8' +// SequenceId returns the sequence id attached to the BadBadCrtc error. +// This is mostly used internally. +func (err BadCrtcError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Int16' +// BadId returns the 'BadValue' number if one exists for the BadBadCrtc error. If no bad value exists, 0 is returned. +func (err BadCrtcError) BadId() uint32 { + return 0 +} -// Skipping definition for base type 'Int32' +// Error returns a rudimentary string representation of the BadBadCrtc error. -// Skipping definition for base type 'Void' +func (err BadCrtcError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadCrtc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Byte' +func init() { + xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew +} -// Skipping definition for base type 'Int8' +// BadBadMode is the error number for a BadBadMode. +const BadBadMode = 2 -const ( - RotationRotate0 = 1 - RotationRotate90 = 2 - RotationRotate180 = 4 - RotationRotate270 = 8 - RotationReflectX = 16 - RotationReflectY = 32 -) +type BadModeError struct { + Sequence uint16 + NiceName string +} -const ( - SetConfigSuccess = 0 - SetConfigInvalidConfigTime = 1 - SetConfigInvalidTime = 2 - SetConfigFailed = 3 -) +// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. +func BadModeErrorNew(buf []byte) xgb.Error { + v := BadModeError{} + v.NiceName = "BadMode" -const ( - NotifyMaskScreenChange = 1 - NotifyMaskCrtcChange = 2 - NotifyMaskOutputChange = 4 - NotifyMaskOutputProperty = 8 -) + b := 1 // skip error determinant + b += 1 // don't read error number -const ( - ModeFlagHsyncPositive = 1 - ModeFlagHsyncNegative = 2 - ModeFlagVsyncPositive = 4 - ModeFlagVsyncNegative = 8 - ModeFlagInterlace = 16 - ModeFlagDoubleScan = 32 - ModeFlagCsync = 64 - ModeFlagCsyncPositive = 128 - ModeFlagCsyncNegative = 256 - ModeFlagHskewPresent = 512 - ModeFlagBcast = 1024 - ModeFlagPixelMultiplex = 2048 - ModeFlagDoubleClock = 4096 - ModeFlagHalveClock = 8192 -) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadBadMode error. +// This is mostly used internally. +func (err BadModeError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadMode error. If no bad value exists, 0 is returned. +func (err BadModeError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadMode error. + +func (err BadModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew +} + +// BadBadOutput is the error number for a BadBadOutput. +const BadBadOutput = 0 + +type BadOutputError struct { + Sequence uint16 + NiceName string +} + +// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. +func BadOutputErrorNew(buf []byte) xgb.Error { + v := BadOutputError{} + v.NiceName = "BadOutput" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadBadOutput error. +// This is mostly used internally. +func (err BadOutputError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadOutput error. If no bad value exists, 0 is returned. +func (err BadOutputError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadOutput error. + +func (err BadOutputError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadOutput {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew +} const ( ConnectionConnected = 0 @@ -111,22 +185,6 @@ const ( ConnectionUnknown = 2 ) -const ( - NotifyCrtcChange = 0 - NotifyOutputChange = 1 - NotifyOutputProperty = 2 -) - -type Mode uint32 - -func NewModeId(c *xgb.Conn) (Mode, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Mode(id), nil -} - type Crtc uint32 func NewCrtcId(c *xgb.Conn) (Crtc, error) { @@ -137,135 +195,104 @@ func NewCrtcId(c *xgb.Conn) (Crtc, error) { return Crtc(id), nil } -type Output uint32 - -func NewOutputId(c *xgb.Conn) (Output, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Output(id), nil -} - -type ScreenSize struct { - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 +type CrtcChange struct { + Timestamp xproto.Timestamp + Window xproto.Window + Crtc Crtc + Mode Mode + Rotation uint16 + // padding: 2 bytes + X int16 + Y int16 + Width uint16 + Height uint16 } -// ScreenSizeRead reads a byte slice into a ScreenSize value. -func ScreenSizeRead(buf []byte, v *ScreenSize) int { +// CrtcChangeRead reads a byte slice into a CrtcChange value. +func CrtcChangeRead(buf []byte, v *CrtcChange) int { b := 0 - v.Width = xgb.Get16(buf[b:]) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + v.Rotation = xgb.Get16(buf[b:]) b += 2 - v.Height = xgb.Get16(buf[b:]) + b += 2 // padding + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.Mwidth = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.Mheight = xgb.Get16(buf[b:]) + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) b += 2 return b } -// ScreenSizeReadList reads a byte slice into a list of ScreenSize values. -func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { +// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. +func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = ScreenSize{} - b += ScreenSizeRead(buf[b:], &dest[i]) + dest[i] = CrtcChange{} + b += CrtcChangeRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a ScreenSize value to a byte slice. -func (v ScreenSize) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a CrtcChange value to a byte slice. +func (v CrtcChange) Bytes() []byte { + buf := make([]byte, 28) b := 0 - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], v.Mwidth) - b += 2 - - xgb.Put16(buf[b:], v.Mheight) - b += 2 - - return buf -} + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 -// ScreenSizeListBytes writes a list of ScreenSize values to a byte slice. -func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 -type RefreshRates struct { - NRates uint16 - Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) -} + xgb.Put32(buf[b:], uint32(v.Crtc)) + b += 4 -// RefreshRatesRead reads a byte slice into a RefreshRates value. -func RefreshRatesRead(buf []byte, v *RefreshRates) int { - b := 0 + xgb.Put32(buf[b:], uint32(v.Mode)) + b += 4 - v.NRates = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Rotation) b += 2 - v.Rates = make([]uint16, v.NRates) - for i := 0; i < int(v.NRates); i++ { - v.Rates[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) - - return b -} + b += 2 // padding -// RefreshRatesReadList reads a byte slice into a list of RefreshRates values. -func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RefreshRates{} - b += RefreshRatesRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 -// Bytes writes a RefreshRates value to a byte slice. -func (v RefreshRates) Bytes() []byte { - buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) - b := 0 + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 - xgb.Put16(buf[b:], v.NRates) + xgb.Put16(buf[b:], v.Width) b += 2 - for i := 0; i < int(v.NRates); i++ { - xgb.Put16(buf[b:], v.Rates[i]) - b += 2 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.Height) + b += 2 return buf } -// RefreshRatesListBytes writes a list of RefreshRates values to a byte slice. -func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { +// CrtcChangeListBytes writes a list of CrtcChange values to a byte slice. +func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { b := 0 var structBytes []byte for _, item := range list { @@ -276,15 +303,33 @@ func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { return b } -// RefreshRatesListSize computes the size (bytes) of a list of RefreshRates values. -func RefreshRatesListSize(list []RefreshRates) int { - size := 0 - for _, item := range list { - size += (2 + xgb.Pad((int(item.NRates) * 2))) +type Mode uint32 + +func NewModeId(c *xgb.Conn) (Mode, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return size + return Mode(id), nil } +const ( + ModeFlagHsyncPositive = 1 + ModeFlagHsyncNegative = 2 + ModeFlagVsyncPositive = 4 + ModeFlagVsyncNegative = 8 + ModeFlagInterlace = 16 + ModeFlagDoubleScan = 32 + ModeFlagCsync = 64 + ModeFlagCsyncPositive = 128 + ModeFlagCsyncNegative = 256 + ModeFlagHskewPresent = 512 + ModeFlagBcast = 1024 + ModeFlagPixelMultiplex = 2048 + ModeFlagDoubleClock = 4096 + ModeFlagHalveClock = 8192 +) + type ModeInfo struct { Id uint32 Width uint16 @@ -416,114 +461,259 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int { return b } -type CrtcChange struct { - Timestamp xproto.Timestamp - Window xproto.Window - Crtc Crtc - Mode Mode - Rotation uint16 - // padding: 2 bytes - X int16 - Y int16 - Width uint16 - Height uint16 +// Notify is the event number for a NotifyEvent. +const Notify = 1 + +type NotifyEvent struct { + Sequence uint16 + SubCode byte + U NotifyDataUnion } -// CrtcChangeRead reads a byte slice into a CrtcChange value. -func CrtcChangeRead(buf []byte, v *CrtcChange) int { +// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.SubCode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.U = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &v.U) + + return v +} + +// Bytes writes a NotifyEvent value to a byte slice. +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + // write event number + buf[b] = 1 + b += 1 - v.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 + buf[b] = v.SubCode + b += 1 - v.Crtc = Crtc(xgb.Get32(buf[b:])) - b += 4 + b += 2 // skip sequence number - v.Mode = Mode(xgb.Get32(buf[b:])) - b += 4 + { + unionBytes := v.U.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } - v.Rotation = xgb.Get16(buf[b:]) - b += 2 + return buf +} - b += 2 // padding +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} - v.X = int16(xgb.Get16(buf[b:])) - b += 2 +// String is a rudimentary string representation of NotifyEvent. +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 +func init() { + xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew +} - v.Width = xgb.Get16(buf[b:]) - b += 2 +const ( + NotifyCrtcChange = 0 + NotifyOutputChange = 1 + NotifyOutputProperty = 2 +) - v.Height = xgb.Get16(buf[b:]) - b += 2 +// NotifyDataUnion is a represention of the NotifyDataUnion union type. +// Note that to *create* a Union, you should *never* create +// this struct directly (unless you know what you're doing). +// Instead use one of the following constructors for 'NotifyDataUnion': +// NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion +// NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion +// NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion +type NotifyDataUnion struct { + Cc CrtcChange + Oc OutputChange + Op OutputProperty +} - return b +// NotifyDataUnionCcNew constructs a new NotifyDataUnion union type with the Cc field. +func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v } -// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. -func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = CrtcChange{} - b += CrtcChangeRead(buf[b:], &dest[i]) +// NotifyDataUnionOcNew constructs a new NotifyDataUnion union type with the Oc field. +func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Oc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } - return xgb.Pad(b) + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v } -// Bytes writes a CrtcChange value to a byte slice. -func (v CrtcChange) Bytes() []byte { +// NotifyDataUnionOpNew constructs a new NotifyDataUnion union type with the Op field. +func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { + var b int buf := make([]byte, 28) - b := 0 - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 + { + structBytes := Op.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + // Create the Union type + v := NotifyDataUnion{} - xgb.Put32(buf[b:], uint32(v.Crtc)) - b += 4 + // Now copy buf into all fields - xgb.Put32(buf[b:], uint32(v.Mode)) - b += 4 + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) - xgb.Put16(buf[b:], v.Rotation) - b += 2 + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) - b += 2 // padding + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + return v +} - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 +// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. +func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { + var b int - xgb.Put16(buf[b:], v.Width) - b += 2 + b = 0 // re-read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) - xgb.Put16(buf[b:], v.Height) - b += 2 + b = 0 // re-read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) - return buf + b = 0 // re-read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return 28 } -// CrtcChangeListBytes writes a list of CrtcChange values to a byte slice. -func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { +// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values. +func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() + for i := 0; i < len(dest); i++ { + dest[i] = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a NotifyDataUnion value to a byte slice. +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v NotifyDataUnion) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + { + structBytes := v.Cc.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } + return buf +} + +// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. +func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { + b := 0 + var unionBytes []byte + for _, item := range list { + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } return b } +const ( + NotifyMaskScreenChange = 1 + NotifyMaskCrtcChange = 2 + NotifyMaskOutputChange = 4 + NotifyMaskOutputProperty = 8 +) + +type Output uint32 + +func NewOutputId(c *xgb.Conn) (Output, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Output(id), nil +} + type OutputChange struct { Timestamp xproto.Timestamp ConfigTimestamp xproto.Timestamp @@ -707,168 +897,85 @@ func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { return b } -// NotifyDataUnion is a represention of the NotifyDataUnion union type. -// Note that to *create* a Union, you should *never* create -// this struct directly (unless you know what you're doing). -// Instead use one of the following constructors for 'NotifyDataUnion': -// NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion -// NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion -// NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion -type NotifyDataUnion struct { - Cc CrtcChange - Oc OutputChange - Op OutputProperty -} - -// NotifyDataUnionCcNew constructs a new NotifyDataUnion union type with the Cc field. -func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Cc.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - // Create the Union type - v := NotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = CrtcChange{} - b += CrtcChangeRead(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = OutputChange{} - b += OutputChangeRead(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = OutputProperty{} - b += OutputPropertyRead(buf[b:], &v.Op) - - return v +type RefreshRates struct { + NRates uint16 + Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) } -// NotifyDataUnionOcNew constructs a new NotifyDataUnion union type with the Oc field. -func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Oc.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - // Create the Union type - v := NotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = CrtcChange{} - b += CrtcChangeRead(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = OutputChange{} - b += OutputChangeRead(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = OutputProperty{} - b += OutputPropertyRead(buf[b:], &v.Op) - - return v -} +// RefreshRatesRead reads a byte slice into a RefreshRates value. +func RefreshRatesRead(buf []byte, v *RefreshRates) int { + b := 0 -// NotifyDataUnionOpNew constructs a new NotifyDataUnion union type with the Op field. -func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { - var b int - buf := make([]byte, 28) + v.NRates = xgb.Get16(buf[b:]) + b += 2 - { - structBytes := Op.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + v.Rates = make([]uint16, v.NRates) + for i := 0; i < int(v.NRates); i++ { + v.Rates[i] = xgb.Get16(buf[b:]) + b += 2 } + b = xgb.Pad(b) - // Create the Union type - v := NotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = CrtcChange{} - b += CrtcChangeRead(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = OutputChange{} - b += OutputChangeRead(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = OutputProperty{} - b += OutputPropertyRead(buf[b:], &v.Op) - - return v -} - -// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. -func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { - var b int - - b = 0 // re-read the same bytes - v.Cc = CrtcChange{} - b += CrtcChangeRead(buf[b:], &v.Cc) - - b = 0 // re-read the same bytes - v.Oc = OutputChange{} - b += OutputChangeRead(buf[b:], &v.Oc) - - b = 0 // re-read the same bytes - v.Op = OutputProperty{} - b += OutputPropertyRead(buf[b:], &v.Op) - - return 28 + return b } -// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values. -func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { +// RefreshRatesReadList reads a byte slice into a list of RefreshRates values. +func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = NotifyDataUnion{} - b += NotifyDataUnionRead(buf[b:], &dest[i]) + dest[i] = RefreshRates{} + b += RefreshRatesRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a NotifyDataUnion value to a byte slice. -// Each field in a union must contain the same data. -// So simply pick the first field and write that to the wire. -func (v NotifyDataUnion) Bytes() []byte { - buf := make([]byte, 28) +// Bytes writes a RefreshRates value to a byte slice. +func (v RefreshRates) Bytes() []byte { + buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) b := 0 - { - structBytes := v.Cc.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + xgb.Put16(buf[b:], v.NRates) + b += 2 + + for i := 0; i < int(v.NRates); i++ { + xgb.Put16(buf[b:], v.Rates[i]) + b += 2 } + b = xgb.Pad(b) + return buf } -// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. -func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { +// RefreshRatesListBytes writes a list of RefreshRates values to a byte slice. +func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { b := 0 - var unionBytes []byte + var structBytes []byte for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } return b } +// RefreshRatesListSize computes the size (bytes) of a list of RefreshRates values. +func RefreshRatesListSize(list []RefreshRates) int { + size := 0 + for _, item := range list { + size += (2 + xgb.Pad((int(item.NRates) * 2))) + } + return size +} + +const ( + RotationRotate0 = 1 + RotationRotate90 = 2 + RotationRotate180 = 4 + RotationRotate270 = 8 + RotationReflectX = 16 + RotationReflectY = 32 +) + // ScreenChangeNotify is the event number for a ScreenChangeNotifyEvent. const ScreenChangeNotify = 0 @@ -1007,251 +1114,356 @@ func init() { xgb.NewExtEventFuncs["RANDR"][0] = ScreenChangeNotifyEventNew } -// Notify is the event number for a NotifyEvent. -const Notify = 1 - -type NotifyEvent struct { - Sequence uint16 - SubCode byte - U NotifyDataUnion +type ScreenSize struct { + Width uint16 + Height uint16 + Mwidth uint16 + Mheight uint16 } -// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. -func NotifyEventNew(buf []byte) xgb.Event { - v := NotifyEvent{} - b := 1 // don't read event number +// ScreenSizeRead reads a byte slice into a ScreenSize value. +func ScreenSizeRead(buf []byte, v *ScreenSize) int { + b := 0 - v.SubCode = buf[b] - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Height = xgb.Get16(buf[b:]) b += 2 - v.U = NotifyDataUnion{} - b += NotifyDataUnionRead(buf[b:], &v.U) + v.Mwidth = xgb.Get16(buf[b:]) + b += 2 - return v + v.Mheight = xgb.Get16(buf[b:]) + b += 2 + + return b } -// Bytes writes a NotifyEvent value to a byte slice. -func (v NotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// ScreenSizeReadList reads a byte slice into a list of ScreenSize values. +func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenSize{} + b += ScreenSizeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 1 - b += 1 +// Bytes writes a ScreenSize value to a byte slice. +func (v ScreenSize) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - buf[b] = v.SubCode - b += 1 + xgb.Put16(buf[b:], v.Width) + b += 2 - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.Height) + b += 2 - { - unionBytes := v.U.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) - } + xgb.Put16(buf[b:], v.Mwidth) + b += 2 + + xgb.Put16(buf[b:], v.Mheight) + b += 2 return buf } -// SequenceId returns the sequence id attached to the Notify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v NotifyEvent) SequenceId() uint16 { - return v.Sequence +// ScreenSizeListBytes writes a list of ScreenSize values to a byte slice. +func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of NotifyEvent. -func (v NotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode)) - return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +const ( + SetConfigSuccess = 0 + SetConfigInvalidConfigTime = 1 + SetConfigInvalidTime = 2 + SetConfigFailed = 3 +) -func init() { - xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew -} +// Skipping definition for base type 'Bool' -// BadBadOutput is the error number for a BadBadOutput. -const BadBadOutput = 0 +// Skipping definition for base type 'Byte' -type BadOutputError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Card8' -// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. -func BadOutputErrorNew(buf []byte) xgb.Error { - v := BadOutputError{} - v.NiceName = "BadOutput" +// Skipping definition for base type 'Char' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Void' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Double' - return v -} +// Skipping definition for base type 'Float' -// SequenceId returns the sequence id attached to the BadBadOutput error. -// This is mostly used internally. -func (err BadOutputError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Int16' -// BadId returns the 'BadValue' number if one exists for the BadBadOutput error. If no bad value exists, 0 is returned. -func (err BadOutputError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Int32' -// Error returns a rudimentary string representation of the BadBadOutput error. +// Skipping definition for base type 'Int8' -func (err BadOutputError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadOutput {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// AddOutputModeCookie is a cookie used only for AddOutputMode requests. +type AddOutputModeCookie struct { + *xgb.Cookie } -func init() { - xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew +// AddOutputMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} } -// BadBadCrtc is the error number for a BadBadCrtc. -const BadBadCrtc = 1 +// AddOutputModeChecked sends a checked request. +// If an error occurs, it can be retrieved using AddOutputModeCookie.Check() +func AddOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} +} -type BadCrtcError struct { - Sequence uint16 - NiceName string +// 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 AddOutputModeCookie) Check() error { + return cook.Cookie.Check() } -// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice. -func BadCrtcErrorNew(buf []byte) xgb.Error { - v := BadCrtcError{} - v.NiceName = "BadCrtc" +// Write request to wire for AddOutputMode +// addOutputModeRequest writes a AddOutputMode request to a byte slice. +func addOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { + size := 12 + b := 0 + buf := make([]byte, size) - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = c.Extensions["RANDR"] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return v -} + xgb.Put32(buf[b:], uint32(Output)) + b += 4 -// SequenceId returns the sequence id attached to the BadBadCrtc error. -// This is mostly used internally. -func (err BadCrtcError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 -// BadId returns the 'BadValue' number if one exists for the BadBadCrtc error. If no bad value exists, 0 is returned. -func (err BadCrtcError) BadId() uint32 { - return 0 + return buf } -// Error returns a rudimentary string representation of the BadBadCrtc error. - -func (err BadCrtcError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadCrtc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. +type ChangeOutputPropertyCookie struct { + *xgb.Cookie } -func init() { - xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew +// ChangeOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} } -// BadBadMode is the error number for a BadBadMode. -const BadBadMode = 2 +// ChangeOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeOutputPropertyCookie.Check() +func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} +} -type BadModeError struct { - Sequence uint16 - NiceName string +// 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 ChangeOutputPropertyCookie) Check() error { + return cook.Cookie.Check() } -// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. -func BadModeErrorNew(buf []byte) xgb.Error { - v := BadModeError{} - v.NiceName = "BadMode" +// Write request to wire for ChangeOutputProperty +// changeOutputPropertyRequest writes a ChangeOutputProperty request to a byte slice. +func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) + b := 0 + buf := make([]byte, size) - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = c.Extensions["RANDR"] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return v + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + buf[b] = Mode + b += 1 + + b += 2 // padding + + xgb.Put32(buf[b:], NumUnits) + b += 4 + + copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) + b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) + + return buf } -// SequenceId returns the sequence id attached to the BadBadMode error. -// This is mostly used internally. -func (err BadModeError) SequenceId() uint16 { - return err.Sequence +// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. +type ConfigureOutputPropertyCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadBadMode error. If no bad value exists, 0 is returned. -func (err BadModeError) BadId() uint32 { - return 0 +// ConfigureOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} } -// Error returns a rudimentary string representation of the BadBadMode error. +// ConfigureOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ConfigureOutputPropertyCookie.Check() +func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} +} -func (err BadModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// 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 ConfigureOutputPropertyCookie) Check() error { + return cook.Cookie.Check() } -func init() { - xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew +// Write request to wire for ConfigureOutputProperty +// configureOutputPropertyRequest writes a ConfigureOutputProperty request to a byte slice. +func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 12 // 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(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + if Pending { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Range { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// CreateModeCookie is a cookie used only for CreateMode requests. +type CreateModeCookie 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +// CreateMode sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateModeCookie.Reply() +func CreateMode(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// CreateModeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// CreateModeReply represents the data returned from a CreateMode request. +type CreateModeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + Mode Mode + // padding: 20 bytes } -// 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 CreateMode request. +func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1259,12 +1471,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return createModeReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// createModeReply reads a byte slice into a CreateModeReply value. +func createModeReply(buf []byte) *CreateModeReply { + v := new(CreateModeReply) b := 1 // skip reply determinant b += 1 // padding @@ -1275,270 +1487,257 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) + v.Mode = Mode(xgb.Get32(buf[b:])) b += 4 - b += 16 // padding + b += 20 // padding return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 +// Write request to wire for CreateMode +// createModeRequest writes a CreateMode request to a byte slice. +func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], MajorVersion) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], MinorVersion) - b += 4 + { + structBytes := ModeInfo.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + copy(buf[b:], Name[:len(Name)]) + b += xgb.Pad(int(len(Name))) return buf } -// SetScreenConfigCookie is a cookie used only for SetScreenConfig requests. -type SetScreenConfigCookie struct { +// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. +type DeleteOutputModeCookie struct { *xgb.Cookie } -// SetScreenConfig sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetScreenConfigCookie.Reply() -func SetScreenConfig(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { +// DeleteOutputMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DeleteOutputMode(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return SetScreenConfigCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} } -// SetScreenConfigUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetScreenConfigUnchecked(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { +// DeleteOutputModeChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteOutputModeCookie.Check() +func DeleteOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return SetScreenConfigCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} } -// SetScreenConfigReply represents the data returned from a SetScreenConfig request. -type SetScreenConfigReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte - NewTimestamp xproto.Timestamp - ConfigTimestamp xproto.Timestamp - Root xproto.Window - SubpixelOrder uint16 - // padding: 10 bytes +// 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 DeleteOutputModeCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a SetScreenConfig request. -func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setScreenConfigReply(buf), nil -} +// Write request to wire for DeleteOutputMode +// deleteOutputModeRequest writes a DeleteOutputMode request to a byte slice. +func deleteOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { + size := 12 + b := 0 + buf := make([]byte, size) -// setScreenConfigReply reads a byte slice into a SetScreenConfigReply value. -func setScreenConfigReply(buf []byte) *SetScreenConfigReply { - v := new(SetScreenConfigReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["RANDR"] + b += 1 - v.Status = buf[b] + buf[b] = 19 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Output)) b += 4 - v.NewTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Mode)) b += 4 - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + return buf +} - v.Root = xproto.Window(xgb.Get32(buf[b:])) - b += 4 +// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. +type DeleteOutputPropertyCookie struct { + *xgb.Cookie +} - v.SubpixelOrder = xgb.Get16(buf[b:]) - b += 2 +// DeleteOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DeleteOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) + return DeleteOutputPropertyCookie{cookie} +} - b += 10 // padding +// DeleteOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteOutputPropertyCookie.Check() +func DeleteOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) + return DeleteOutputPropertyCookie{cookie} +} - 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 DeleteOutputPropertyCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for SetScreenConfig -// setScreenConfigRequest writes a SetScreenConfig request to a byte slice. -func setScreenConfigRequest(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte { - size := 24 +// Write request to wire for DeleteOutputProperty +// deleteOutputPropertyRequest writes a DeleteOutputProperty request to a byte slice. +func deleteOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Timestamp)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + xgb.Put32(buf[b:], uint32(Property)) b += 4 - xgb.Put16(buf[b:], SizeID) - b += 2 - - xgb.Put16(buf[b:], Rotation) - b += 2 - - xgb.Put16(buf[b:], Rate) - b += 2 - - b += 2 // padding - return buf } -// SelectInputCookie is a cookie used only for SelectInput requests. -type SelectInputCookie struct { +// DestroyModeCookie is a cookie used only for DestroyMode requests. +type DestroyModeCookie struct { *xgb.Cookie } -// SelectInput sends an unchecked request. +// DestroyMode sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { +func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(selectInputRequest(c, Window, Enable), cookie) - return SelectInputCookie{cookie} + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{cookie} } -// SelectInputChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectInputCookie.Check() -func SelectInputChecked(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { +// DestroyModeChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyModeCookie.Check() +func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(selectInputRequest(c, Window, Enable), cookie) - return SelectInputCookie{cookie} + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{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 SelectInputCookie) Check() error { +func (cook DestroyModeCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SelectInput -// selectInputRequest writes a SelectInput request to a byte slice. -func selectInputRequest(c *xgb.Conn, Window xproto.Window, Enable uint16) []byte { - size := 12 +// Write request to wire for DestroyMode +// destroyModeRequest writes a DestroyMode request to a byte slice. +func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 17 // 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)) + xgb.Put32(buf[b:], uint32(Mode)) b += 4 - xgb.Put16(buf[b:], Enable) - b += 2 - - b += 2 // padding - return buf } -// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. -type GetScreenInfoCookie struct { +// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. +type GetCrtcGammaCookie struct { *xgb.Cookie } -// GetScreenInfo sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetScreenInfoCookie.Reply() -func GetScreenInfo(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { +// GetCrtcGamma sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcGammaCookie.Reply() +func GetCrtcGamma(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getScreenInfoRequest(c, Window), cookie) - return GetScreenInfoCookie{cookie} + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} } -// GetScreenInfoUnchecked sends an unchecked request. +// GetCrtcGammaUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenInfoUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { +func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getScreenInfoRequest(c, Window), cookie) - return GetScreenInfoCookie{cookie} + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} } -// GetScreenInfoReply represents the data returned from a GetScreenInfo request. -type GetScreenInfoReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Rotations byte - Root xproto.Window - Timestamp xproto.Timestamp - ConfigTimestamp xproto.Timestamp - NSizes uint16 - SizeID uint16 - Rotation uint16 - Rate uint16 - NInfo uint16 - // padding: 2 bytes - Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) - Rates []RefreshRates // size: RefreshRatesListSize(Rates) +// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. +type GetCrtcGammaReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Size uint16 + // padding: 22 bytes + Red []uint16 // size: xgb.Pad((int(Size) * 2)) + Green []uint16 // size: xgb.Pad((int(Size) * 2)) + Blue []uint16 // size: xgb.Pad((int(Size) * 2)) } -// Reply blocks and returns the reply data for a GetScreenInfo request. -func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { +// Reply blocks and returns the reply data for a GetCrtcGamma request. +func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1546,16 +1745,15 @@ func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { if buf == nil { return nil, nil } - return getScreenInfoReply(buf), nil + return getCrtcGammaReply(buf), nil } -// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. -func getScreenInfoReply(buf []byte) *GetScreenInfoReply { - v := new(GetScreenInfoReply) +// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value. +func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { + v := new(GetCrtcGammaReply) b := 1 // skip reply determinant - v.Rotations = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -1563,44 +1761,38 @@ func getScreenInfoReply(buf []byte) *GetScreenInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Root = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.NSizes = xgb.Get16(buf[b:]) - b += 2 - - v.SizeID = xgb.Get16(buf[b:]) - b += 2 - - v.Rotation = xgb.Get16(buf[b:]) - b += 2 - - v.Rate = xgb.Get16(buf[b:]) + v.Size = xgb.Get16(buf[b:]) b += 2 - v.NInfo = xgb.Get16(buf[b:]) - b += 2 + b += 22 // padding - b += 2 // padding + v.Red = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Red[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) - v.Sizes = make([]ScreenSize, v.NSizes) - b += ScreenSizeReadList(buf[b:], v.Sizes) + v.Green = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Green[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) - v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes))) - b += RefreshRatesReadList(buf[b:], v.Rates) + v.Blue = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Blue[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) return v } -// Write request to wire for GetScreenInfo -// getScreenInfoRequest writes a GetScreenInfo request to a byte slice. -func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetCrtcGamma +// getCrtcGammaRequest writes a GetCrtcGamma request to a byte slice. +func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1608,59 +1800,56 @@ func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 23 // 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)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. -type GetScreenSizeRangeCookie struct { +// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. +type GetCrtcGammaSizeCookie struct { *xgb.Cookie } -// GetScreenSizeRange sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetScreenSizeRangeCookie.Reply() -func GetScreenSizeRange(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { +// GetCrtcGammaSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcGammaSizeCookie.Reply() +func GetCrtcGammaSize(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) - return GetScreenSizeRangeCookie{cookie} + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} } -// GetScreenSizeRangeUnchecked sends an unchecked request. +// GetCrtcGammaSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { +func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) - return GetScreenSizeRangeCookie{cookie} + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} } -// GetScreenSizeRangeReply represents the data returned from a GetScreenSizeRange request. -type GetScreenSizeRangeReply struct { +// GetCrtcGammaSizeReply represents the data returned from a GetCrtcGammaSize request. +type GetCrtcGammaSizeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MinWidth uint16 - MinHeight uint16 - MaxWidth uint16 - MaxHeight uint16 - // padding: 16 bytes + Size uint16 + // padding: 22 bytes } -// Reply blocks and returns the reply data for a GetScreenSizeRange request. -func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { +// Reply blocks and returns the reply data for a GetCrtcGammaSize request. +func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1668,12 +1857,12 @@ func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { if buf == nil { return nil, nil } - return getScreenSizeRangeReply(buf), nil + return getCrtcGammaSizeReply(buf), nil } -// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value. -func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { - v := new(GetScreenSizeRangeReply) +// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. +func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { + v := new(GetCrtcGammaSizeReply) b := 1 // skip reply determinant b += 1 // padding @@ -1684,26 +1873,17 @@ func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MinWidth = xgb.Get16(buf[b:]) - b += 2 - - v.MinHeight = xgb.Get16(buf[b:]) - b += 2 - - v.MaxWidth = xgb.Get16(buf[b:]) - b += 2 - - v.MaxHeight = xgb.Get16(buf[b:]) + v.Size = xgb.Get16(buf[b:]) b += 2 - b += 16 // padding + b += 22 // padding return v } -// Write request to wire for GetScreenSizeRange -// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. -func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetCrtcGammaSize +// getCrtcGammaSizeRequest writes a GetCrtcGammaSize request to a byte slice. +func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1711,132 +1891,211 @@ func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 22 // 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)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. -type SetScreenSizeCookie struct { +// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. +type GetCrtcInfoCookie struct { *xgb.Cookie } -// SetScreenSize sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { +// GetCrtcInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcInfoCookie.Reply() +func GetCrtcInfo(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) - return SetScreenSizeCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} } -// SetScreenSizeChecked sends a checked request. -// If an error occurs, it can be retrieved using SetScreenSizeCookie.Check() -func SetScreenSizeChecked(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { +// GetCrtcInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) - return SetScreenSizeCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{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 SetScreenSizeCookie) Check() error { - return cook.Cookie.Check() +// GetCrtcInfoReply represents the data returned from a GetCrtcInfo request. +type GetCrtcInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte + Timestamp xproto.Timestamp + X int16 + Y int16 + Width uint16 + Height uint16 + Mode Mode + Rotation uint16 + Rotations uint16 + NumOutputs uint16 + NumPossibleOutputs uint16 + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4)) } -// Write request to wire for SetScreenSize -// setScreenSizeRequest writes a SetScreenSize request to a byte slice. -func setScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetCrtcInfo request. +func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcInfoReply(buf), nil +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. +func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { + v := new(GetCrtcInfoReply) + b := 1 // skip reply determinant - buf[b] = 7 // request opcode + v.Status = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Window)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Width) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], Height) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put32(buf[b:], MmWidth) + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mode = Mode(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], MmHeight) + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Rotations = xgb.Get16(buf[b:]) + b += 2 + + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumPossibleOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Possible = make([]Output, v.NumPossibleOutputs) + for i := 0; i < int(v.NumPossibleOutputs); i++ { + v.Possible[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcInfo +// getCrtcInfoRequest writes a GetCrtcInfo request to a byte slice. +func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 20 // 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(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) b += 4 return buf } -// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. -type GetScreenResourcesCookie struct { +// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. +type GetCrtcTransformCookie struct { *xgb.Cookie } -// GetScreenResources sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCookie.Reply() -func GetScreenResources(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { +// GetCrtcTransform sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcTransformCookie.Reply() +func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getScreenResourcesRequest(c, Window), cookie) - return GetScreenResourcesCookie{cookie} + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} } -// GetScreenResourcesUnchecked sends an unchecked request. +// GetCrtcTransformUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { +func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getScreenResourcesRequest(c, Window), cookie) - return GetScreenResourcesCookie{cookie} + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} } -// GetScreenResourcesReply represents the data returned from a GetScreenResources request. -type GetScreenResourcesReply struct { +// GetCrtcTransformReply represents the data returned from a GetCrtcTransform request. +type GetCrtcTransformReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Timestamp xproto.Timestamp - ConfigTimestamp xproto.Timestamp - NumCrtcs uint16 - NumOutputs uint16 - NumModes uint16 - NamesLen uint16 - // padding: 8 bytes - Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) - Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) - Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) - Names []byte // size: xgb.Pad((int(NamesLen) * 1)) + PendingTransform render.Transform + HasTransforms bool + // padding: 3 bytes + CurrentTransform render.Transform + // padding: 4 bytes + PendingLen uint16 + PendingNparams uint16 + CurrentLen uint16 + CurrentNparams uint16 + PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1)) + PendingParams []render.Fixed // size: xgb.Pad((int(PendingNparams) * 4)) + CurrentFilterName string // size: xgb.Pad((int(CurrentLen) * 1)) + CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4)) } -// Reply blocks and returns the reply data for a GetScreenResources request. -func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { +// Reply blocks and returns the reply data for a GetCrtcTransform request. +func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1844,12 +2103,12 @@ func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { if buf == nil { return nil, nil } - return getScreenResourcesReply(buf), nil + return getCrtcTransformReply(buf), nil } -// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. -func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { - v := new(GetScreenResourcesReply) +// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. +func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { + v := new(GetCrtcTransformReply) b := 1 // skip reply determinant b += 1 // padding @@ -1860,53 +2119,69 @@ func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + v.PendingTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.PendingTransform) - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + if buf[b] == 1 { + v.HasTransforms = true + } else { + v.HasTransforms = false + } + b += 1 - v.NumCrtcs = xgb.Get16(buf[b:]) + b += 3 // padding + + v.CurrentTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.CurrentTransform) + + b += 4 // padding + + v.PendingLen = xgb.Get16(buf[b:]) b += 2 - v.NumOutputs = xgb.Get16(buf[b:]) + v.PendingNparams = xgb.Get16(buf[b:]) b += 2 - v.NumModes = xgb.Get16(buf[b:]) + v.CurrentLen = xgb.Get16(buf[b:]) b += 2 - v.NamesLen = xgb.Get16(buf[b:]) + v.CurrentNparams = xgb.Get16(buf[b:]) b += 2 - b += 8 // padding + { + byteString := make([]byte, v.PendingLen) + copy(byteString[:v.PendingLen], buf[b:]) + v.PendingFilterName = string(byteString) + b += xgb.Pad(int(v.PendingLen)) + } - v.Crtcs = make([]Crtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + v.PendingParams = make([]render.Fixed, v.PendingNparams) + for i := 0; i < int(v.PendingNparams); i++ { + v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) - v.Outputs = make([]Output, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Output(xgb.Get32(buf[b:])) + { + byteString := make([]byte, v.CurrentLen) + copy(byteString[:v.CurrentLen], buf[b:]) + v.CurrentFilterName = string(byteString) + b += xgb.Pad(int(v.CurrentLen)) + } + + v.CurrentParams = make([]render.Fixed, v.CurrentNparams) + for i := 0; i < int(v.CurrentNparams); i++ { + v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) - v.Modes = make([]ModeInfo, v.NumModes) - b += ModeInfoReadList(buf[b:], v.Modes) - - v.Names = make([]byte, v.NamesLen) - copy(v.Names[:v.NamesLen], buf[b:]) - b += xgb.Pad(int(v.NamesLen)) - return v } -// Write request to wire for GetScreenResources -// getScreenResourcesRequest writes a GetScreenResources request to a byte slice. -func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetCrtcTransform +// getCrtcTransformRequest writes a GetCrtcTransform request to a byte slice. +func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1914,13 +2189,13 @@ func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 27 // 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)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf @@ -2087,45 +2362,43 @@ func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Tim return buf } -// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. -type ListOutputPropertiesCookie struct { +// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. +type GetOutputPrimaryCookie struct { *xgb.Cookie } -// ListOutputProperties sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListOutputPropertiesCookie.Reply() -func ListOutputProperties(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { +// GetOutputPrimary sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOutputPrimaryCookie.Reply() +func GetOutputPrimary(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) - return ListOutputPropertiesCookie{cookie} + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} } -// ListOutputPropertiesUnchecked sends an unchecked request. +// GetOutputPrimaryUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { +func GetOutputPrimaryUnchecked(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) - return ListOutputPropertiesCookie{cookie} + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} } -// ListOutputPropertiesReply represents the data returned from a ListOutputProperties request. -type ListOutputPropertiesReply struct { +// GetOutputPrimaryReply represents the data returned from a GetOutputPrimary request. +type GetOutputPrimaryReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumAtoms uint16 - // padding: 22 bytes - Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4)) + Output Output } -// Reply blocks and returns the reply data for a ListOutputProperties request. -func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { +// Reply blocks and returns the reply data for a GetOutputPrimary request. +func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2133,12 +2406,12 @@ func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, erro if buf == nil { return nil, nil } - return listOutputPropertiesReply(buf), nil + return getOutputPrimaryReply(buf), nil } -// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value. -func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { - v := new(ListOutputPropertiesReply) +// getOutputPrimaryReply reads a byte slice into a GetOutputPrimaryReply value. +func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { + v := new(GetOutputPrimaryReply) b := 1 // skip reply determinant b += 1 // padding @@ -2149,24 +2422,15 @@ func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAtoms = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Atoms = make([]xproto.Atom, v.NumAtoms) - for i := 0; i < int(v.NumAtoms); i++ { - v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + v.Output = Output(xgb.Get32(buf[b:])) + b += 4 return v } -// Write request to wire for ListOutputProperties -// listOutputPropertiesRequest writes a ListOutputProperties request to a byte slice. -func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { +// Write request to wire for GetOutputPrimary +// getOutputPrimaryRequest writes a GetOutputPrimary request to a byte slice. +func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -2174,59 +2438,59 @@ func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 31 // 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(Output)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests. -type QueryOutputPropertyCookie struct { +// GetOutputPropertyCookie is a cookie used only for GetOutputProperty requests. +type GetOutputPropertyCookie struct { *xgb.Cookie } -// QueryOutputProperty sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryOutputPropertyCookie.Reply() -func QueryOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { +// GetOutputProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOutputPropertyCookie.Reply() +func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) - return QueryOutputPropertyCookie{cookie} + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} } -// QueryOutputPropertyUnchecked sends an unchecked request. +// GetOutputPropertyUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { +func GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) - return QueryOutputPropertyCookie{cookie} + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} } -// QueryOutputPropertyReply represents the data returned from a QueryOutputProperty request. -type QueryOutputPropertyReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Pending bool - Range bool - Immutable bool - // padding: 21 bytes - ValidValues []int32 // size: xgb.Pad((int(Length) * 4)) +// GetOutputPropertyReply represents the data returned from a GetOutputProperty request. +type GetOutputPropertyReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Format byte + Type xproto.Atom + BytesAfter uint32 + NumItems uint32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1)) } -// Reply blocks and returns the reply data for a QueryOutputProperty request. -func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) { +// Reply blocks and returns the reply data for a GetOutputProperty request. +func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2234,15 +2498,16 @@ func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) if buf == nil { return nil, nil } - return queryOutputPropertyReply(buf), nil + return getOutputPropertyReply(buf), nil } -// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value. -func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { - v := new(QueryOutputPropertyReply) +// getOutputPropertyReply reads a byte slice into a GetOutputPropertyReply value. +func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { + v := new(GetOutputPropertyReply) b := 1 // skip reply determinant - b += 1 // padding + v.Format = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2250,50 +2515,35 @@ func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - if buf[b] == 1 { - v.Pending = true - } else { - v.Pending = false - } - b += 1 + v.Type = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 - if buf[b] == 1 { - v.Range = true - } else { - v.Range = false - } - b += 1 + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 - if buf[b] == 1 { - v.Immutable = true - } else { - v.Immutable = false - } - b += 1 + v.NumItems = xgb.Get32(buf[b:]) + b += 4 - b += 21 // padding + b += 12 // padding - v.ValidValues = make([]int32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.ValidValues[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) + copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8)))) return v } -// Write request to wire for QueryOutputProperty -// queryOutputPropertyRequest writes a QueryOutputProperty request to a byte slice. -func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { - size := 12 +// Write request to wire for GetOutputProperty +// getOutputPropertyRequest writes a GetOutputProperty request to a byte slice. +func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { + size := 28 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 15 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2305,72 +2555,23 @@ func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom xgb.Put32(buf[b:], uint32(Property)) b += 4 - return buf -} - -// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. -type ConfigureOutputPropertyCookie struct { - *xgb.Cookie -} - -// ConfigureOutputProperty sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) - return ConfigureOutputPropertyCookie{cookie} -} - -// ConfigureOutputPropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using ConfigureOutputPropertyCookie.Check() -func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) - return ConfigureOutputPropertyCookie{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 ConfigureOutputPropertyCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ConfigureOutputProperty -// configureOutputPropertyRequest writes a ConfigureOutputProperty request to a byte slice. -func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - b += 1 - - buf[b] = 12 // 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(Type)) + b += 4 - xgb.Put32(buf[b:], uint32(Output)) + xgb.Put32(buf[b:], LongOffset) b += 4 - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], LongLength) b += 4 - if Pending { + if Delete { buf[b] = 1 } else { buf[b] = 0 } b += 1 - if Range { + if Pending { buf[b] = 1 } else { buf[b] = 0 @@ -2379,189 +2580,193 @@ func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto. b += 2 // padding - for i := 0; i < int(len(Values)); i++ { - xgb.Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. -type ChangeOutputPropertyCookie struct { +// GetPanningCookie is a cookie used only for GetPanning requests. +type GetPanningCookie struct { *xgb.Cookie } -// ChangeOutputProperty sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { +// GetPanning sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPanningCookie.Reply() +func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} } -// ChangeOutputPropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeOutputPropertyCookie.Check() -func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { +// GetPanningUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{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 ChangeOutputPropertyCookie) Check() error { - return cook.Cookie.Check() +// GetPanningReply represents the data returned from a GetPanning request. +type GetPanningReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte + Timestamp xproto.Timestamp + Left uint16 + Top uint16 + Width uint16 + Height uint16 + TrackLeft uint16 + TrackTop uint16 + TrackWidth uint16 + TrackHeight uint16 + BorderLeft int16 + BorderTop int16 + BorderRight int16 + BorderBottom int16 } -// Write request to wire for ChangeOutputProperty -// changeOutputPropertyRequest writes a ChangeOutputProperty request to a byte slice. -func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte { - size := xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetPanning request. +func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPanningReply(buf), nil +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// getPanningReply reads a byte slice into a GetPanningReply value. +func getPanningReply(buf []byte) *GetPanningReply { + v := new(GetPanningReply) + b := 1 // skip reply determinant - buf[b] = 13 // request opcode + v.Status = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Output)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Property)) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], uint32(Type)) - b += 4 + v.Left = xgb.Get16(buf[b:]) + b += 2 - buf[b] = Format - b += 1 + v.Top = xgb.Get16(buf[b:]) + b += 2 - buf[b] = Mode - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - b += 2 // padding + v.Height = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], NumUnits) - b += 4 + v.TrackLeft = xgb.Get16(buf[b:]) + b += 2 - copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) - b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) + v.TrackTop = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.TrackWidth = xgb.Get16(buf[b:]) + b += 2 -// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. -type DeleteOutputPropertyCookie struct { - *xgb.Cookie -} + v.TrackHeight = xgb.Get16(buf[b:]) + b += 2 -// DeleteOutputProperty sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) - return DeleteOutputPropertyCookie{cookie} -} + v.BorderLeft = int16(xgb.Get16(buf[b:])) + b += 2 -// DeleteOutputPropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteOutputPropertyCookie.Check() -func DeleteOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) - return DeleteOutputPropertyCookie{cookie} -} + v.BorderTop = int16(xgb.Get16(buf[b:])) + b += 2 -// 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 DeleteOutputPropertyCookie) Check() error { - return cook.Cookie.Check() + v.BorderRight = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderBottom = int16(xgb.Get16(buf[b:])) + b += 2 + + return v } -// Write request to wire for DeleteOutputProperty -// deleteOutputPropertyRequest writes a DeleteOutputProperty request to a byte slice. -func deleteOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { - size := 12 +// Write request to wire for GetPanning +// getPanningRequest writes a GetPanning request to a byte slice. +func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 28 // 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// GetOutputPropertyCookie is a cookie used only for GetOutputProperty requests. -type GetOutputPropertyCookie struct { +// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. +type GetScreenInfoCookie struct { *xgb.Cookie } -// GetOutputProperty sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetOutputPropertyCookie.Reply() -func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { +// GetScreenInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenInfoCookie.Reply() +func GetScreenInfo(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return GetOutputPropertyCookie{cookie} + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{cookie} } -// GetOutputPropertyUnchecked sends an unchecked request. +// GetScreenInfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { +func GetScreenInfoUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return GetOutputPropertyCookie{cookie} + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{cookie} } -// GetOutputPropertyReply represents the data returned from a GetOutputProperty request. -type GetOutputPropertyReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Format byte - Type xproto.Atom - BytesAfter uint32 - NumItems uint32 - // padding: 12 bytes - Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1)) +// GetScreenInfoReply represents the data returned from a GetScreenInfo request. +type GetScreenInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Rotations byte + Root xproto.Window + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NSizes uint16 + SizeID uint16 + Rotation uint16 + Rate uint16 + NInfo uint16 + // padding: 2 bytes + Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) + Rates []RefreshRates // size: RefreshRatesListSize(Rates) } -// Reply blocks and returns the reply data for a GetOutputProperty request. -func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { +// Reply blocks and returns the reply data for a GetScreenInfo request. +func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2569,15 +2774,15 @@ func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { if buf == nil { return nil, nil } - return getOutputPropertyReply(buf), nil + return getScreenInfoReply(buf), nil } -// getOutputPropertyReply reads a byte slice into a GetOutputPropertyReply value. -func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { - v := new(GetOutputPropertyReply) +// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. +func getScreenInfoReply(buf []byte) *GetScreenInfoReply { + v := new(GetScreenInfoReply) b := 1 // skip reply determinant - v.Format = buf[b] + v.Rotations = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -2586,112 +2791,110 @@ func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Type = xproto.Atom(xgb.Get32(buf[b:])) + v.Root = xproto.Window(xgb.Get32(buf[b:])) b += 4 - v.BytesAfter = xgb.Get32(buf[b:]) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.NumItems = xgb.Get32(buf[b:]) + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - b += 12 // padding + v.NSizes = xgb.Get16(buf[b:]) + b += 2 - v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) - copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) - b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8)))) + v.SizeID = xgb.Get16(buf[b:]) + b += 2 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Rate = xgb.Get16(buf[b:]) + b += 2 + + v.NInfo = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Sizes = make([]ScreenSize, v.NSizes) + b += ScreenSizeReadList(buf[b:], v.Sizes) + + v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes))) + b += RefreshRatesReadList(buf[b:], v.Rates) return v } -// Write request to wire for GetOutputProperty -// getOutputPropertyRequest writes a GetOutputProperty request to a byte slice. -func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { - size := 28 +// Write request to wire for GetScreenInfo +// getScreenInfoRequest writes a GetScreenInfo request to a byte slice. +func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 15 // request opcode + 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:], uint32(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - xgb.Put32(buf[b:], uint32(Type)) - b += 4 - - xgb.Put32(buf[b:], LongOffset) - b += 4 - - xgb.Put32(buf[b:], LongLength) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - return buf } -// CreateModeCookie is a cookie used only for CreateMode requests. -type CreateModeCookie struct { +// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. +type GetScreenResourcesCookie struct { *xgb.Cookie } -// CreateMode sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateModeCookie.Reply() -func CreateMode(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { +// GetScreenResources sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCookie.Reply() +func GetScreenResources(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) - return CreateModeCookie{cookie} + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} } -// CreateModeUnchecked sends an unchecked request. +// GetScreenResourcesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { +func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) - return CreateModeCookie{cookie} + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} } -// CreateModeReply represents the data returned from a CreateMode request. -type CreateModeReply struct { +// GetScreenResourcesReply represents the data returned from a GetScreenResources request. +type GetScreenResourcesReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Mode Mode - // padding: 20 bytes + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NumCrtcs uint16 + NumOutputs uint16 + NumModes uint16 + NamesLen uint16 + // padding: 8 bytes + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) } -// Reply blocks and returns the reply data for a CreateMode request. -func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { +// Reply blocks and returns the reply data for a GetScreenResources request. +func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2699,12 +2902,12 @@ func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { if buf == nil { return nil, nil } - return createModeReply(buf), nil + return getScreenResourcesReply(buf), nil } -// createModeReply reads a byte slice into a CreateModeReply value. -func createModeReply(buf []byte) *CreateModeReply { - v := new(CreateModeReply) +// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. +func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { + v := new(GetScreenResourcesReply) b := 1 // skip reply determinant b += 1 // padding @@ -2715,81 +2918,53 @@ func createModeReply(buf []byte) *CreateModeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Mode = Mode(xgb.Get32(buf[b:])) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - b += 20 // padding - - return v -} + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// Write request to wire for CreateMode -// createModeRequest writes a CreateMode request to a byte slice. -func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) []byte { - size := xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) - b := 0 - buf := make([]byte, size) + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 - buf[b] = c.Extensions["RANDR"] - b += 1 + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 - buf[b] = 16 // request opcode - b += 1 + v.NumModes = xgb.Get16(buf[b:]) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.NamesLen = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 + b += 8 // padding - { - structBytes := ModeInfo.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 } + b = xgb.Pad(b) - copy(buf[b:], Name[:len(Name)]) - b += xgb.Pad(int(len(Name))) - - return buf -} - -// DestroyModeCookie is a cookie used only for DestroyMode requests. -type DestroyModeCookie struct { - *xgb.Cookie -} - -// DestroyMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyModeRequest(c, Mode), cookie) - return DestroyModeCookie{cookie} -} + b = xgb.Pad(b) -// DestroyModeChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyModeCookie.Check() -func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyModeRequest(c, Mode), cookie) - return DestroyModeCookie{cookie} -} + v.Modes = make([]ModeInfo, v.NumModes) + b += ModeInfoReadList(buf[b:], v.Modes) -// 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 DestroyModeCookie) Check() error { - return cook.Cookie.Check() + v.Names = make([]byte, v.NamesLen) + copy(v.Names[:v.NamesLen], buf[b:]) + b += xgb.Pad(int(v.NamesLen)) + + return v } -// Write request to wire for DestroyMode -// destroyModeRequest writes a DestroyMode request to a byte slice. -func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { +// Write request to wire for GetScreenResources +// getScreenResourcesRequest writes a GetScreenResources request to a byte slice. +func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -2797,182 +2972,195 @@ func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 17 // request opcode + 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:], uint32(Mode)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// AddOutputModeCookie is a cookie used only for AddOutputMode requests. -type AddOutputModeCookie struct { +// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. +type GetScreenResourcesCurrentCookie struct { *xgb.Cookie } -// AddOutputMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { +// GetScreenResourcesCurrent sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCurrentCookie.Reply() +func GetScreenResourcesCurrent(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) - return AddOutputModeCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} } -// AddOutputModeChecked sends a checked request. -// If an error occurs, it can be retrieved using AddOutputModeCookie.Check() -func AddOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { +// GetScreenResourcesCurrentUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) - return AddOutputModeCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{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 AddOutputModeCookie) Check() error { - return cook.Cookie.Check() +// GetScreenResourcesCurrentReply represents the data returned from a GetScreenResourcesCurrent request. +type GetScreenResourcesCurrentReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NumCrtcs uint16 + NumOutputs uint16 + NumModes uint16 + NamesLen uint16 + // padding: 8 bytes + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) } -// Write request to wire for AddOutputMode -// addOutputModeRequest writes a AddOutputMode request to a byte slice. -func addOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { - size := 12 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetScreenResourcesCurrent request. +func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenResourcesCurrentReply(buf), nil +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. +func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { + v := new(GetScreenResourcesCurrentReply) + b := 1 // skip reply determinant - buf[b] = 18 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Output)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Mode)) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - return buf -} + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. -type DeleteOutputModeCookie struct { - *xgb.Cookie -} + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 -// DeleteOutputMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteOutputMode(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumModes = xgb.Get16(buf[b:]) + b += 2 + + v.NamesLen = xgb.Get16(buf[b:]) + b += 2 + + b += 8 // padding + + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) - return DeleteOutputModeCookie{cookie} -} + b = xgb.Pad(b) -// DeleteOutputModeChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteOutputModeCookie.Check() -func DeleteOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) - return DeleteOutputModeCookie{cookie} -} + b = xgb.Pad(b) -// 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 DeleteOutputModeCookie) Check() error { - return cook.Cookie.Check() + v.Modes = make([]ModeInfo, v.NumModes) + b += ModeInfoReadList(buf[b:], v.Modes) + + v.Names = make([]byte, v.NamesLen) + copy(v.Names[:v.NamesLen], buf[b:]) + b += xgb.Pad(int(v.NamesLen)) + + return v } -// Write request to wire for DeleteOutputMode -// deleteOutputModeRequest writes a DeleteOutputMode request to a byte slice. -func deleteOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { - size := 12 +// Write request to wire for GetScreenResourcesCurrent +// getScreenResourcesCurrentRequest writes a GetScreenResourcesCurrent request to a byte slice. +func getScreenResourcesCurrentRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 25 // 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mode)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. -type GetCrtcInfoCookie struct { +// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. +type GetScreenSizeRangeCookie struct { *xgb.Cookie } -// GetCrtcInfo sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCrtcInfoCookie.Reply() -func GetCrtcInfo(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { +// GetScreenSizeRange sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenSizeRangeCookie.Reply() +func GetScreenSizeRange(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) - return GetCrtcInfoCookie{cookie} + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} } -// GetCrtcInfoUnchecked sends an unchecked request. +// GetScreenSizeRangeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { +func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) - return GetCrtcInfoCookie{cookie} + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} } -// GetCrtcInfoReply represents the data returned from a GetCrtcInfo request. -type GetCrtcInfoReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte - Timestamp xproto.Timestamp - X int16 - Y int16 - Width uint16 - Height uint16 - Mode Mode - Rotation uint16 - Rotations uint16 - NumOutputs uint16 - NumPossibleOutputs uint16 - Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) - Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4)) +// GetScreenSizeRangeReply represents the data returned from a GetScreenSizeRange request. +type GetScreenSizeRangeReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MinWidth uint16 + MinHeight uint16 + MaxWidth uint16 + MaxHeight uint16 + // padding: 16 bytes } -// Reply blocks and returns the reply data for a GetCrtcInfo request. -func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { +// Reply blocks and returns the reply data for a GetScreenSizeRange request. +func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2980,16 +3168,15 @@ func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { if buf == nil { return nil, nil } - return getCrtcInfoReply(buf), nil + return getScreenSizeRangeReply(buf), nil } -// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. -func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { - v := new(GetCrtcInfoReply) +// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value. +func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { + v := new(GetScreenSizeRangeReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2997,116 +3184,84 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.Mode = Mode(xgb.Get32(buf[b:])) - b += 4 - - v.Rotation = xgb.Get16(buf[b:]) + v.MinWidth = xgb.Get16(buf[b:]) b += 2 - v.Rotations = xgb.Get16(buf[b:]) + v.MinHeight = xgb.Get16(buf[b:]) b += 2 - v.NumOutputs = xgb.Get16(buf[b:]) + v.MaxWidth = xgb.Get16(buf[b:]) b += 2 - v.NumPossibleOutputs = xgb.Get16(buf[b:]) + v.MaxHeight = xgb.Get16(buf[b:]) b += 2 - v.Outputs = make([]Output, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Output(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - v.Possible = make([]Output, v.NumPossibleOutputs) - for i := 0; i < int(v.NumPossibleOutputs); i++ { - v.Possible[i] = Output(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + b += 16 // padding return v } -// Write request to wire for GetCrtcInfo -// getCrtcInfoRequest writes a GetCrtcInfo request to a byte slice. -func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte { - size := 12 +// Write request to wire for GetScreenSizeRange +// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. +func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 20 // request opcode + 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:], uint32(Crtc)) - b += 4 - - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// SetCrtcConfigCookie is a cookie used only for SetCrtcConfig requests. -type SetCrtcConfigCookie struct { +// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. +type ListOutputPropertiesCookie struct { *xgb.Cookie } -// SetCrtcConfig sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetCrtcConfigCookie.Reply() -func SetCrtcConfig(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { +// ListOutputProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListOutputPropertiesCookie.Reply() +func ListOutputProperties(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return SetCrtcConfigCookie{cookie} + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} } -// SetCrtcConfigUnchecked sends an unchecked request. +// ListOutputPropertiesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { +func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return SetCrtcConfigCookie{cookie} + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} } -// SetCrtcConfigReply represents the data returned from a SetCrtcConfig request. -type SetCrtcConfigReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte - Timestamp xproto.Timestamp - // padding: 20 bytes +// ListOutputPropertiesReply represents the data returned from a ListOutputProperties request. +type ListOutputPropertiesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumAtoms uint16 + // padding: 22 bytes + Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4)) } -// Reply blocks and returns the reply data for a SetCrtcConfig request. -func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { +// Reply blocks and returns the reply data for a ListOutputProperties request. +func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3114,16 +3269,15 @@ func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { if buf == nil { return nil, nil } - return setCrtcConfigReply(buf), nil + return listOutputPropertiesReply(buf), nil } -// setCrtcConfigReply reads a byte slice into a SetCrtcConfigReply value. -func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { - v := new(SetCrtcConfigReply) +// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value. +func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { + v := new(ListOutputPropertiesReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3131,100 +3285,84 @@ func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + v.NumAtoms = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding + b += 22 // padding + + v.Atoms = make([]xproto.Atom, v.NumAtoms) + for i := 0; i < int(v.NumAtoms); i++ { + v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for SetCrtcConfig -// setCrtcConfigRequest writes a SetCrtcConfig request to a byte slice. -func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) []byte { - size := xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) +// Write request to wire for ListOutputProperties +// listOutputPropertiesRequest writes a ListOutputProperties request to a byte slice. +func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 21 // request opcode + 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:], uint32(Crtc)) - b += 4 - - xgb.Put32(buf[b:], uint32(Timestamp)) - b += 4 - - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - xgb.Put32(buf[b:], uint32(Mode)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 - xgb.Put16(buf[b:], Rotation) - b += 2 - - b += 2 // padding - - for i := 0; i < int(len(Outputs)); i++ { - xgb.Put32(buf[b:], uint32(Outputs[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. -type GetCrtcGammaSizeCookie struct { +// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests. +type QueryOutputPropertyCookie struct { *xgb.Cookie } -// GetCrtcGammaSize sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCrtcGammaSizeCookie.Reply() -func GetCrtcGammaSize(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { +// QueryOutputProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryOutputPropertyCookie.Reply() +func QueryOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) - return GetCrtcGammaSizeCookie{cookie} + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{cookie} } -// GetCrtcGammaSizeUnchecked sends an unchecked request. +// QueryOutputPropertyUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { +func QueryOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) - return GetCrtcGammaSizeCookie{cookie} + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{cookie} } -// GetCrtcGammaSizeReply represents the data returned from a GetCrtcGammaSize request. -type GetCrtcGammaSizeReply struct { +// QueryOutputPropertyReply represents the data returned from a QueryOutputProperty request. +type QueryOutputPropertyReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Size uint16 - // padding: 22 bytes + Pending bool + Range bool + Immutable bool + // padding: 21 bytes + ValidValues []int32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a GetCrtcGammaSize request. -func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { +// Reply blocks and returns the reply data for a QueryOutputProperty request. +func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3232,12 +3370,12 @@ func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { if buf == nil { return nil, nil } - return getCrtcGammaSizeReply(buf), nil + return queryOutputPropertyReply(buf), nil } -// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. -func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { - v := new(GetCrtcGammaSizeReply) +// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value. +func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { + v := new(QueryOutputPropertyReply) b := 1 // skip reply determinant b += 1 // padding @@ -3248,77 +3386,103 @@ func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Size = xgb.Get16(buf[b:]) - b += 2 + if buf[b] == 1 { + v.Pending = true + } else { + v.Pending = false + } + b += 1 - b += 22 // padding + if buf[b] == 1 { + v.Range = true + } else { + v.Range = false + } + b += 1 + + if buf[b] == 1 { + v.Immutable = true + } else { + v.Immutable = false + } + b += 1 + + b += 21 // padding + + v.ValidValues = make([]int32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.ValidValues[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for GetCrtcGammaSize -// getCrtcGammaSizeRequest writes a GetCrtcGammaSize request to a byte slice. -func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { - size := 8 +// Write request to wire for QueryOutputProperty +// queryOutputPropertyRequest writes a QueryOutputProperty request to a byte slice. +func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 22 // 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:], uint32(Crtc)) + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) b += 4 return buf } -// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. -type GetCrtcGammaCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// GetCrtcGamma sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCrtcGammaCookie.Reply() -func GetCrtcGamma(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { +// 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) - return GetCrtcGammaCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetCrtcGammaUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) - return GetCrtcGammaCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. -type GetCrtcGammaReply struct { +// 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 - Size uint16 - // padding: 22 bytes - Red []uint16 // size: xgb.Pad((int(Size) * 2)) - Green []uint16 // size: xgb.Pad((int(Size) * 2)) - Blue []uint16 // size: xgb.Pad((int(Size) * 2)) + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes } -// Reply blocks and returns the reply data for a GetCrtcGamma request. -func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { +// 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 @@ -3326,12 +3490,12 @@ func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { if buf == nil { return nil, nil } - return getCrtcGammaReply(buf), nil + return queryVersionReply(buf), nil } -// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value. -func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { - v := new(GetCrtcGammaReply) +// 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 @@ -3342,182 +3506,140 @@ func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Size = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Red = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Red[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 - v.Green = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Green[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 - v.Blue = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Blue[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + b += 16 // padding return v } -// Write request to wire for GetCrtcGamma -// getCrtcGammaRequest writes a GetCrtcGamma request to a byte slice. -func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { - size := 8 +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 23 // request opcode + buf[b] = 0 // 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(Crtc)) + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) b += 4 return buf } -// SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests. -type SetCrtcGammaCookie struct { +// SelectInputCookie is a cookie used only for SelectInput requests. +type SelectInputCookie struct { *xgb.Cookie } -// SetCrtcGamma sends an unchecked request. +// SelectInput sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetCrtcGamma(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { +func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) - return SetCrtcGammaCookie{cookie} + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{cookie} } -// SetCrtcGammaChecked sends a checked request. -// If an error occurs, it can be retrieved using SetCrtcGammaCookie.Check() -func SetCrtcGammaChecked(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { +// SelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectInputCookie.Check() +func SelectInputChecked(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) - return SetCrtcGammaCookie{cookie} + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{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 SetCrtcGammaCookie) Check() error { +func (cook SelectInputCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetCrtcGamma -// setCrtcGammaRequest writes a SetCrtcGamma request to a byte slice. -func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { - size := xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) +// Write request to wire for SelectInput +// selectInputRequest writes a SelectInput request to a byte slice. +func selectInputRequest(c *xgb.Conn, Window xproto.Window, Enable uint16) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 24 // request opcode + 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:], uint32(Crtc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Size) + xgb.Put16(buf[b:], Enable) b += 2 b += 2 // padding - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Red[i]) - b += 2 - } - b = xgb.Pad(b) - - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Green[i]) - b += 2 - } - b = xgb.Pad(b) - - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Blue[i]) - b += 2 - } - b = xgb.Pad(b) - return buf } -// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. -type GetScreenResourcesCurrentCookie struct { +// SetCrtcConfigCookie is a cookie used only for SetCrtcConfig requests. +type SetCrtcConfigCookie struct { *xgb.Cookie } -// GetScreenResourcesCurrent sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCurrentCookie.Reply() -func GetScreenResourcesCurrent(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { +// SetCrtcConfig sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetCrtcConfigCookie.Reply() +func SetCrtcConfig(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) - return GetScreenResourcesCurrentCookie{cookie} + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} } -// GetScreenResourcesCurrentUnchecked sends an unchecked request. +// SetCrtcConfigUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { +func SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) - return GetScreenResourcesCurrentCookie{cookie} + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} } -// GetScreenResourcesCurrentReply represents the data returned from a GetScreenResourcesCurrent request. -type GetScreenResourcesCurrentReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Timestamp xproto.Timestamp - ConfigTimestamp xproto.Timestamp - NumCrtcs uint16 - NumOutputs uint16 - NumModes uint16 - NamesLen uint16 - // padding: 8 bytes - Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) - Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) - Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) - Names []byte // size: xgb.Pad((int(NamesLen) * 1)) +// SetCrtcConfigReply represents the data returned from a SetCrtcConfig request. +type SetCrtcConfigReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte + Timestamp xproto.Timestamp + // padding: 20 bytes } -// Reply blocks and returns the reply data for a GetScreenResourcesCurrent request. -func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { +// Reply blocks and returns the reply data for a SetCrtcConfig request. +func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3525,15 +3647,16 @@ func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentR if buf == nil { return nil, nil } - return getScreenResourcesCurrentReply(buf), nil + return setCrtcConfigReply(buf), nil } -// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. -func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { - v := new(GetScreenResourcesCurrentReply) +// setCrtcConfigReply reads a byte slice into a SetCrtcConfigReply value. +func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { + v := new(SetCrtcConfigReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3544,66 +3667,134 @@ func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + b += 20 // padding - v.NumCrtcs = xgb.Get16(buf[b:]) + return v +} + +// Write request to wire for SetCrtcConfig +// setCrtcConfigRequest writes a SetCrtcConfig request to a byte slice. +func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.NumOutputs = xgb.Get16(buf[b:]) + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) b += 2 - v.NumModes = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(Y)) b += 2 - v.NamesLen = xgb.Get16(buf[b:]) + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + xgb.Put16(buf[b:], Rotation) b += 2 - b += 8 // padding + b += 2 // padding - v.Crtcs = make([]Crtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + for i := 0; i < int(len(Outputs)); i++ { + xgb.Put32(buf[b:], uint32(Outputs[i])) b += 4 } b = xgb.Pad(b) - v.Outputs = make([]Output, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Output(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + return buf +} - v.Modes = make([]ModeInfo, v.NumModes) - b += ModeInfoReadList(buf[b:], v.Modes) +// SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests. +type SetCrtcGammaCookie struct { + *xgb.Cookie +} - v.Names = make([]byte, v.NamesLen) - copy(v.Names[:v.NamesLen], buf[b:]) - b += xgb.Pad(int(v.NamesLen)) +// SetCrtcGamma sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetCrtcGamma(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} +} - return v +// SetCrtcGammaChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCrtcGammaCookie.Check() +func SetCrtcGammaChecked(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} } -// Write request to wire for GetScreenResourcesCurrent -// getScreenResourcesCurrentRequest writes a GetScreenResourcesCurrent request to a byte slice. -func getScreenResourcesCurrentRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// 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 SetCrtcGammaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCrtcGamma +// setCrtcGammaRequest writes a SetCrtcGamma request to a byte slice. +func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { + size := xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 25 // request opcode + buf[b] = 24 // 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)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 + xgb.Put16(buf[b:], Size) + b += 2 + + b += 2 // padding + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Red[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Green[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Blue[i]) + b += 2 + } + b = xgb.Pad(b) + return buf } @@ -3682,292 +3873,59 @@ func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, return buf } -// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. -type GetCrtcTransformCookie struct { +// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. +type SetOutputPrimaryCookie struct { *xgb.Cookie } -// GetCrtcTransform sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCrtcTransformCookie.Reply() -func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} -} - -// GetCrtcTransformUnchecked sends an unchecked request. +// SetOutputPrimary sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { +func SetOutputPrimary(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} -} - -// GetCrtcTransformReply represents the data returned from a GetCrtcTransform request. -type GetCrtcTransformReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - PendingTransform render.Transform - HasTransforms bool - // padding: 3 bytes - CurrentTransform render.Transform - // padding: 4 bytes - PendingLen uint16 - PendingNparams uint16 - CurrentLen uint16 - CurrentNparams uint16 - PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1)) - PendingParams []render.Fixed // size: xgb.Pad((int(PendingNparams) * 4)) - CurrentFilterName string // size: xgb.Pad((int(CurrentLen) * 1)) - CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4)) + cookie := c.NewCookie(false, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{cookie} } -// Reply blocks and returns the reply data for a GetCrtcTransform request. -func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SetOutputPrimaryChecked sends a checked request. +// If an error occurs, it can be retrieved using SetOutputPrimaryCookie.Check() +func SetOutputPrimaryChecked(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - return getCrtcTransformReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{cookie} } -// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. -func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { - v := new(GetCrtcTransformReply) - 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.PendingTransform = render.Transform{} - b += render.TransformRead(buf[b:], &v.PendingTransform) - - if buf[b] == 1 { - v.HasTransforms = true - } else { - v.HasTransforms = false - } - b += 1 - - b += 3 // padding - - v.CurrentTransform = render.Transform{} - b += render.TransformRead(buf[b:], &v.CurrentTransform) - - b += 4 // padding - - v.PendingLen = xgb.Get16(buf[b:]) - b += 2 - - v.PendingNparams = xgb.Get16(buf[b:]) - b += 2 - - v.CurrentLen = xgb.Get16(buf[b:]) - b += 2 - - v.CurrentNparams = xgb.Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.PendingLen) - copy(byteString[:v.PendingLen], buf[b:]) - v.PendingFilterName = string(byteString) - b += xgb.Pad(int(v.PendingLen)) - } - - v.PendingParams = make([]render.Fixed, v.PendingNparams) - for i := 0; i < int(v.PendingNparams); i++ { - v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - { - byteString := make([]byte, v.CurrentLen) - copy(byteString[:v.CurrentLen], buf[b:]) - v.CurrentFilterName = string(byteString) - b += xgb.Pad(int(v.CurrentLen)) - } - - v.CurrentParams = make([]render.Fixed, v.CurrentNparams) - for i := 0; i < int(v.CurrentNparams); i++ { - v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - 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 SetOutputPrimaryCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetCrtcTransform -// getCrtcTransformRequest writes a GetCrtcTransform request to a byte slice. -func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { - size := 8 +// Write request to wire for SetOutputPrimary +// setOutputPrimaryRequest writes a SetOutputPrimary request to a byte slice. +func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 27 // request opcode + buf[b] = 30 // 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(Crtc)) - b += 4 - - return buf -} - -// GetPanningCookie is a cookie used only for GetPanning requests. -type GetPanningCookie struct { - *xgb.Cookie -} - -// GetPanning sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPanningCookie.Reply() -func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getPanningRequest(c, Crtc), cookie) - return GetPanningCookie{cookie} -} - -// GetPanningUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getPanningRequest(c, Crtc), cookie) - return GetPanningCookie{cookie} -} - -// GetPanningReply represents the data returned from a GetPanning request. -type GetPanningReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte - Timestamp xproto.Timestamp - Left uint16 - Top uint16 - Width uint16 - Height uint16 - TrackLeft uint16 - TrackTop uint16 - TrackWidth uint16 - TrackHeight uint16 - BorderLeft int16 - BorderTop int16 - BorderRight int16 - BorderBottom int16 -} - -// Reply blocks and returns the reply data for a GetPanning request. -func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPanningReply(buf), nil -} - -// getPanningReply reads a byte slice into a GetPanningReply value. -func getPanningReply(buf []byte) *GetPanningReply { - v := new(GetPanningReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - v.Left = xgb.Get16(buf[b:]) - b += 2 - - v.Top = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.TrackLeft = xgb.Get16(buf[b:]) - b += 2 - - v.TrackTop = xgb.Get16(buf[b:]) - b += 2 - - v.TrackWidth = xgb.Get16(buf[b:]) - b += 2 - - v.TrackHeight = xgb.Get16(buf[b:]) - b += 2 - - v.BorderLeft = int16(xgb.Get16(buf[b:])) - b += 2 - - v.BorderTop = int16(xgb.Get16(buf[b:])) - b += 2 - - v.BorderRight = int16(xgb.Get16(buf[b:])) - b += 2 - - v.BorderBottom = int16(xgb.Get16(buf[b:])) - b += 2 - - return v -} - -// Write request to wire for GetPanning -// getPanningRequest writes a GetPanning request to a byte slice. -func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - b += 1 - - buf[b] = 28 // 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(Crtc)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 return buf @@ -4101,50 +4059,99 @@ func setPanningRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left return buf } -// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. -type SetOutputPrimaryCookie struct { +// SetScreenConfigCookie is a cookie used only for SetScreenConfig requests. +type SetScreenConfigCookie struct { *xgb.Cookie } -// SetOutputPrimary sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetOutputPrimary(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { +// SetScreenConfig sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetScreenConfigCookie.Reply() +func SetScreenConfig(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) - return SetOutputPrimaryCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{cookie} } -// SetOutputPrimaryChecked sends a checked request. -// If an error occurs, it can be retrieved using SetOutputPrimaryCookie.Check() -func SetOutputPrimaryChecked(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { +// SetScreenConfigUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetScreenConfigUnchecked(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) - return SetOutputPrimaryCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{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 SetOutputPrimaryCookie) Check() error { - return cook.Cookie.Check() +// SetScreenConfigReply represents the data returned from a SetScreenConfig request. +type SetScreenConfigReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte + NewTimestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + Root xproto.Window + SubpixelOrder uint16 + // padding: 10 bytes } -// Write request to wire for SetOutputPrimary -// setOutputPrimaryRequest writes a SetOutputPrimary request to a byte slice. -func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) []byte { - size := 12 +// Reply blocks and returns the reply data for a SetScreenConfig request. +func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setScreenConfigReply(buf), nil +} + +// setScreenConfigReply reads a byte slice into a SetScreenConfigReply value. +func setScreenConfigReply(buf []byte) *SetScreenConfigReply { + v := new(SetScreenConfigReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NewTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.SubpixelOrder = xgb.Get16(buf[b:]) + b += 2 + + b += 10 // padding + + return v +} + +// Write request to wire for SetScreenConfig +// setScreenConfigRequest writes a SetScreenConfig request to a byte slice. +func setScreenConfigRequest(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte { + size := 24 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 30 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4153,89 +4160,70 @@ func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) [ xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Output)) + xgb.Put32(buf[b:], uint32(Timestamp)) b += 4 + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + xgb.Put16(buf[b:], SizeID) + b += 2 + + xgb.Put16(buf[b:], Rotation) + b += 2 + + xgb.Put16(buf[b:], Rate) + b += 2 + + b += 2 // padding + return buf } -// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. -type GetOutputPrimaryCookie struct { +// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. +type SetScreenSizeCookie struct { *xgb.Cookie } -// GetOutputPrimary sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetOutputPrimaryCookie.Reply() -func GetOutputPrimary(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) - return GetOutputPrimaryCookie{cookie} -} - -// GetOutputPrimaryUnchecked sends an unchecked request. +// SetScreenSize sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetOutputPrimaryUnchecked(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { +func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) - return GetOutputPrimaryCookie{cookie} -} - -// GetOutputPrimaryReply represents the data returned from a GetOutputPrimary request. -type GetOutputPrimaryReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Output Output + cookie := c.NewCookie(false, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} } -// Reply blocks and returns the reply data for a GetOutputPrimary request. -func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SetScreenSizeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetScreenSizeCookie.Check() +func SetScreenSizeChecked(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - return getOutputPrimaryReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} } -// getOutputPrimaryReply reads a byte slice into a GetOutputPrimaryReply value. -func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { - v := new(GetOutputPrimaryReply) - 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.Output = Output(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 SetScreenSizeCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetOutputPrimary -// getOutputPrimaryRequest writes a GetOutputPrimary request to a byte slice. -func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for SetScreenSize +// setScreenSizeRequest writes a SetScreenSize request to a byte slice. +func setScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 31 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4244,5 +4232,17 @@ func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], MmWidth) + b += 4 + + xgb.Put32(buf[b:], MmHeight) + b += 4 + return buf } diff --git a/nexgb/record/record.go b/nexgb/record/record.go index 4bed730..2bbfe1c 100644 --- a/nexgb/record/record.go +++ b/nexgb/record/record.go @@ -2,7 +2,7 @@ package record /* - This file was generated by record.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by record.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,100 +40,107 @@ func init() { xgb.NewExtErrorFuncs["RECORD"] = 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' +// BadBadContext is the error number for a BadBadContext. +const BadBadContext = 0 -// Skipping definition for base type 'Int8' +type BadContextError struct { + Sequence uint16 + NiceName string + InvalidRecord uint32 +} -// Skipping definition for base type 'Card16' +// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError{} + v.NiceName = "BadContext" -// Skipping definition for base type 'Char' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Card32' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Double' + v.InvalidRecord = xgb.Get32(buf[b:]) + b += 4 -// Skipping definition for base type 'Bool' + return v +} -const ( - HTypeFromServerTime = 1 - HTypeFromClientTime = 2 - HTypeFromClientSequence = 4 -) +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} -const ( - CsCurrentClients = 1 - CsFutureClients = 2 - CsAllClients = 3 -) +// BadId returns the 'BadValue' number if one exists for the BadBadContext error. If no bad value exists, 0 is returned. +func (err BadContextError) BadId() uint32 { + return 0 +} -type Context uint32 +// Error returns a rudimentary string representation of the BadBadContext error. -func NewContextId(c *xgb.Conn) (Context, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Context(id), nil +func (err BadContextError) Error() string { + fieldVals := make([]string, 0, 1) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("InvalidRecord: %d", err.InvalidRecord)) + return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type ElementHeader byte - -type ClientSpec uint32 +func init() { + xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +} -type Range8 struct { - First byte - Last byte +type ClientInfo struct { + ClientResource ClientSpec + NumRanges uint32 + Ranges []Range // size: xgb.Pad((int(NumRanges) * 24)) } -// Range8Read reads a byte slice into a Range8 value. -func Range8Read(buf []byte, v *Range8) int { +// ClientInfoRead reads a byte slice into a ClientInfo value. +func ClientInfoRead(buf []byte, v *ClientInfo) int { b := 0 - v.First = buf[b] - b += 1 + v.ClientResource = ClientSpec(xgb.Get32(buf[b:])) + b += 4 - v.Last = buf[b] - b += 1 + v.NumRanges = xgb.Get32(buf[b:]) + b += 4 + + v.Ranges = make([]Range, v.NumRanges) + b += RangeReadList(buf[b:], v.Ranges) return b } -// Range8ReadList reads a byte slice into a list of Range8 values. -func Range8ReadList(buf []byte, dest []Range8) int { +// ClientInfoReadList reads a byte slice into a list of ClientInfo values. +func ClientInfoReadList(buf []byte, dest []ClientInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Range8{} - b += Range8Read(buf[b:], &dest[i]) + dest[i] = ClientInfo{} + b += ClientInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Range8 value to a byte slice. -func (v Range8) Bytes() []byte { - buf := make([]byte, 2) +// Bytes writes a ClientInfo value to a byte slice. +func (v ClientInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumRanges) * 24)))) b := 0 - buf[b] = v.First - b += 1 + xgb.Put32(buf[b:], uint32(v.ClientResource)) + b += 4 - buf[b] = v.Last - b += 1 + xgb.Put32(buf[b:], v.NumRanges) + b += 4 + + b += RangeListBytes(buf[b:], v.Ranges) return buf } -// Range8ListBytes writes a list of Range8 values to a byte slice. -func Range8ListBytes(buf []byte, list []Range8) int { +// ClientInfoListBytes writes a list of ClientInfo values to a byte slice. +func ClientInfoListBytes(buf []byte, list []ClientInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -144,59 +151,34 @@ func Range8ListBytes(buf []byte, list []Range8) int { return b } -type Range16 struct { - First uint16 - Last uint16 +// ClientInfoListSize computes the size (bytes) of a list of ClientInfo values. +func ClientInfoListSize(list []ClientInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumRanges) * 24))) + } + return size } -// Range16Read reads a byte slice into a Range16 value. -func Range16Read(buf []byte, v *Range16) int { - b := 0 - - v.First = xgb.Get16(buf[b:]) - b += 2 - - v.Last = xgb.Get16(buf[b:]) - b += 2 +type ClientSpec uint32 - return b -} +type Context uint32 -// Range16ReadList reads a byte slice into a list of Range16 values. -func Range16ReadList(buf []byte, dest []Range16) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Range16{} - b += Range16Read(buf[b:], &dest[i]) +func NewContextId(c *xgb.Conn) (Context, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return xgb.Pad(b) + return Context(id), nil } -// Bytes writes a Range16 value to a byte slice. -func (v Range16) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - xgb.Put16(buf[b:], v.First) - b += 2 - - xgb.Put16(buf[b:], v.Last) - b += 2 - - return buf -} +const ( + CsCurrentClients = 1 + CsFutureClients = 2 + CsAllClients = 3 +) -// Range16ListBytes writes a list of Range16 values to a byte slice. -func Range16ListBytes(buf []byte, list []Range16) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} +type ElementHeader byte type ExtRange struct { Major Range8 @@ -258,6 +240,12 @@ func ExtRangeListBytes(buf []byte, list []ExtRange) int { return b } +const ( + HTypeFromServerTime = 1 + HTypeFromClientTime = 2 + HTypeFromClientSequence = 4 +) + type Range struct { CoreRequests Range8 CoreReplies Range8 @@ -398,56 +386,50 @@ func RangeListBytes(buf []byte, list []Range) int { return b } -type ClientInfo struct { - ClientResource ClientSpec - NumRanges uint32 - Ranges []Range // size: xgb.Pad((int(NumRanges) * 24)) +type Range16 struct { + First uint16 + Last uint16 } -// ClientInfoRead reads a byte slice into a ClientInfo value. -func ClientInfoRead(buf []byte, v *ClientInfo) int { +// Range16Read reads a byte slice into a Range16 value. +func Range16Read(buf []byte, v *Range16) int { b := 0 - v.ClientResource = ClientSpec(xgb.Get32(buf[b:])) - b += 4 - - v.NumRanges = xgb.Get32(buf[b:]) - b += 4 + v.First = xgb.Get16(buf[b:]) + b += 2 - v.Ranges = make([]Range, v.NumRanges) - b += RangeReadList(buf[b:], v.Ranges) + v.Last = xgb.Get16(buf[b:]) + b += 2 return b } -// ClientInfoReadList reads a byte slice into a list of ClientInfo values. -func ClientInfoReadList(buf []byte, dest []ClientInfo) int { +// Range16ReadList reads a byte slice into a list of Range16 values. +func Range16ReadList(buf []byte, dest []Range16) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = ClientInfo{} - b += ClientInfoRead(buf[b:], &dest[i]) + dest[i] = Range16{} + b += Range16Read(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a ClientInfo value to a byte slice. -func (v ClientInfo) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.NumRanges) * 24)))) +// Bytes writes a Range16 value to a byte slice. +func (v Range16) Bytes() []byte { + buf := make([]byte, 4) b := 0 - xgb.Put32(buf[b:], uint32(v.ClientResource)) - b += 4 - - xgb.Put32(buf[b:], v.NumRanges) - b += 4 + xgb.Put16(buf[b:], v.First) + b += 2 - b += RangeListBytes(buf[b:], v.Ranges) + xgb.Put16(buf[b:], v.Last) + b += 2 return buf } -// ClientInfoListBytes writes a list of ClientInfo values to a byte slice. -func ClientInfoListBytes(buf []byte, list []ClientInfo) int { +// Range16ListBytes writes a list of Range16 values to a byte slice. +func Range16ListBytes(buf []byte, list []Range16) int { b := 0 var structBytes []byte for _, item := range list { @@ -458,160 +440,83 @@ func ClientInfoListBytes(buf []byte, list []ClientInfo) int { return b } -// ClientInfoListSize computes the size (bytes) of a list of ClientInfo values. -func ClientInfoListSize(list []ClientInfo) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.NumRanges) * 24))) - } - return size -} - -// BadBadContext is the error number for a BadBadContext. -const BadBadContext = 0 - -type BadContextError struct { - Sequence uint16 - NiceName string - InvalidRecord uint32 -} - -// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. -func BadContextErrorNew(buf []byte) xgb.Error { - v := BadContextError{} - v.NiceName = "BadContext" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.InvalidRecord = xgb.Get32(buf[b:]) - b += 4 - - return v +type Range8 struct { + First byte + Last byte } -// SequenceId returns the sequence id attached to the BadBadContext error. -// This is mostly used internally. -func (err BadContextError) SequenceId() uint16 { - return err.Sequence -} +// Range8Read reads a byte slice into a Range8 value. +func Range8Read(buf []byte, v *Range8) int { + b := 0 -// BadId returns the 'BadValue' number if one exists for the BadBadContext error. If no bad value exists, 0 is returned. -func (err BadContextError) BadId() uint32 { - return 0 -} + v.First = buf[b] + b += 1 -// Error returns a rudimentary string representation of the BadBadContext error. + v.Last = buf[b] + b += 1 -func (err BadContextError) Error() string { - fieldVals := make([]string, 0, 1) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("InvalidRecord: %d", err.InvalidRecord)) - return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return b } -func init() { - xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +// Range8ReadList reads a byte slice into a list of Range8 values. +func Range8ReadList(buf []byte, dest []Range8) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Range8{} + b += Range8Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { - *xgb.Cookie -} +// Bytes writes a Range8 value to a byte slice. +func (v Range8) Bytes() []byte { + buf := make([]byte, 2) + b := 0 -// 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, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} -} + buf[b] = v.First + b += 1 -// 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, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} -} + buf[b] = v.Last + b += 1 -// 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 - MajorVersion uint16 - MinorVersion uint16 + return buf } -// 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 +// Range8ListBytes writes a list of Range8 values to a byte slice. +func Range8ListBytes(buf []byte, list []Range8) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } - return queryVersionReply(buf), nil + return b } -// 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 +// Skipping definition for base type 'Bool' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Byte' - v.MajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card8' - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Char' - return v -} +// Skipping definition for base type 'Void' -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Double' - buf[b] = c.Extensions["RECORD"] - b += 1 +// Skipping definition for base type 'Float' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Int16' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Int32' - xgb.Put16(buf[b:], MajorVersion) - b += 2 +// Skipping definition for base type 'Int8' - xgb.Put16(buf[b:], MinorVersion) - b += 2 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { @@ -687,50 +592,50 @@ func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHea return buf } -// RegisterClientsCookie is a cookie used only for RegisterClients requests. -type RegisterClientsCookie struct { +// DisableContextCookie is a cookie used only for DisableContext requests. +type DisableContextCookie struct { *xgb.Cookie } -// RegisterClients sends an unchecked request. +// DisableContext sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RegisterClients(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { +func DisableContext(c *xgb.Conn, Context Context) DisableContextCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RegisterClientsCookie{cookie} + c.NewRequest(disableContextRequest(c, Context), cookie) + return DisableContextCookie{cookie} } -// RegisterClientsChecked sends a checked request. -// If an error occurs, it can be retrieved using RegisterClientsCookie.Check() -func RegisterClientsChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { +// DisableContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DisableContextCookie.Check() +func DisableContextChecked(c *xgb.Conn, Context Context) DisableContextCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RegisterClientsCookie{cookie} + c.NewRequest(disableContextRequest(c, Context), cookie) + return DisableContextCookie{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 RegisterClientsCookie) Check() error { +func (cook DisableContextCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RegisterClients -// registerClientsRequest writes a RegisterClients request to a byte slice. -func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { - size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +// Write request to wire for DisableContext +// disableContextRequest writes a DisableContext request to a byte slice. +func disableContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RECORD"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -739,72 +644,173 @@ func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementH xgb.Put32(buf[b:], uint32(Context)) b += 4 - buf[b] = byte(ElementHeader) + return buf +} + +// EnableContextCookie is a cookie used only for EnableContext requests. +type EnableContextCookie struct { + *xgb.Cookie +} + +// EnableContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling EnableContextCookie.Reply() +func EnableContext(c *xgb.Conn, Context Context) EnableContextCookie { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(enableContextRequest(c, Context), cookie) + return EnableContextCookie{cookie} +} + +// EnableContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func EnableContextUnchecked(c *xgb.Conn, Context Context) EnableContextCookie { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(enableContextRequest(c, Context), cookie) + return EnableContextCookie{cookie} +} + +// EnableContextReply represents the data returned from a EnableContext request. +type EnableContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Category byte + ElementHeader ElementHeader + ClientSwapped bool + // padding: 2 bytes + XidBase uint32 + ServerTime uint32 + RecSequenceNum uint32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a EnableContext request. +func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return enableContextReply(buf), nil +} + +// enableContextReply reads a byte slice into a EnableContextReply value. +func enableContextReply(buf []byte) *EnableContextReply { + v := new(EnableContextReply) + b := 1 // skip reply determinant + + v.Category = buf[b] b += 1 - b += 3 // padding + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], NumClientSpecs) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], NumRanges) - b += 4 + v.ElementHeader = ElementHeader(buf[b]) + b += 1 - for i := 0; i < int(NumClientSpecs); i++ { - xgb.Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 + if buf[b] == 1 { + v.ClientSwapped = true + } else { + v.ClientSwapped = false } - b = xgb.Pad(b) + b += 1 - b += RangeListBytes(buf[b:], Ranges) + b += 2 // padding + + v.XidBase = xgb.Get32(buf[b:]) + b += 4 + + v.ServerTime = xgb.Get32(buf[b:]) + b += 4 + + v.RecSequenceNum = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for EnableContext +// enableContextRequest writes a EnableContext request to a byte slice. +func enableContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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:], uint32(Context)) + b += 4 return buf } -// UnregisterClientsCookie is a cookie used only for UnregisterClients requests. -type UnregisterClientsCookie struct { +// FreeContextCookie is a cookie used only for FreeContext requests. +type FreeContextCookie struct { *xgb.Cookie } -// UnregisterClients sends an unchecked request. +// FreeContext sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnregisterClients(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { +func FreeContext(c *xgb.Conn, Context Context) FreeContextCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) - return UnregisterClientsCookie{cookie} + c.NewRequest(freeContextRequest(c, Context), cookie) + return FreeContextCookie{cookie} } -// UnregisterClientsChecked sends a checked request. -// If an error occurs, it can be retrieved using UnregisterClientsCookie.Check() -func UnregisterClientsChecked(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { +// FreeContextChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeContextCookie.Check() +func FreeContextChecked(c *xgb.Conn, Context Context) FreeContextCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) - return UnregisterClientsCookie{cookie} + c.NewRequest(freeContextRequest(c, Context), cookie) + return FreeContextCookie{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 UnregisterClientsCookie) Check() error { +func (cook FreeContextCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnregisterClients -// unregisterClientsRequest writes a UnregisterClients request to a byte slice. -func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) +// Write request to wire for FreeContext +// freeContextRequest writes a FreeContext request to a byte slice. +func freeContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RECORD"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -813,15 +819,6 @@ func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint3 xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], NumClientSpecs) - b += 4 - - for i := 0; i < int(NumClientSpecs); i++ { - xgb.Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } @@ -932,50 +929,44 @@ func getContextRequest(c *xgb.Conn, Context Context) []byte { return buf } -// EnableContextCookie is a cookie used only for EnableContext requests. -type EnableContextCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// EnableContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling EnableContextCookie.Reply() -func EnableContext(c *xgb.Conn, Context Context) EnableContextCookie { +// 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, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(enableContextRequest(c, Context), cookie) - return EnableContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// EnableContextUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func EnableContextUnchecked(c *xgb.Conn, Context Context) EnableContextCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(enableContextRequest(c, Context), cookie) - return EnableContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// EnableContextReply represents the data returned from a EnableContext request. -type EnableContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Category byte - ElementHeader ElementHeader - ClientSwapped bool - // padding: 2 bytes - XidBase uint32 - ServerTime uint32 - RecSequenceNum uint32 - // padding: 8 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +// 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 + MajorVersion uint16 + MinorVersion uint16 } -// Reply blocks and returns the reply data for a EnableContext request. -func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { +// 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 @@ -983,16 +974,15 @@ func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { if buf == nil { return nil, nil } - return enableContextReply(buf), nil + return queryVersionReply(buf), nil } -// enableContextReply reads a byte slice into a EnableContextReply value. -func enableContextReply(buf []byte) *EnableContextReply { - v := new(EnableContextReply) +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) b := 1 // skip reply determinant - v.Category = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -1000,39 +990,18 @@ func enableContextReply(buf []byte) *EnableContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ElementHeader = ElementHeader(buf[b]) - b += 1 - - if buf[b] == 1 { - v.ClientSwapped = true - } else { - v.ClientSwapped = false - } - b += 1 - - b += 2 // padding - - v.XidBase = xgb.Get32(buf[b:]) - b += 4 - - v.ServerTime = xgb.Get32(buf[b:]) - b += 4 - - v.RecSequenceNum = xgb.Get32(buf[b:]) - b += 4 - - b += 8 // padding + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for EnableContext -// enableContextRequest writes a EnableContext request to a byte slice. -func enableContextRequest(c *xgb.Conn, Context Context) []byte { +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1040,62 +1009,65 @@ func enableContextRequest(c *xgb.Conn, Context Context) []byte { buf[b] = c.Extensions["RECORD"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 0 // 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(Context)) - b += 4 + xgb.Put16(buf[b:], MajorVersion) + b += 2 + + xgb.Put16(buf[b:], MinorVersion) + b += 2 return buf } -// DisableContextCookie is a cookie used only for DisableContext requests. -type DisableContextCookie struct { +// RegisterClientsCookie is a cookie used only for RegisterClients requests. +type RegisterClientsCookie struct { *xgb.Cookie } -// DisableContext sends an unchecked request. +// RegisterClients sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DisableContext(c *xgb.Conn, Context Context) DisableContextCookie { +func RegisterClients(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(disableContextRequest(c, Context), cookie) - return DisableContextCookie{cookie} + c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return RegisterClientsCookie{cookie} } -// DisableContextChecked sends a checked request. -// If an error occurs, it can be retrieved using DisableContextCookie.Check() -func DisableContextChecked(c *xgb.Conn, Context Context) DisableContextCookie { +// RegisterClientsChecked sends a checked request. +// If an error occurs, it can be retrieved using RegisterClientsCookie.Check() +func RegisterClientsChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(disableContextRequest(c, Context), cookie) - return DisableContextCookie{cookie} + c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return RegisterClientsCookie{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 DisableContextCookie) Check() error { +func (cook RegisterClientsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DisableContext -// disableContextRequest writes a DisableContext request to a byte slice. -func disableContextRequest(c *xgb.Conn, Context Context) []byte { - size := 8 +// Write request to wire for RegisterClients +// registerClientsRequest writes a RegisterClients request to a byte slice. +func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { + size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RECORD"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1104,53 +1076,72 @@ func disableContextRequest(c *xgb.Conn, Context Context) []byte { xgb.Put32(buf[b:], uint32(Context)) b += 4 + buf[b] = byte(ElementHeader) + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + xgb.Put32(buf[b:], NumRanges) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + + b += RangeListBytes(buf[b:], Ranges) + return buf } -// FreeContextCookie is a cookie used only for FreeContext requests. -type FreeContextCookie struct { +// UnregisterClientsCookie is a cookie used only for UnregisterClients requests. +type UnregisterClientsCookie struct { *xgb.Cookie } -// FreeContext sends an unchecked request. +// UnregisterClients sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeContext(c *xgb.Conn, Context Context) FreeContextCookie { +func UnregisterClients(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(freeContextRequest(c, Context), cookie) - return FreeContextCookie{cookie} + c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) + return UnregisterClientsCookie{cookie} } -// FreeContextChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeContextCookie.Check() -func FreeContextChecked(c *xgb.Conn, Context Context) FreeContextCookie { +// UnregisterClientsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnregisterClientsCookie.Check() +func UnregisterClientsChecked(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(freeContextRequest(c, Context), cookie) - return FreeContextCookie{cookie} + c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) + return UnregisterClientsCookie{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 FreeContextCookie) Check() error { +func (cook UnregisterClientsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FreeContext -// freeContextRequest writes a FreeContext request to a byte slice. -func freeContextRequest(c *xgb.Conn, Context Context) []byte { - size := 8 +// Write request to wire for UnregisterClients +// unregisterClientsRequest writes a UnregisterClients request to a byte slice. +func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RECORD"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1159,5 +1150,14 @@ func freeContextRequest(c *xgb.Conn, Context Context) []byte { xgb.Put32(buf[b:], uint32(Context)) b += 4 + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + return buf } diff --git a/nexgb/render/render.go b/nexgb/render/render.go index 2f1ae13..c6f5095 100644 --- a/nexgb/render/render.go +++ b/nexgb/render/render.go @@ -2,7 +2,7 @@ package render /* - This file was generated by render.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by render.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,104 +40,127 @@ func init() { xgb.NewExtErrorFuncs["RENDER"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Float' +type Animcursorelt struct { + Cursor xproto.Cursor + Delay uint32 +} -// Skipping definition for base type 'Card8' +// AnimcursoreltRead reads a byte slice into a Animcursorelt value. +func AnimcursoreltRead(buf []byte, v *Animcursorelt) int { + b := 0 -// Skipping definition for base type 'Int16' + v.Cursor = xproto.Cursor(xgb.Get32(buf[b:])) + b += 4 -// Skipping definition for base type 'Int32' + v.Delay = xgb.Get32(buf[b:]) + b += 4 -// Skipping definition for base type 'Void' + return b +} -// Skipping definition for base type 'Byte' +// AnimcursoreltReadList reads a byte slice into a list of Animcursorelt values. +func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Animcursorelt{} + b += AnimcursoreltRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} -// Skipping definition for base type 'Int8' +// Bytes writes a Animcursorelt value to a byte slice. +func (v Animcursorelt) Bytes() []byte { + buf := make([]byte, 8) + b := 0 -// Skipping definition for base type 'Card16' + xgb.Put32(buf[b:], uint32(v.Cursor)) + b += 4 -// Skipping definition for base type 'Char' + xgb.Put32(buf[b:], v.Delay) + b += 4 -// Skipping definition for base type 'Card32' + return buf +} -// Skipping definition for base type 'Double' +// AnimcursoreltListBytes writes a list of Animcursorelt values to a byte slice. +func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} -// Skipping definition for base type 'Bool' +type Color struct { + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} -const ( - PictTypeIndexed = 0 - PictTypeDirect = 1 -) +// ColorRead reads a byte slice into a Color value. +func ColorRead(buf []byte, v *Color) int { + b := 0 -const ( - PictureNone = 0 -) + v.Red = xgb.Get16(buf[b:]) + b += 2 -const ( - PictOpClear = 0 - PictOpSrc = 1 - PictOpDst = 2 - PictOpOver = 3 - PictOpOverReverse = 4 - PictOpIn = 5 - PictOpInReverse = 6 - PictOpOut = 7 - PictOpOutReverse = 8 - PictOpAtop = 9 - PictOpAtopReverse = 10 - PictOpXor = 11 - PictOpAdd = 12 - PictOpSaturate = 13 - PictOpDisjointClear = 16 - PictOpDisjointSrc = 17 - PictOpDisjointDst = 18 - PictOpDisjointOver = 19 - PictOpDisjointOverReverse = 20 - PictOpDisjointIn = 21 - PictOpDisjointInReverse = 22 - PictOpDisjointOut = 23 - PictOpDisjointOutReverse = 24 - PictOpDisjointAtop = 25 - PictOpDisjointAtopReverse = 26 - PictOpDisjointXor = 27 - PictOpConjointClear = 32 - PictOpConjointSrc = 33 - PictOpConjointDst = 34 - PictOpConjointOver = 35 - PictOpConjointOverReverse = 36 - PictOpConjointIn = 37 - PictOpConjointInReverse = 38 - PictOpConjointOut = 39 - PictOpConjointOutReverse = 40 - PictOpConjointAtop = 41 - PictOpConjointAtopReverse = 42 - PictOpConjointXor = 43 - PictOpMultiply = 48 - PictOpScreen = 49 - PictOpOverlay = 50 - PictOpDarken = 51 - PictOpLighten = 52 - PictOpColorDodge = 53 - PictOpColorBurn = 54 - PictOpHardLight = 55 - PictOpSoftLight = 56 - PictOpDifference = 57 - PictOpExclusion = 58 - PictOpHSLHue = 59 - PictOpHSLSaturation = 60 - PictOpHSLColor = 61 - PictOpHSLLuminosity = 62 -) + v.Green = xgb.Get16(buf[b:]) + b += 2 -const ( - PolyEdgeSharp = 0 - PolyEdgeSmooth = 1 -) + v.Blue = xgb.Get16(buf[b:]) + b += 2 -const ( - PolyModePrecise = 0 - PolyModeImprecise = 1 -) + v.Alpha = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// ColorReadList reads a byte slice into a list of Color values. +func ColorReadList(buf []byte, dest []Color) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Color{} + b += ColorRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Color value to a byte slice. +func (v Color) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + xgb.Put16(buf[b:], v.Alpha) + b += 2 + + return buf +} + +// ColorListBytes writes a list of Color values to a byte slice. +func ColorListBytes(buf []byte, list []Color) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} const ( CpRepeat = 1 @@ -155,56 +178,6 @@ const ( CpComponentAlpha = 4096 ) -const ( - SubPixelUnknown = 0 - SubPixelHorizontalRGB = 1 - SubPixelHorizontalBGR = 2 - SubPixelVerticalRGB = 3 - SubPixelVerticalBGR = 4 - SubPixelNone = 5 -) - -const ( - RepeatNone = 0 - RepeatNormal = 1 - RepeatPad = 2 - RepeatReflect = 3 -) - -type Glyphset uint32 - -func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Glyphset(id), nil -} - -type Picture uint32 - -func NewPictureId(c *xgb.Conn) (Picture, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Picture(id), nil -} - -type Pictformat uint32 - -func NewPictformatId(c *xgb.Conn) (Pictformat, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pictformat(id), nil -} - -type Glyph uint32 - -type Fixed int32 - type Directformat struct { RedShift uint16 RedMask uint16 @@ -301,79 +274,259 @@ func DirectformatListBytes(buf []byte, list []Directformat) int { return b } -type Pictforminfo struct { - Id Pictformat - Type byte - Depth byte - // padding: 2 bytes - Direct Directformat - Colormap xproto.Colormap +type Fixed int32 + +type Glyph uint32 + +// BadGlyph is the error number for a BadGlyph. +const BadGlyph = 4 + +type GlyphError struct { + Sequence uint16 + NiceName string } -// PictforminfoRead reads a byte slice into a Pictforminfo value. -func PictforminfoRead(buf []byte, v *Pictforminfo) int { +// GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice. +func GlyphErrorNew(buf []byte) xgb.Error { + v := GlyphError{} + v.NiceName = "Glyph" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadGlyph error. +// This is mostly used internally. +func (err GlyphError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadGlyph error. If no bad value exists, 0 is returned. +func (err GlyphError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadGlyph error. + +func (err GlyphError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadGlyph {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew +} + +// BadGlyphSet is the error number for a BadGlyphSet. +const BadGlyphSet = 3 + +type GlyphSetError struct { + Sequence uint16 + NiceName string +} + +// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice. +func GlyphSetErrorNew(buf []byte) xgb.Error { + v := GlyphSetError{} + v.NiceName = "GlyphSet" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadGlyphSet error. +// This is mostly used internally. +func (err GlyphSetError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadGlyphSet error. If no bad value exists, 0 is returned. +func (err GlyphSetError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadGlyphSet error. + +func (err GlyphSetError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadGlyphSet {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew +} + +type Glyphinfo struct { + Width uint16 + Height uint16 + X int16 + Y int16 + XOff int16 + YOff int16 +} + +// GlyphinfoRead reads a byte slice into a Glyphinfo value. +func GlyphinfoRead(buf []byte, v *Glyphinfo) int { b := 0 - v.Id = Pictformat(xgb.Get32(buf[b:])) - b += 4 + v.Width = xgb.Get16(buf[b:]) + b += 2 - v.Type = buf[b] - b += 1 + v.Height = xgb.Get16(buf[b:]) + b += 2 - v.Depth = buf[b] - b += 1 + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - b += 2 // padding + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - v.Direct = Directformat{} - b += DirectformatRead(buf[b:], &v.Direct) + v.XOff = int16(xgb.Get16(buf[b:])) + b += 2 - v.Colormap = xproto.Colormap(xgb.Get32(buf[b:])) - b += 4 + v.YOff = int16(xgb.Get16(buf[b:])) + b += 2 return b } -// PictforminfoReadList reads a byte slice into a list of Pictforminfo values. -func PictforminfoReadList(buf []byte, dest []Pictforminfo) int { +// GlyphinfoReadList reads a byte slice into a list of Glyphinfo values. +func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Pictforminfo{} - b += PictforminfoRead(buf[b:], &dest[i]) + dest[i] = Glyphinfo{} + b += GlyphinfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Pictforminfo value to a byte slice. -func (v Pictforminfo) Bytes() []byte { - buf := make([]byte, 28) +// Bytes writes a Glyphinfo value to a byte slice. +func (v Glyphinfo) Bytes() []byte { + buf := make([]byte, 12) b := 0 - xgb.Put32(buf[b:], uint32(v.Id)) - b += 4 + xgb.Put16(buf[b:], v.Width) + b += 2 - buf[b] = v.Type - b += 1 + xgb.Put16(buf[b:], v.Height) + b += 2 - buf[b] = v.Depth - b += 1 + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 - b += 2 // padding + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 - { - structBytes := v.Direct.Bytes() + xgb.Put16(buf[b:], uint16(v.XOff)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.YOff)) + b += 2 + + return buf +} + +// GlyphinfoListBytes writes a list of Glyphinfo values to a byte slice. +func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } + return b +} - xgb.Put32(buf[b:], uint32(v.Colormap)) +type Glyphset uint32 + +func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Glyphset(id), nil +} + +type Indexvalue struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} + +// IndexvalueRead reads a byte slice into a Indexvalue value. +func IndexvalueRead(buf []byte, v *Indexvalue) int { + b := 0 + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Alpha = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// IndexvalueReadList reads a byte slice into a list of Indexvalue values. +func IndexvalueReadList(buf []byte, dest []Indexvalue) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Indexvalue{} + b += IndexvalueRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Indexvalue value to a byte slice. +func (v Indexvalue) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Pixel) b += 4 + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + xgb.Put16(buf[b:], v.Alpha) + b += 2 + return buf } -// PictforminfoListBytes writes a list of Pictforminfo values to a byte slice. -func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { +// IndexvalueListBytes writes a list of Indexvalue values to a byte slice. +func IndexvalueListBytes(buf []byte, list []Indexvalue) int { b := 0 var structBytes []byte for _, item := range list { @@ -384,50 +537,56 @@ func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { return b } -type Pictvisual struct { - Visual xproto.Visualid - Format Pictformat +type Linefix struct { + P1 Pointfix + P2 Pointfix } -// PictvisualRead reads a byte slice into a Pictvisual value. -func PictvisualRead(buf []byte, v *Pictvisual) int { +// LinefixRead reads a byte slice into a Linefix value. +func LinefixRead(buf []byte, v *Linefix) int { b := 0 - v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) - b += 4 + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) - v.Format = Pictformat(xgb.Get32(buf[b:])) - b += 4 + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) return b } -// PictvisualReadList reads a byte slice into a list of Pictvisual values. -func PictvisualReadList(buf []byte, dest []Pictvisual) int { +// LinefixReadList reads a byte slice into a list of Linefix values. +func LinefixReadList(buf []byte, dest []Linefix) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Pictvisual{} - b += PictvisualRead(buf[b:], &dest[i]) + dest[i] = Linefix{} + b += LinefixRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Pictvisual value to a byte slice. -func (v Pictvisual) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a Linefix value to a byte slice. +func (v Linefix) Bytes() []byte { + buf := make([]byte, 16) b := 0 - xgb.Put32(buf[b:], uint32(v.Visual)) - b += 4 + { + structBytes := v.P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - xgb.Put32(buf[b:], uint32(v.Format)) - b += 4 + { + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// PictvisualListBytes writes a list of Pictvisual values to a byte slice. -func PictvisualListBytes(buf []byte, list []Pictvisual) int { +// LinefixListBytes writes a list of Linefix values to a byte slice. +func LinefixListBytes(buf []byte, list []Linefix) int { b := 0 var structBytes []byte for _, item := range list { @@ -438,6 +597,159 @@ func PictvisualListBytes(buf []byte, list []Pictvisual) int { return b } +// BadPictFormat is the error number for a BadPictFormat. +const BadPictFormat = 0 + +type PictFormatError struct { + Sequence uint16 + NiceName string +} + +// PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice. +func PictFormatErrorNew(buf []byte) xgb.Error { + v := PictFormatError{} + v.NiceName = "PictFormat" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadPictFormat error. +// This is mostly used internally. +func (err PictFormatError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadPictFormat error. If no bad value exists, 0 is returned. +func (err PictFormatError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadPictFormat error. + +func (err PictFormatError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictFormat {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew +} + +// BadPictOp is the error number for a BadPictOp. +const BadPictOp = 2 + +type PictOpError struct { + Sequence uint16 + NiceName string +} + +// PictOpErrorNew constructs a PictOpError value that implements xgb.Error from a byte slice. +func PictOpErrorNew(buf []byte) xgb.Error { + v := PictOpError{} + v.NiceName = "PictOp" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadPictOp error. +// This is mostly used internally. +func (err PictOpError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadPictOp error. If no bad value exists, 0 is returned. +func (err PictOpError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadPictOp error. + +func (err PictOpError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew +} + +const ( + PictOpClear = 0 + PictOpSrc = 1 + PictOpDst = 2 + PictOpOver = 3 + PictOpOverReverse = 4 + PictOpIn = 5 + PictOpInReverse = 6 + PictOpOut = 7 + PictOpOutReverse = 8 + PictOpAtop = 9 + PictOpAtopReverse = 10 + PictOpXor = 11 + PictOpAdd = 12 + PictOpSaturate = 13 + PictOpDisjointClear = 16 + PictOpDisjointSrc = 17 + PictOpDisjointDst = 18 + PictOpDisjointOver = 19 + PictOpDisjointOverReverse = 20 + PictOpDisjointIn = 21 + PictOpDisjointInReverse = 22 + PictOpDisjointOut = 23 + PictOpDisjointOutReverse = 24 + PictOpDisjointAtop = 25 + PictOpDisjointAtopReverse = 26 + PictOpDisjointXor = 27 + PictOpConjointClear = 32 + PictOpConjointSrc = 33 + PictOpConjointDst = 34 + PictOpConjointOver = 35 + PictOpConjointOverReverse = 36 + PictOpConjointIn = 37 + PictOpConjointInReverse = 38 + PictOpConjointOut = 39 + PictOpConjointOutReverse = 40 + PictOpConjointAtop = 41 + PictOpConjointAtopReverse = 42 + PictOpConjointXor = 43 + PictOpMultiply = 48 + PictOpScreen = 49 + PictOpOverlay = 50 + PictOpDarken = 51 + PictOpLighten = 52 + PictOpColorDodge = 53 + PictOpColorBurn = 54 + PictOpHardLight = 55 + PictOpSoftLight = 56 + PictOpDifference = 57 + PictOpExclusion = 58 + PictOpHSLHue = 59 + PictOpHSLSaturation = 60 + PictOpHSLColor = 61 + PictOpHSLLuminosity = 62 +) + +const ( + PictTypeIndexed = 0 + PictTypeDirect = 1 +) + type Pictdepth struct { Depth byte // padding: 1 bytes @@ -517,6 +829,99 @@ func PictdepthListSize(list []Pictdepth) int { return size } +type Pictformat uint32 + +func NewPictformatId(c *xgb.Conn) (Pictformat, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pictformat(id), nil +} + +type Pictforminfo struct { + Id Pictformat + Type byte + Depth byte + // padding: 2 bytes + Direct Directformat + Colormap xproto.Colormap +} + +// PictforminfoRead reads a byte slice into a Pictforminfo value. +func PictforminfoRead(buf []byte, v *Pictforminfo) int { + b := 0 + + v.Id = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + v.Type = buf[b] + b += 1 + + v.Depth = buf[b] + b += 1 + + b += 2 // padding + + v.Direct = Directformat{} + b += DirectformatRead(buf[b:], &v.Direct) + + v.Colormap = xproto.Colormap(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// PictforminfoReadList reads a byte slice into a list of Pictforminfo values. +func PictforminfoReadList(buf []byte, dest []Pictforminfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictforminfo{} + b += PictforminfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Pictforminfo value to a byte slice. +func (v Pictforminfo) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Id)) + b += 4 + + buf[b] = v.Type + b += 1 + + buf[b] = v.Depth + b += 1 + + b += 2 // padding + + { + structBytes := v.Direct.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + return buf +} + +// PictforminfoListBytes writes a list of Pictforminfo values to a byte slice. +func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + type Pictscreen struct { NumDepths uint32 Fallback Pictformat @@ -586,139 +991,110 @@ func PictscreenListSize(list []Pictscreen) int { return size } -type Indexvalue struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 -} +type Picture uint32 -// IndexvalueRead reads a byte slice into a Indexvalue value. -func IndexvalueRead(buf []byte, v *Indexvalue) int { - b := 0 +func NewPictureId(c *xgb.Conn) (Picture, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Picture(id), nil +} - v.Pixel = xgb.Get32(buf[b:]) - b += 4 +// BadPicture is the error number for a BadPicture. +const BadPicture = 1 - v.Red = xgb.Get16(buf[b:]) - b += 2 +type PictureError struct { + Sequence uint16 + NiceName string +} - v.Green = xgb.Get16(buf[b:]) - b += 2 +// PictureErrorNew constructs a PictureError value that implements xgb.Error from a byte slice. +func PictureErrorNew(buf []byte) xgb.Error { + v := PictureError{} + v.NiceName = "Picture" - v.Blue = xgb.Get16(buf[b:]) - b += 2 + b := 1 // skip error determinant + b += 1 // don't read error number - v.Alpha = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - return b + return v } -// IndexvalueReadList reads a byte slice into a list of Indexvalue values. -func IndexvalueReadList(buf []byte, dest []Indexvalue) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Indexvalue{} - b += IndexvalueRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the BadPicture error. +// This is mostly used internally. +func (err PictureError) SequenceId() uint16 { + return err.Sequence } -// Bytes writes a Indexvalue value to a byte slice. -func (v Indexvalue) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - xgb.Put32(buf[b:], v.Pixel) - b += 4 - - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 - - xgb.Put16(buf[b:], v.Blue) - b += 2 +// BadId returns the 'BadValue' number if one exists for the BadPicture error. If no bad value exists, 0 is returned. +func (err PictureError) BadId() uint32 { + return 0 +} - xgb.Put16(buf[b:], v.Alpha) - b += 2 +// Error returns a rudimentary string representation of the BadPicture error. - return buf +func (err PictureError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPicture {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// IndexvalueListBytes writes a list of Indexvalue values to a byte slice. -func IndexvalueListBytes(buf []byte, list []Indexvalue) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +func init() { + xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew } -type Color struct { - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 +const ( + PictureNone = 0 +) + +type Pictvisual struct { + Visual xproto.Visualid + Format Pictformat } -// ColorRead reads a byte slice into a Color value. -func ColorRead(buf []byte, v *Color) int { +// PictvisualRead reads a byte slice into a Pictvisual value. +func PictvisualRead(buf []byte, v *Pictvisual) int { b := 0 - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 - - v.Blue = xgb.Get16(buf[b:]) - b += 2 + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 - v.Alpha = xgb.Get16(buf[b:]) - b += 2 + v.Format = Pictformat(xgb.Get32(buf[b:])) + b += 4 return b } -// ColorReadList reads a byte slice into a list of Color values. -func ColorReadList(buf []byte, dest []Color) int { +// PictvisualReadList reads a byte slice into a list of Pictvisual values. +func PictvisualReadList(buf []byte, dest []Pictvisual) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Color{} - b += ColorRead(buf[b:], &dest[i]) + dest[i] = Pictvisual{} + b += PictvisualRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Color value to a byte slice. -func (v Color) Bytes() []byte { +// Bytes writes a Pictvisual value to a byte slice. +func (v Pictvisual) Bytes() []byte { buf := make([]byte, 8) b := 0 - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 - - xgb.Put16(buf[b:], v.Blue) - b += 2 + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 - xgb.Put16(buf[b:], v.Alpha) - b += 2 + xgb.Put32(buf[b:], uint32(v.Format)) + b += 4 return buf } -// ColorListBytes writes a list of Color values to a byte slice. -func ColorListBytes(buf []byte, list []Color) int { +// PictvisualListBytes writes a list of Pictvisual values to a byte slice. +func PictvisualListBytes(buf []byte, list []Pictvisual) int { b := 0 var structBytes []byte for _, item := range list { @@ -783,200 +1159,74 @@ func PointfixListBytes(buf []byte, list []Pointfix) int { return b } -type Linefix struct { - P1 Pointfix - P2 Pointfix -} - -// LinefixRead reads a byte slice into a Linefix value. -func LinefixRead(buf []byte, v *Linefix) int { - b := 0 - - v.P1 = Pointfix{} - b += PointfixRead(buf[b:], &v.P1) - - v.P2 = Pointfix{} - b += PointfixRead(buf[b:], &v.P2) - - return b -} - -// LinefixReadList reads a byte slice into a list of Linefix values. -func LinefixReadList(buf []byte, dest []Linefix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Linefix{} - b += LinefixRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Linefix value to a byte slice. -func (v Linefix) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - return buf -} - -// LinefixListBytes writes a list of Linefix values to a byte slice. -func LinefixListBytes(buf []byte, list []Linefix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Triangle struct { - P1 Pointfix - P2 Pointfix - P3 Pointfix -} - -// TriangleRead reads a byte slice into a Triangle value. -func TriangleRead(buf []byte, v *Triangle) int { - b := 0 - - v.P1 = Pointfix{} - b += PointfixRead(buf[b:], &v.P1) - - v.P2 = Pointfix{} - b += PointfixRead(buf[b:], &v.P2) - - v.P3 = Pointfix{} - b += PointfixRead(buf[b:], &v.P3) - - return b -} - -// TriangleReadList reads a byte slice into a list of Triangle values. -func TriangleReadList(buf []byte, dest []Triangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Triangle{} - b += TriangleRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Triangle value to a byte slice. -func (v Triangle) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.P3.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } +const ( + PolyEdgeSharp = 0 + PolyEdgeSmooth = 1 +) - return buf -} +const ( + PolyModePrecise = 0 + PolyModeImprecise = 1 +) -// TriangleListBytes writes a list of Triangle values to a byte slice. -func TriangleListBytes(buf []byte, list []Triangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} +const ( + RepeatNone = 0 + RepeatNormal = 1 + RepeatPad = 2 + RepeatReflect = 3 +) -type Trapezoid struct { - Top Fixed - Bottom Fixed - Left Linefix - Right Linefix +type Spanfix struct { + L Fixed + R Fixed + Y Fixed } -// TrapezoidRead reads a byte slice into a Trapezoid value. -func TrapezoidRead(buf []byte, v *Trapezoid) int { +// SpanfixRead reads a byte slice into a Spanfix value. +func SpanfixRead(buf []byte, v *Spanfix) int { b := 0 - v.Top = Fixed(xgb.Get32(buf[b:])) + v.L = Fixed(xgb.Get32(buf[b:])) b += 4 - v.Bottom = Fixed(xgb.Get32(buf[b:])) + v.R = Fixed(xgb.Get32(buf[b:])) b += 4 - v.Left = Linefix{} - b += LinefixRead(buf[b:], &v.Left) - - v.Right = Linefix{} - b += LinefixRead(buf[b:], &v.Right) + v.Y = Fixed(xgb.Get32(buf[b:])) + b += 4 return b } -// TrapezoidReadList reads a byte slice into a list of Trapezoid values. -func TrapezoidReadList(buf []byte, dest []Trapezoid) int { +// SpanfixReadList reads a byte slice into a list of Spanfix values. +func SpanfixReadList(buf []byte, dest []Spanfix) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Trapezoid{} - b += TrapezoidRead(buf[b:], &dest[i]) + dest[i] = Spanfix{} + b += SpanfixRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Trapezoid value to a byte slice. -func (v Trapezoid) Bytes() []byte { - buf := make([]byte, 40) +// Bytes writes a Spanfix value to a byte slice. +func (v Spanfix) Bytes() []byte { + buf := make([]byte, 12) b := 0 - xgb.Put32(buf[b:], uint32(v.Top)) + xgb.Put32(buf[b:], uint32(v.L)) b += 4 - xgb.Put32(buf[b:], uint32(v.Bottom)) + xgb.Put32(buf[b:], uint32(v.R)) b += 4 - { - structBytes := v.Left.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.Right.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + xgb.Put32(buf[b:], uint32(v.Y)) + b += 4 return buf } -// TrapezoidListBytes writes a list of Trapezoid values to a byte slice. -func TrapezoidListBytes(buf []byte, list []Trapezoid) int { +// SpanfixListBytes writes a list of Spanfix values to a byte slice. +func SpanfixListBytes(buf []byte, list []Spanfix) int { b := 0 var structBytes []byte for _, item := range list { @@ -987,87 +1237,14 @@ func TrapezoidListBytes(buf []byte, list []Trapezoid) int { return b } -type Glyphinfo struct { - Width uint16 - Height uint16 - X int16 - Y int16 - XOff int16 - YOff int16 -} - -// GlyphinfoRead reads a byte slice into a Glyphinfo value. -func GlyphinfoRead(buf []byte, v *Glyphinfo) int { - b := 0 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.XOff = int16(xgb.Get16(buf[b:])) - b += 2 - - v.YOff = int16(xgb.Get16(buf[b:])) - b += 2 - - return b -} - -// GlyphinfoReadList reads a byte slice into a list of Glyphinfo values. -func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Glyphinfo{} - b += GlyphinfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Glyphinfo value to a byte slice. -func (v Glyphinfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.XOff)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.YOff)) - b += 2 - - return buf -} - -// GlyphinfoListBytes writes a list of Glyphinfo values to a byte slice. -func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} +const ( + SubPixelUnknown = 0 + SubPixelHorizontalRGB = 1 + SubPixelHorizontalBGR = 2 + SubPixelVerticalRGB = 3 + SubPixelVerticalBGR = 4 + SubPixelNone = 5 +) type Transform struct { Matrix11 Fixed @@ -1172,50 +1349,56 @@ func TransformListBytes(buf []byte, list []Transform) int { return b } -type Animcursorelt struct { - Cursor xproto.Cursor - Delay uint32 +type Trap struct { + Top Spanfix + Bot Spanfix } -// AnimcursoreltRead reads a byte slice into a Animcursorelt value. -func AnimcursoreltRead(buf []byte, v *Animcursorelt) int { +// TrapRead reads a byte slice into a Trap value. +func TrapRead(buf []byte, v *Trap) int { b := 0 - v.Cursor = xproto.Cursor(xgb.Get32(buf[b:])) - b += 4 + v.Top = Spanfix{} + b += SpanfixRead(buf[b:], &v.Top) - v.Delay = xgb.Get32(buf[b:]) - b += 4 + v.Bot = Spanfix{} + b += SpanfixRead(buf[b:], &v.Bot) return b } -// AnimcursoreltReadList reads a byte slice into a list of Animcursorelt values. -func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int { +// TrapReadList reads a byte slice into a list of Trap values. +func TrapReadList(buf []byte, dest []Trap) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Animcursorelt{} - b += AnimcursoreltRead(buf[b:], &dest[i]) + dest[i] = Trap{} + b += TrapRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Animcursorelt value to a byte slice. -func (v Animcursorelt) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a Trap value to a byte slice. +func (v Trap) Bytes() []byte { + buf := make([]byte, 24) b := 0 - xgb.Put32(buf[b:], uint32(v.Cursor)) - b += 4 + { + structBytes := v.Top.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - xgb.Put32(buf[b:], v.Delay) - b += 4 + { + structBytes := v.Bot.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// AnimcursoreltListBytes writes a list of Animcursorelt values to a byte slice. -func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int { +// TrapListBytes writes a list of Trap values to a byte slice. +func TrapListBytes(buf []byte, list []Trap) int { b := 0 var structBytes []byte for _, item := range list { @@ -1226,57 +1409,70 @@ func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int { return b } -type Spanfix struct { - L Fixed - R Fixed - Y Fixed +type Trapezoid struct { + Top Fixed + Bottom Fixed + Left Linefix + Right Linefix } -// SpanfixRead reads a byte slice into a Spanfix value. -func SpanfixRead(buf []byte, v *Spanfix) int { +// TrapezoidRead reads a byte slice into a Trapezoid value. +func TrapezoidRead(buf []byte, v *Trapezoid) int { b := 0 - v.L = Fixed(xgb.Get32(buf[b:])) + v.Top = Fixed(xgb.Get32(buf[b:])) b += 4 - v.R = Fixed(xgb.Get32(buf[b:])) + v.Bottom = Fixed(xgb.Get32(buf[b:])) b += 4 - v.Y = Fixed(xgb.Get32(buf[b:])) - b += 4 + v.Left = Linefix{} + b += LinefixRead(buf[b:], &v.Left) + + v.Right = Linefix{} + b += LinefixRead(buf[b:], &v.Right) return b } -// SpanfixReadList reads a byte slice into a list of Spanfix values. -func SpanfixReadList(buf []byte, dest []Spanfix) int { +// TrapezoidReadList reads a byte slice into a list of Trapezoid values. +func TrapezoidReadList(buf []byte, dest []Trapezoid) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Spanfix{} - b += SpanfixRead(buf[b:], &dest[i]) + dest[i] = Trapezoid{} + b += TrapezoidRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Spanfix value to a byte slice. -func (v Spanfix) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a Trapezoid value to a byte slice. +func (v Trapezoid) Bytes() []byte { + buf := make([]byte, 40) b := 0 - xgb.Put32(buf[b:], uint32(v.L)) + xgb.Put32(buf[b:], uint32(v.Top)) b += 4 - xgb.Put32(buf[b:], uint32(v.R)) + xgb.Put32(buf[b:], uint32(v.Bottom)) b += 4 - xgb.Put32(buf[b:], uint32(v.Y)) - b += 4 + { + structBytes := v.Left.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Right.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// SpanfixListBytes writes a list of Spanfix values to a byte slice. -func SpanfixListBytes(buf []byte, list []Spanfix) int { +// TrapezoidListBytes writes a list of Trapezoid values to a byte slice. +func TrapezoidListBytes(buf []byte, list []Trapezoid) int { b := 0 var structBytes []byte for _, item := range list { @@ -1287,47 +1483,57 @@ func SpanfixListBytes(buf []byte, list []Spanfix) int { return b } -type Trap struct { - Top Spanfix - Bot Spanfix +type Triangle struct { + P1 Pointfix + P2 Pointfix + P3 Pointfix } -// TrapRead reads a byte slice into a Trap value. -func TrapRead(buf []byte, v *Trap) int { +// TriangleRead reads a byte slice into a Triangle value. +func TriangleRead(buf []byte, v *Triangle) int { b := 0 - v.Top = Spanfix{} - b += SpanfixRead(buf[b:], &v.Top) + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) - v.Bot = Spanfix{} - b += SpanfixRead(buf[b:], &v.Bot) + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) + + v.P3 = Pointfix{} + b += PointfixRead(buf[b:], &v.P3) return b } -// TrapReadList reads a byte slice into a list of Trap values. -func TrapReadList(buf []byte, dest []Trap) int { +// TriangleReadList reads a byte slice into a list of Triangle values. +func TriangleReadList(buf []byte, dest []Triangle) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Trap{} - b += TrapRead(buf[b:], &dest[i]) + dest[i] = Triangle{} + b += TriangleRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Trap value to a byte slice. -func (v Trap) Bytes() []byte { +// Bytes writes a Triangle value to a byte slice. +func (v Triangle) Bytes() []byte { buf := make([]byte, 24) b := 0 { - structBytes := v.Top.Bytes() + structBytes := v.P1.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } { - structBytes := v.Bot.Bytes() + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P3.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } @@ -1335,8 +1541,8 @@ func (v Trap) Bytes() []byte { return buf } -// TrapListBytes writes a list of Trap values to a byte slice. -func TrapListBytes(buf []byte, list []Trap) int { +// TriangleListBytes writes a list of Triangle values to a byte slice. +func TriangleListBytes(buf []byte, list []Triangle) int { b := 0 var structBytes []byte for _, item := range list { @@ -1347,614 +1553,158 @@ func TrapListBytes(buf []byte, list []Trap) int { return b } -// BadPictFormat is the error number for a BadPictFormat. -const BadPictFormat = 0 - -type PictFormatError struct { - Sequence uint16 - NiceName string -} - -// PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice. -func PictFormatErrorNew(buf []byte) xgb.Error { - v := PictFormatError{} - v.NiceName = "PictFormat" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadPictFormat error. -// This is mostly used internally. -func (err PictFormatError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadPictFormat error. If no bad value exists, 0 is returned. -func (err PictFormatError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadPictFormat error. - -func (err PictFormatError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadPictFormat {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew -} - -// BadPicture is the error number for a BadPicture. -const BadPicture = 1 - -type PictureError struct { - Sequence uint16 - NiceName string -} - -// PictureErrorNew constructs a PictureError value that implements xgb.Error from a byte slice. -func PictureErrorNew(buf []byte) xgb.Error { - v := PictureError{} - v.NiceName = "Picture" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadPicture error. -// This is mostly used internally. -func (err PictureError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadPicture error. If no bad value exists, 0 is returned. -func (err PictureError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadPicture error. - -func (err PictureError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadPicture {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew -} - -// BadPictOp is the error number for a BadPictOp. -const BadPictOp = 2 - -type PictOpError struct { - Sequence uint16 - NiceName string -} - -// PictOpErrorNew constructs a PictOpError value that implements xgb.Error from a byte slice. -func PictOpErrorNew(buf []byte) xgb.Error { - v := PictOpError{} - v.NiceName = "PictOp" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadPictOp error. -// This is mostly used internally. -func (err PictOpError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadPictOp error. If no bad value exists, 0 is returned. -func (err PictOpError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadPictOp error. - -func (err PictOpError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew -} - -// BadGlyphSet is the error number for a BadGlyphSet. -const BadGlyphSet = 3 - -type GlyphSetError struct { - Sequence uint16 - NiceName string -} - -// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice. -func GlyphSetErrorNew(buf []byte) xgb.Error { - v := GlyphSetError{} - v.NiceName = "GlyphSet" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadGlyphSet error. -// This is mostly used internally. -func (err GlyphSetError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadGlyphSet error. If no bad value exists, 0 is returned. -func (err GlyphSetError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadGlyphSet error. - -func (err GlyphSetError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadGlyphSet {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew -} +// Skipping definition for base type 'Bool' -// BadGlyph is the error number for a BadGlyph. -const BadGlyph = 4 +// Skipping definition for base type 'Byte' -type GlyphError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Card8' -// GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice. -func GlyphErrorNew(buf []byte) xgb.Error { - v := GlyphError{} - v.NiceName = "Glyph" +// Skipping definition for base type 'Char' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Void' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Double' - return v -} +// Skipping definition for base type 'Float' -// SequenceId returns the sequence id attached to the BadGlyph error. -// This is mostly used internally. -func (err GlyphError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Int16' -// BadId returns the 'BadValue' number if one exists for the BadGlyph error. If no bad value exists, 0 is returned. -func (err GlyphError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Int32' -// Error returns a rudimentary string representation of the BadGlyph error. +// Skipping definition for base type 'Int8' -func (err GlyphError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadGlyph {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Card16' -func init() { - xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew -} +// Skipping definition for base type 'Card32' -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// AddGlyphsCookie is a cookie used only for AddGlyphs requests. +type AddGlyphsCookie 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionUnchecked sends an unchecked request. +// AddGlyphs sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { +func AddGlyphs(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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 - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) + return AddGlyphsCookie{cookie} } -// 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 +// AddGlyphsChecked sends a checked request. +// If an error occurs, it can be retrieved using AddGlyphsCookie.Check() +func AddGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } - return queryVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) + return AddGlyphsCookie{cookie} } -// 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.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - 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 AddGlyphsCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 +// Write request to wire for AddGlyphs +// addGlyphsRequest writes a AddGlyphs request to a byte slice. +func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte { + size := xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 20 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ClientMajorVersion) - b += 4 - - xgb.Put32(buf[b:], ClientMinorVersion) - b += 4 - - return buf -} - -// QueryPictFormatsCookie is a cookie used only for QueryPictFormats requests. -type QueryPictFormatsCookie struct { - *xgb.Cookie -} - -// QueryPictFormats sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryPictFormatsCookie.Reply() -func QueryPictFormats(c *xgb.Conn) QueryPictFormatsCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryPictFormatsRequest(c), cookie) - return QueryPictFormatsCookie{cookie} -} - -// QueryPictFormatsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryPictFormatsUnchecked(c *xgb.Conn) QueryPictFormatsCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryPictFormatsRequest(c), cookie) - return QueryPictFormatsCookie{cookie} -} - -// QueryPictFormatsReply represents the data returned from a QueryPictFormats request. -type QueryPictFormatsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumFormats uint32 - NumScreens uint32 - NumDepths uint32 - NumVisuals uint32 - NumSubpixel uint32 - // padding: 4 bytes - Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28)) - Screens []Pictscreen // size: PictscreenListSize(Screens) - Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4)) -} - -// Reply blocks and returns the reply data for a QueryPictFormats request. -func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryPictFormatsReply(buf), nil -} - -// queryPictFormatsReply reads a byte slice into a QueryPictFormatsReply value. -func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { - v := new(QueryPictFormatsReply) - 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.NumFormats = xgb.Get32(buf[b:]) - b += 4 - - v.NumScreens = xgb.Get32(buf[b:]) - b += 4 - - v.NumDepths = xgb.Get32(buf[b:]) - b += 4 - - v.NumVisuals = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(Glyphset)) b += 4 - v.NumSubpixel = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], GlyphsLen) b += 4 - b += 4 // padding - - v.Formats = make([]Pictforminfo, v.NumFormats) - b += PictforminfoReadList(buf[b:], v.Formats) - - v.Screens = make([]Pictscreen, v.NumScreens) - b += PictscreenReadList(buf[b:], v.Screens) - - v.Subpixels = make([]uint32, v.NumSubpixel) - for i := 0; i < int(v.NumSubpixel); i++ { - v.Subpixels[i] = xgb.Get32(buf[b:]) + for i := 0; i < int(GlyphsLen); i++ { + xgb.Put32(buf[b:], Glyphids[i]) b += 4 } b = xgb.Pad(b) - return v -} - -// Write request to wire for QueryPictFormats -// queryPictFormatsRequest writes a QueryPictFormats request to a byte slice. -func queryPictFormatsRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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 - - return buf -} - -// QueryPictIndexValuesCookie is a cookie used only for QueryPictIndexValues requests. -type QueryPictIndexValuesCookie struct { - *xgb.Cookie -} - -// QueryPictIndexValues sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryPictIndexValuesCookie.Reply() -func QueryPictIndexValues(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) - return QueryPictIndexValuesCookie{cookie} -} - -// QueryPictIndexValuesUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryPictIndexValuesUnchecked(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) - return QueryPictIndexValuesCookie{cookie} -} - -// QueryPictIndexValuesReply represents the data returned from a QueryPictIndexValues request. -type QueryPictIndexValuesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumValues uint32 - // padding: 20 bytes - Values []Indexvalue // size: xgb.Pad((int(NumValues) * 12)) -} - -// Reply blocks and returns the reply data for a QueryPictIndexValues request. -func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryPictIndexValuesReply(buf), nil -} - -// queryPictIndexValuesReply reads a byte slice into a QueryPictIndexValuesReply value. -func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply { - v := new(QueryPictIndexValuesReply) - 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.NumValues = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Values = make([]Indexvalue, v.NumValues) - b += IndexvalueReadList(buf[b:], v.Values) - - return v -} - -// Write request to wire for QueryPictIndexValues -// queryPictIndexValuesRequest writes a QueryPictIndexValues request to a byte slice. -func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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 + b += GlyphinfoListBytes(buf[b:], Glyphs) - xgb.Put32(buf[b:], uint32(Format)) - b += 4 + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) return buf } -// CreatePictureCookie is a cookie used only for CreatePicture requests. -type CreatePictureCookie struct { +// AddTrapsCookie is a cookie used only for AddTraps requests. +type AddTrapsCookie struct { *xgb.Cookie } -// CreatePicture sends an unchecked request. +// AddTraps sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { +func AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) - return CreatePictureCookie{cookie} + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{cookie} } -// CreatePictureChecked sends a checked request. -// If an error occurs, it can be retrieved using CreatePictureCookie.Check() -func CreatePictureChecked(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { +// AddTrapsChecked sends a checked request. +// If an error occurs, it can be retrieved using AddTrapsCookie.Check() +func AddTrapsChecked(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) - return CreatePictureCookie{cookie} + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{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 CreatePictureCookie) Check() error { +func (cook AddTrapsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreatePicture -// createPictureRequest writes a CreatePicture request to a byte slice. -func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for AddTraps +// addTrapsRequest writes a AddTraps request to a byte slice. +func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 32 // 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(Pid)) + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 + xgb.Put16(buf[b:], uint16(XOff)) + b += 2 - xgb.Put32(buf[b:], uint32(Format)) - b += 4 + xgb.Put16(buf[b:], uint16(YOff)) + b += 2 - xgb.Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + b += TrapListBytes(buf[b:], Traps) return buf } @@ -2022,124 +1772,6 @@ func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueL return buf } -// SetPictureClipRectanglesCookie is a cookie used only for SetPictureClipRectangles requests. -type SetPictureClipRectanglesCookie struct { - *xgb.Cookie -} - -// SetPictureClipRectangles sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetPictureClipRectanglesCookie{cookie} -} - -// SetPictureClipRectanglesChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPictureClipRectanglesCookie.Check() -func SetPictureClipRectanglesChecked(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetPictureClipRectanglesCookie{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 SetPictureClipRectanglesCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPictureClipRectangles -// setPictureClipRectanglesRequest writes a SetPictureClipRectangles request to a byte slice. -func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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:], uint32(Picture)) - b += 4 - - xgb.Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += xproto.RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// FreePictureCookie is a cookie used only for FreePicture requests. -type FreePictureCookie struct { - *xgb.Cookie -} - -// FreePicture sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(freePictureRequest(c, Picture), cookie) - return FreePictureCookie{cookie} -} - -// FreePictureChecked sends a checked request. -// If an error occurs, it can be retrieved using FreePictureCookie.Check() -func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(freePictureRequest(c, Picture), cookie) - return FreePictureCookie{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 FreePictureCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FreePicture -// freePictureRequest writes a FreePicture request to a byte slice. -func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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:], uint32(Picture)) - b += 4 - - return buf -} - // CompositeCookie is a cookie used only for Composite requests. type CompositeCookie struct { *xgb.Cookie @@ -2230,50 +1862,50 @@ func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Pictu return buf } -// TrapezoidsCookie is a cookie used only for Trapezoids requests. -type TrapezoidsCookie struct { +// CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests. +type CompositeGlyphs16Cookie struct { *xgb.Cookie } -// Trapezoids sends an unchecked request. +// CompositeGlyphs16 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { +func CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) - return TrapezoidsCookie{cookie} + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{cookie} } -// TrapezoidsChecked sends a checked request. -// If an error occurs, it can be retrieved using TrapezoidsCookie.Check() -func TrapezoidsChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { +// CompositeGlyphs16Checked sends a checked request. +// If an error occurs, it can be retrieved using CompositeGlyphs16Cookie.Check() +func CompositeGlyphs16Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) - return TrapezoidsCookie{cookie} + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{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 TrapezoidsCookie) Check() error { +func (cook CompositeGlyphs16Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Trapezoids -// trapezoidsRequest writes a Trapezoids request to a byte slice. -func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) []byte { - size := xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) +// Write request to wire for CompositeGlyphs16 +// compositeGlyphs16Request writes a CompositeGlyphs16 request to a byte slice. +func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 24 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2293,61 +1925,65 @@ func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskForma xgb.Put32(buf[b:], uint32(MaskFormat)) b += 4 + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - b += TrapezoidListBytes(buf[b:], Traps) + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) return buf } -// TrianglesCookie is a cookie used only for Triangles requests. -type TrianglesCookie struct { +// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests. +type CompositeGlyphs32Cookie struct { *xgb.Cookie } -// Triangles sends an unchecked request. +// CompositeGlyphs32 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { +func CompositeGlyphs32(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return TrianglesCookie{cookie} + c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs32Cookie{cookie} } -// TrianglesChecked sends a checked request. -// If an error occurs, it can be retrieved using TrianglesCookie.Check() -func TrianglesChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { +// CompositeGlyphs32Checked sends a checked request. +// If an error occurs, it can be retrieved using CompositeGlyphs32Cookie.Check() +func CompositeGlyphs32Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return TrianglesCookie{cookie} + c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs32Cookie{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 TrianglesCookie) Check() error { +func (cook CompositeGlyphs32Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Triangles -// trianglesRequest writes a Triangles request to a byte slice. -func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) []byte { - size := xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) +// Write request to wire for CompositeGlyphs32 +// compositeGlyphs32Request writes a CompositeGlyphs32 request to a byte slice. +func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 25 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2367,61 +2003,65 @@ func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat xgb.Put32(buf[b:], uint32(MaskFormat)) b += 4 + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - b += TriangleListBytes(buf[b:], Triangles) + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) return buf } -// TriStripCookie is a cookie used only for TriStrip requests. -type TriStripCookie struct { +// CompositeGlyphs8Cookie is a cookie used only for CompositeGlyphs8 requests. +type CompositeGlyphs8Cookie struct { *xgb.Cookie } -// TriStrip sends an unchecked request. +// CompositeGlyphs8 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { +func CompositeGlyphs8(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriStripCookie{cookie} + c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs8Cookie{cookie} } -// TriStripChecked sends a checked request. -// If an error occurs, it can be retrieved using TriStripCookie.Check() -func TriStripChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { +// CompositeGlyphs8Checked sends a checked request. +// If an error occurs, it can be retrieved using CompositeGlyphs8Cookie.Check() +func CompositeGlyphs8Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriStripCookie{cookie} + c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs8Cookie{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 TriStripCookie) Check() error { +func (cook CompositeGlyphs8Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for TriStrip -// triStripRequest writes a TriStrip request to a byte slice. -func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { - size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +// Write request to wire for CompositeGlyphs8 +// compositeGlyphs8Request writes a CompositeGlyphs8 request to a byte slice. +func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 23 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2441,385 +2081,415 @@ func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat xgb.Put32(buf[b:], uint32(MaskFormat)) b += 4 + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - b += PointfixListBytes(buf[b:], Points) + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) return buf } -// TriFanCookie is a cookie used only for TriFan requests. -type TriFanCookie struct { +// CreateAnimCursorCookie is a cookie used only for CreateAnimCursor requests. +type CreateAnimCursorCookie struct { *xgb.Cookie } -// TriFan sends an unchecked request. +// CreateAnimCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { +func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriFanCookie{cookie} + c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) + return CreateAnimCursorCookie{cookie} } -// TriFanChecked sends a checked request. -// If an error occurs, it can be retrieved using TriFanCookie.Check() -func TriFanChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { +// CreateAnimCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateAnimCursorCookie.Check() +func CreateAnimCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriFanCookie{cookie} + c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) + return CreateAnimCursorCookie{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 TriFanCookie) Check() error { +func (cook CreateAnimCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for TriFan -// triFanRequest writes a TriFan request to a byte slice. -func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { - size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +// Write request to wire for CreateAnimCursor +// createAnimCursorRequest writes a CreateAnimCursor request to a byte slice. +func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 31 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Src)) - b += 4 - - xgb.Put32(buf[b:], uint32(Dst)) - b += 4 - - xgb.Put32(buf[b:], uint32(MaskFormat)) + xgb.Put32(buf[b:], uint32(Cid)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += PointfixListBytes(buf[b:], Points) + b += AnimcursoreltListBytes(buf[b:], Cursors) return buf } -// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests. -type CreateGlyphSetCookie struct { +// CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests. +type CreateConicalGradientCookie struct { *xgb.Cookie } -// CreateGlyphSet sends an unchecked request. +// CreateConicalGradient sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { +func CreateConicalGradient(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) - return CreateGlyphSetCookie{cookie} + c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) + return CreateConicalGradientCookie{cookie} } -// CreateGlyphSetChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateGlyphSetCookie.Check() -func CreateGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { +// CreateConicalGradientChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateConicalGradientCookie.Check() +func CreateConicalGradientChecked(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) - return CreateGlyphSetCookie{cookie} + c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) + return CreateConicalGradientCookie{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 CreateGlyphSetCookie) Check() error { +func (cook CreateConicalGradientCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateGlyphSet -// createGlyphSetRequest writes a CreateGlyphSet request to a byte slice. -func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte { - size := 12 +// Write request to wire for CreateConicalGradient +// createConicalGradientRequest writes a CreateConicalGradient request to a byte slice. +func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 17 // request opcode + buf[b] = 36 // 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(Gsid)) + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put32(buf[b:], uint32(Format)) + { + structBytes := Center.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(Angle)) + b += 4 + + xgb.Put32(buf[b:], NumStops) b += 4 + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + return buf } -// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests. -type ReferenceGlyphSetCookie struct { +// CreateCursorCookie is a cookie used only for CreateCursor requests. +type CreateCursorCookie struct { *xgb.Cookie } -// ReferenceGlyphSet sends an unchecked request. +// CreateCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { +func CreateCursor(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) - return ReferenceGlyphSetCookie{cookie} + c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) + return CreateCursorCookie{cookie} } -// ReferenceGlyphSetChecked sends a checked request. -// If an error occurs, it can be retrieved using ReferenceGlyphSetCookie.Check() -func ReferenceGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { +// CreateCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCursorCookie.Check() +func CreateCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) - return ReferenceGlyphSetCookie{cookie} + c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) + return CreateCursorCookie{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 ReferenceGlyphSetCookie) Check() error { +func (cook CreateCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ReferenceGlyphSet -// referenceGlyphSetRequest writes a ReferenceGlyphSet request to a byte slice. -func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []byte { - size := 12 +// Write request to wire for CreateCursor +// createCursorRequest writes a CreateCursor request to a byte slice. +func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 27 // 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(Gsid)) + xgb.Put32(buf[b:], uint32(Cid)) b += 4 - xgb.Put32(buf[b:], uint32(Existing)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + return buf } -// FreeGlyphSetCookie is a cookie used only for FreeGlyphSet requests. -type FreeGlyphSetCookie struct { +// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests. +type CreateGlyphSetCookie struct { *xgb.Cookie } -// FreeGlyphSet sends an unchecked request. +// CreateGlyphSet sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { +func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) - return FreeGlyphSetCookie{cookie} + c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) + return CreateGlyphSetCookie{cookie} } -// FreeGlyphSetChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeGlyphSetCookie.Check() -func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { +// CreateGlyphSetChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGlyphSetCookie.Check() +func CreateGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) - return FreeGlyphSetCookie{cookie} + c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) + return CreateGlyphSetCookie{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 FreeGlyphSetCookie) Check() error { +func (cook CreateGlyphSetCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FreeGlyphSet -// freeGlyphSetRequest writes a FreeGlyphSet request to a byte slice. -func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { - size := 8 +// Write request to wire for CreateGlyphSet +// createGlyphSetRequest writes a CreateGlyphSet request to a byte slice. +func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 17 // 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(Glyphset)) + xgb.Put32(buf[b:], uint32(Gsid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) b += 4 return buf } -// AddGlyphsCookie is a cookie used only for AddGlyphs requests. -type AddGlyphsCookie struct { +// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests. +type CreateLinearGradientCookie struct { *xgb.Cookie } -// AddGlyphs sends an unchecked request. +// CreateLinearGradient sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AddGlyphs(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { +func CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) - return AddGlyphsCookie{cookie} + c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) + return CreateLinearGradientCookie{cookie} } -// AddGlyphsChecked sends a checked request. -// If an error occurs, it can be retrieved using AddGlyphsCookie.Check() -func AddGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { +// CreateLinearGradientChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateLinearGradientCookie.Check() +func CreateLinearGradientChecked(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) - return AddGlyphsCookie{cookie} + c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) + return CreateLinearGradientCookie{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 AddGlyphsCookie) Check() error { +func (cook CreateLinearGradientCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for AddGlyphs -// addGlyphsRequest writes a AddGlyphs request to a byte slice. -func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte { - size := xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) +// Write request to wire for CreateLinearGradient +// createLinearGradientRequest writes a CreateLinearGradient request to a byte slice. +func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 34 // 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(Glyphset)) + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put32(buf[b:], GlyphsLen) + { + structBytes := P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], NumStops) b += 4 - for i := 0; i < int(GlyphsLen); i++ { - xgb.Put32(buf[b:], Glyphids[i]) + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) b += 4 } b = xgb.Pad(b) - b += GlyphinfoListBytes(buf[b:], Glyphs) - - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += ColorListBytes(buf[b:], Colors) return buf } -// FreeGlyphsCookie is a cookie used only for FreeGlyphs requests. -type FreeGlyphsCookie struct { +// CreatePictureCookie is a cookie used only for CreatePicture requests. +type CreatePictureCookie struct { *xgb.Cookie } -// FreeGlyphs sends an unchecked request. +// CreatePicture sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { +func CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) - return FreeGlyphsCookie{cookie} + c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) + return CreatePictureCookie{cookie} } -// FreeGlyphsChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeGlyphsCookie.Check() -func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { +// CreatePictureChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePictureCookie.Check() +func CreatePictureChecked(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) - return FreeGlyphsCookie{cookie} + c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) + return CreatePictureCookie{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 FreeGlyphsCookie) Check() error { +func (cook CreatePictureCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FreeGlyphs -// freeGlyphsRequest writes a FreeGlyphs request to a byte slice. -func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) +// Write request to wire for CreatePicture +// createPictureRequest writes a CreatePicture request to a byte slice. +func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 22 // request opcode + 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:], uint32(Glyphset)) + xgb.Put32(buf[b:], uint32(Pid)) b += 4 - for i := 0; i < int(len(Glyphs)); i++ { - xgb.Put32(buf[b:], uint32(Glyphs[i])) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) b += 4 } b = xgb.Pad(b) @@ -2827,206 +2497,195 @@ func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { return buf } -// CompositeGlyphs8Cookie is a cookie used only for CompositeGlyphs8 requests. -type CompositeGlyphs8Cookie struct { +// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests. +type CreateRadialGradientCookie struct { *xgb.Cookie } -// CompositeGlyphs8 sends an unchecked request. +// CreateRadialGradient sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CompositeGlyphs8(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { +func CreateRadialGradient(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs8Cookie{cookie} + c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) + return CreateRadialGradientCookie{cookie} } -// CompositeGlyphs8Checked sends a checked request. -// If an error occurs, it can be retrieved using CompositeGlyphs8Cookie.Check() -func CompositeGlyphs8Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { +// CreateRadialGradientChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRadialGradientCookie.Check() +func CreateRadialGradientChecked(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs8Cookie{cookie} + c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) + return CreateRadialGradientCookie{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 CompositeGlyphs8Cookie) Check() error { +func (cook CreateRadialGradientCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CompositeGlyphs8 -// compositeGlyphs8Request writes a CompositeGlyphs8 request to a byte slice. -func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +// Write request to wire for CreateRadialGradient +// createRadialGradientRequest writes a CreateRadialGradient request to a byte slice. +func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 23 // request opcode + buf[b] = 35 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = Op - b += 1 + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 - b += 3 // padding + { + structBytes := Inner.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - xgb.Put32(buf[b:], uint32(Src)) - b += 4 + { + structBytes := Outer.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - xgb.Put32(buf[b:], uint32(Dst)) + xgb.Put32(buf[b:], uint32(InnerRadius)) b += 4 - xgb.Put32(buf[b:], uint32(MaskFormat)) + xgb.Put32(buf[b:], uint32(OuterRadius)) b += 4 - xgb.Put32(buf[b:], uint32(Glyphset)) + xgb.Put32(buf[b:], NumStops) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) + b += ColorListBytes(buf[b:], Colors) return buf } -// CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests. -type CompositeGlyphs16Cookie struct { +// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. +type CreateSolidFillCookie struct { *xgb.Cookie } -// CompositeGlyphs16 sends an unchecked request. +// CreateSolidFill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { +func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs16Cookie{cookie} + c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) + return CreateSolidFillCookie{cookie} } -// CompositeGlyphs16Checked sends a checked request. -// If an error occurs, it can be retrieved using CompositeGlyphs16Cookie.Check() -func CompositeGlyphs16Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { +// CreateSolidFillChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateSolidFillCookie.Check() +func CreateSolidFillChecked(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs16Cookie{cookie} + c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) + return CreateSolidFillCookie{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 CompositeGlyphs16Cookie) Check() error { +func (cook CreateSolidFillCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CompositeGlyphs16 -// compositeGlyphs16Request writes a CompositeGlyphs16 request to a byte slice. -func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +// Write request to wire for CreateSolidFill +// createSolidFillRequest writes a CreateSolidFill request to a byte slice. +func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 24 // request opcode + buf[b] = 33 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Src)) - b += 4 - - xgb.Put32(buf[b:], uint32(Dst)) - b += 4 - - xgb.Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - xgb.Put32(buf[b:], uint32(Glyphset)) + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests. -type CompositeGlyphs32Cookie struct { +// FillRectanglesCookie is a cookie used only for FillRectangles requests. +type FillRectanglesCookie struct { *xgb.Cookie } -// CompositeGlyphs32 sends an unchecked request. +// FillRectangles sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CompositeGlyphs32(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { +func FillRectangles(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs32Cookie{cookie} + c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) + return FillRectanglesCookie{cookie} } -// CompositeGlyphs32Checked sends a checked request. -// If an error occurs, it can be retrieved using CompositeGlyphs32Cookie.Check() -func CompositeGlyphs32Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { +// FillRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using FillRectanglesCookie.Check() +func FillRectanglesChecked(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs32Cookie{cookie} + c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) + return FillRectanglesCookie{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 CompositeGlyphs32Cookie) Check() error { +func (cook FillRectanglesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CompositeGlyphs32 -// compositeGlyphs32Request writes a CompositeGlyphs32 request to a byte slice. -func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +// Write request to wire for FillRectangles +// fillRectanglesRequest writes a FillRectangles request to a byte slice. +func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) []byte { + size := xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 25 // request opcode + buf[b] = 26 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3037,206 +2696,180 @@ func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, Ma b += 3 // padding - xgb.Put32(buf[b:], uint32(Src)) - b += 4 - xgb.Put32(buf[b:], uint32(Dst)) b += 4 - xgb.Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - xgb.Put32(buf[b:], uint32(Glyphset)) - b += 4 - - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) + b += xproto.RectangleListBytes(buf[b:], Rects) return buf } -// FillRectanglesCookie is a cookie used only for FillRectangles requests. -type FillRectanglesCookie struct { +// FreeGlyphSetCookie is a cookie used only for FreeGlyphSet requests. +type FreeGlyphSetCookie struct { *xgb.Cookie } -// FillRectangles sends an unchecked request. +// FreeGlyphSet sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FillRectangles(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { +func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) - return FillRectanglesCookie{cookie} + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{cookie} } -// FillRectanglesChecked sends a checked request. -// If an error occurs, it can be retrieved using FillRectanglesCookie.Check() -func FillRectanglesChecked(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { +// FreeGlyphSetChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGlyphSetCookie.Check() +func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) - return FillRectanglesCookie{cookie} + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{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 FillRectanglesCookie) Check() error { +func (cook FreeGlyphSetCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FillRectangles -// fillRectanglesRequest writes a FillRectangles request to a byte slice. -func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) []byte { - size := xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) +// Write request to wire for FreeGlyphSet +// freeGlyphSetRequest writes a FreeGlyphSet request to a byte slice. +func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Dst)) + xgb.Put32(buf[b:], uint32(Glyphset)) b += 4 - { - structBytes := Color.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - b += xproto.RectangleListBytes(buf[b:], Rects) - return buf } -// CreateCursorCookie is a cookie used only for CreateCursor requests. -type CreateCursorCookie struct { +// FreeGlyphsCookie is a cookie used only for FreeGlyphs requests. +type FreeGlyphsCookie struct { *xgb.Cookie } -// CreateCursor sends an unchecked request. +// FreeGlyphs sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateCursor(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { +func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) - return CreateCursorCookie{cookie} + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{cookie} } -// CreateCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateCursorCookie.Check() -func CreateCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { +// FreeGlyphsChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGlyphsCookie.Check() +func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) - return CreateCursorCookie{cookie} + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{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 CreateCursorCookie) Check() error { +func (cook FreeGlyphsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateCursor -// createCursorRequest writes a CreateCursor request to a byte slice. -func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) []byte { - size := 16 +// Write request to wire for FreeGlyphs +// freeGlyphsRequest writes a FreeGlyphs request to a byte slice. +func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 27 // request opcode + buf[b] = 22 // 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(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source)) + xgb.Put32(buf[b:], uint32(Glyphset)) b += 4 - xgb.Put16(buf[b:], X) - b += 2 - - xgb.Put16(buf[b:], Y) - b += 2 + for i := 0; i < int(len(Glyphs)); i++ { + xgb.Put32(buf[b:], uint32(Glyphs[i])) + b += 4 + } + b = xgb.Pad(b) return buf } -// SetPictureTransformCookie is a cookie used only for SetPictureTransform requests. -type SetPictureTransformCookie struct { +// FreePictureCookie is a cookie used only for FreePicture requests. +type FreePictureCookie struct { *xgb.Cookie } -// SetPictureTransform sends an unchecked request. +// FreePicture sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { +func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) - return SetPictureTransformCookie{cookie} + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{cookie} } -// SetPictureTransformChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPictureTransformCookie.Check() -func SetPictureTransformChecked(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { +// FreePictureChecked sends a checked request. +// If an error occurs, it can be retrieved using FreePictureCookie.Check() +func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) - return SetPictureTransformCookie{cookie} + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{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 SetPictureTransformCookie) Check() error { +func (cook FreePictureCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetPictureTransform -// setPictureTransformRequest writes a SetPictureTransform request to a byte slice. -func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transform) []byte { - size := 44 +// Write request to wire for FreePicture +// freePictureRequest writes a FreePicture request to a byte slice. +func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 28 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3245,12 +2878,6 @@ func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transfor xgb.Put32(buf[b:], uint32(Picture)) b += 4 - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return buf } @@ -3361,176 +2988,421 @@ func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } -// SetPictureFilterCookie is a cookie used only for SetPictureFilter requests. -type SetPictureFilterCookie struct { +// QueryPictFormatsCookie is a cookie used only for QueryPictFormats requests. +type QueryPictFormatsCookie struct { *xgb.Cookie } -// SetPictureFilter sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { +// QueryPictFormats sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPictFormatsCookie.Reply() +func QueryPictFormats(c *xgb.Conn) QueryPictFormatsCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) - return SetPictureFilterCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictFormatsRequest(c), cookie) + return QueryPictFormatsCookie{cookie} } -// SetPictureFilterChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPictureFilterCookie.Check() -func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { +// QueryPictFormatsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryPictFormatsUnchecked(c *xgb.Conn) QueryPictFormatsCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) - return SetPictureFilterCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(queryPictFormatsRequest(c), cookie) + return QueryPictFormatsCookie{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 SetPictureFilterCookie) Check() error { - return cook.Cookie.Check() +// QueryPictFormatsReply represents the data returned from a QueryPictFormats request. +type QueryPictFormatsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumFormats uint32 + NumScreens uint32 + NumDepths uint32 + NumVisuals uint32 + NumSubpixel uint32 + // padding: 4 bytes + Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28)) + Screens []Pictscreen // size: PictscreenListSize(Screens) + Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4)) } -// Write request to wire for SetPictureFilter -// setPictureFilterRequest writes a SetPictureFilter request to a byte slice. -func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte { - size := xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) +// Reply blocks and returns the reply data for a QueryPictFormats request. +func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPictFormatsReply(buf), nil +} + +// queryPictFormatsReply reads a byte slice into a QueryPictFormatsReply value. +func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { + v := new(QueryPictFormatsReply) + 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.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + v.NumScreens = xgb.Get32(buf[b:]) + b += 4 + + v.NumDepths = xgb.Get32(buf[b:]) + b += 4 + + v.NumVisuals = xgb.Get32(buf[b:]) + b += 4 + + v.NumSubpixel = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + v.Formats = make([]Pictforminfo, v.NumFormats) + b += PictforminfoReadList(buf[b:], v.Formats) + + v.Screens = make([]Pictscreen, v.NumScreens) + b += PictscreenReadList(buf[b:], v.Screens) + + v.Subpixels = make([]uint32, v.NumSubpixel) + for i := 0; i < int(v.NumSubpixel); i++ { + v.Subpixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryPictFormats +// queryPictFormatsRequest writes a QueryPictFormats request to a byte slice. +func queryPictFormatsRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 30 // request opcode + 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(Picture)) + return buf +} + +// QueryPictIndexValuesCookie is a cookie used only for QueryPictIndexValues requests. +type QueryPictIndexValuesCookie struct { + *xgb.Cookie +} + +// QueryPictIndexValues sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPictIndexValuesCookie.Reply() +func QueryPictIndexValues(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{cookie} +} + +// QueryPictIndexValuesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryPictIndexValuesUnchecked(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{cookie} +} + +// QueryPictIndexValuesReply represents the data returned from a QueryPictIndexValues request. +type QueryPictIndexValuesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumValues uint32 + // padding: 20 bytes + Values []Indexvalue // size: xgb.Pad((int(NumValues) * 12)) +} + +// Reply blocks and returns the reply data for a QueryPictIndexValues request. +func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPictIndexValuesReply(buf), nil +} + +// queryPictIndexValuesReply reads a byte slice into a QueryPictIndexValuesReply value. +func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply { + v := new(QueryPictIndexValuesReply) + 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 - xgb.Put16(buf[b:], FilterLen) + v.NumValues = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Values = make([]Indexvalue, v.NumValues) + b += IndexvalueReadList(buf[b:], v.Values) + + return v +} + +// Write request to wire for QueryPictIndexValues +// queryPictIndexValuesRequest writes a QueryPictIndexValues request to a byte slice. +func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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 - b += 2 // padding + xgb.Put32(buf[b:], uint32(Format)) + b += 4 - copy(buf[b:], Filter[:FilterLen]) - b += xgb.Pad(int(FilterLen)) + return buf +} - for i := 0; i < int(len(Values)); i++ { - xgb.Put32(buf[b:], uint32(Values[i])) - b += 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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 + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// 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.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 return buf } -// CreateAnimCursorCookie is a cookie used only for CreateAnimCursor requests. -type CreateAnimCursorCookie struct { +// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests. +type ReferenceGlyphSetCookie struct { *xgb.Cookie } -// CreateAnimCursor sends an unchecked request. +// ReferenceGlyphSet sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { +func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) - return CreateAnimCursorCookie{cookie} + c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{cookie} } -// CreateAnimCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateAnimCursorCookie.Check() -func CreateAnimCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { +// ReferenceGlyphSetChecked sends a checked request. +// If an error occurs, it can be retrieved using ReferenceGlyphSetCookie.Check() +func ReferenceGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) - return CreateAnimCursorCookie{cookie} + c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{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 CreateAnimCursorCookie) Check() error { +func (cook ReferenceGlyphSetCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateAnimCursor -// createAnimCursorRequest writes a CreateAnimCursor request to a byte slice. -func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) +// Write request to wire for ReferenceGlyphSet +// referenceGlyphSetRequest writes a ReferenceGlyphSet request to a byte slice. +func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 31 // request opcode + buf[b] = 18 // 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(Cid)) + xgb.Put32(buf[b:], uint32(Gsid)) b += 4 - b += AnimcursoreltListBytes(buf[b:], Cursors) + xgb.Put32(buf[b:], uint32(Existing)) + b += 4 return buf } -// AddTrapsCookie is a cookie used only for AddTraps requests. -type AddTrapsCookie struct { +// SetPictureClipRectanglesCookie is a cookie used only for SetPictureClipRectangles requests. +type SetPictureClipRectanglesCookie struct { *xgb.Cookie } -// AddTraps sends an unchecked request. +// SetPictureClipRectangles sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { +func SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) - return AddTrapsCookie{cookie} + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{cookie} } -// AddTrapsChecked sends a checked request. -// If an error occurs, it can be retrieved using AddTrapsCookie.Check() -func AddTrapsChecked(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { +// SetPictureClipRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureClipRectanglesCookie.Check() +func SetPictureClipRectanglesChecked(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) - return AddTrapsCookie{cookie} + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{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 AddTrapsCookie) Check() error { +func (cook SetPictureClipRectanglesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for AddTraps -// addTrapsRequest writes a AddTraps request to a byte slice. -func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) +// Write request to wire for SetPictureClipRectangles +// setPictureClipRectanglesRequest writes a SetPictureClipRectangles request to a byte slice. +func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 32 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3539,61 +3411,61 @@ func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put16(buf[b:], uint16(XOff)) + xgb.Put16(buf[b:], uint16(ClipXOrigin)) b += 2 - xgb.Put16(buf[b:], uint16(YOff)) + xgb.Put16(buf[b:], uint16(ClipYOrigin)) b += 2 - b += TrapListBytes(buf[b:], Traps) + b += xproto.RectangleListBytes(buf[b:], Rectangles) return buf } -// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. -type CreateSolidFillCookie struct { +// SetPictureFilterCookie is a cookie used only for SetPictureFilter requests. +type SetPictureFilterCookie struct { *xgb.Cookie } -// CreateSolidFill sends an unchecked request. +// SetPictureFilter sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { +func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) - return CreateSolidFillCookie{cookie} + c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{cookie} } -// CreateSolidFillChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateSolidFillCookie.Check() -func CreateSolidFillChecked(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { +// SetPictureFilterChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureFilterCookie.Check() +func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) - return CreateSolidFillCookie{cookie} + c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{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 CreateSolidFillCookie) Check() error { +func (cook SetPictureFilterCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateSolidFill -// createSolidFillRequest writes a CreateSolidFill request to a byte slice. -func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte { - size := 16 +// Write request to wire for SetPictureFilter +// setPictureFilterRequest writes a SetPictureFilter request to a byte slice. +func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte { + size := xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 33 // request opcode + buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3602,59 +3474,67 @@ func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte { xgb.Put32(buf[b:], uint32(Picture)) b += 4 - { - structBytes := Color.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + xgb.Put16(buf[b:], FilterLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Filter[:FilterLen]) + b += xgb.Pad(int(FilterLen)) + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 } + b = xgb.Pad(b) return buf } -// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests. -type CreateLinearGradientCookie struct { +// SetPictureTransformCookie is a cookie used only for SetPictureTransform requests. +type SetPictureTransformCookie struct { *xgb.Cookie } -// CreateLinearGradient sends an unchecked request. +// SetPictureTransform sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { +func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) - return CreateLinearGradientCookie{cookie} + c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{cookie} } -// CreateLinearGradientChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateLinearGradientCookie.Check() -func CreateLinearGradientChecked(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { +// SetPictureTransformChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureTransformCookie.Check() +func SetPictureTransformChecked(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) - return CreateLinearGradientCookie{cookie} + c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{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 CreateLinearGradientCookie) Check() error { +func (cook SetPictureTransformCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateLinearGradient -// createLinearGradientRequest writes a CreateLinearGradient request to a byte slice. -func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte { - size := xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +// Write request to wire for SetPictureTransform +// setPictureTransformRequest writes a SetPictureTransform request to a byte slice. +func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transform) []byte { + size := 44 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 34 // request opcode + buf[b] = 28 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3664,186 +3544,306 @@ func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 P b += 4 { - structBytes := P1.Bytes() + structBytes := Transform.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } - { - structBytes := P2.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + return buf +} + +// TrapezoidsCookie is a cookie used only for Trapezoids requests. +type TrapezoidsCookie struct { + *xgb.Cookie +} + +// Trapezoids sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } + cookie := c.NewCookie(false, false) + c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) + return TrapezoidsCookie{cookie} +} - xgb.Put32(buf[b:], NumStops) +// TrapezoidsChecked sends a checked request. +// If an error occurs, it can be retrieved using TrapezoidsCookie.Check() +func TrapezoidsChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) + return TrapezoidsCookie{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 TrapezoidsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Trapezoids +// trapezoidsRequest writes a Trapezoids request to a byte slice. +func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) b += 4 - for i := 0; i < int(NumStops); i++ { - xgb.Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 - b += ColorListBytes(buf[b:], Colors) + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += TrapezoidListBytes(buf[b:], Traps) return buf } -// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests. -type CreateRadialGradientCookie struct { +// TriFanCookie is a cookie used only for TriFan requests. +type TriFanCookie struct { *xgb.Cookie } -// CreateRadialGradient sends an unchecked request. +// TriFan sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateRadialGradient(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { +func TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) - return CreateRadialGradientCookie{cookie} + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{cookie} } -// CreateRadialGradientChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRadialGradientCookie.Check() -func CreateRadialGradientChecked(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { +// TriFanChecked sends a checked request. +// If an error occurs, it can be retrieved using TriFanCookie.Check() +func TriFanChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) - return CreateRadialGradientCookie{cookie} + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{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 CreateRadialGradientCookie) Check() error { +func (cook TriFanCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateRadialGradient -// createRadialGradientRequest writes a CreateRadialGradient request to a byte slice. -func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { - size := xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +// Write request to wire for TriFan +// triFanRequest writes a TriFan request to a byte slice. +func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 35 // request opcode + buf[b] = 13 // 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(Picture)) + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) b += 4 - { - structBytes := Inner.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += PointfixListBytes(buf[b:], Points) + + return buf +} + +// TriStripCookie is a cookie used only for TriStrip requests. +type TriStripCookie struct { + *xgb.Cookie +} + +// TriStrip sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } + cookie := c.NewCookie(false, false) + c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{cookie} +} - { - structBytes := Outer.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) +// TriStripChecked sends a checked request. +// If an error occurs, it can be retrieved using TriStripCookie.Check() +func TriStripChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } + cookie := c.NewCookie(true, false) + c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{cookie} +} - xgb.Put32(buf[b:], uint32(InnerRadius)) +// 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 TriStripCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TriStrip +// triStripRequest writes a TriStrip request to a byte slice. +func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) b += 4 - xgb.Put32(buf[b:], uint32(OuterRadius)) + xgb.Put32(buf[b:], uint32(Dst)) b += 4 - xgb.Put32(buf[b:], NumStops) + xgb.Put32(buf[b:], uint32(MaskFormat)) b += 4 - for i := 0; i < int(NumStops); i++ { - xgb.Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 - b += ColorListBytes(buf[b:], Colors) + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += PointfixListBytes(buf[b:], Points) return buf } -// CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests. -type CreateConicalGradientCookie struct { +// TrianglesCookie is a cookie used only for Triangles requests. +type TrianglesCookie struct { *xgb.Cookie } -// CreateConicalGradient sends an unchecked request. +// Triangles sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateConicalGradient(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { +func Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) - return CreateConicalGradientCookie{cookie} + c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) + return TrianglesCookie{cookie} } -// CreateConicalGradientChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateConicalGradientCookie.Check() -func CreateConicalGradientChecked(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { +// TrianglesChecked sends a checked request. +// If an error occurs, it can be retrieved using TrianglesCookie.Check() +func TrianglesChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) - return CreateConicalGradientCookie{cookie} + c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) + return TrianglesCookie{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 CreateConicalGradientCookie) Check() error { +func (cook TrianglesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateConicalGradient -// createConicalGradientRequest writes a CreateConicalGradient request to a byte slice. -func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { - size := xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +// Write request to wire for Triangles +// trianglesRequest writes a Triangles request to a byte slice. +func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 36 // 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:], uint32(Picture)) - b += 4 + buf[b] = Op + b += 1 - { - structBytes := Center.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + b += 3 // padding - xgb.Put32(buf[b:], uint32(Angle)) + xgb.Put32(buf[b:], uint32(Src)) b += 4 - xgb.Put32(buf[b:], NumStops) + xgb.Put32(buf[b:], uint32(Dst)) b += 4 - for i := 0; i < int(NumStops); i++ { - xgb.Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 - b += ColorListBytes(buf[b:], Colors) + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += TriangleListBytes(buf[b:], Triangles) return buf } diff --git a/nexgb/res/res.go b/nexgb/res/res.go index cbbd8cc..671f691 100644 --- a/nexgb/res/res.go +++ b/nexgb/res/res.go @@ -2,7 +2,7 @@ package res /* - This file was generated by res.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by res.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["X-Resource"] = 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 Client struct { ResourceBase uint32 ResourceMask uint32 @@ -172,44 +148,68 @@ func TypeListBytes(buf []byte, list []Type) 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' + +// QueryClientPixmapBytesCookie is a cookie used only for QueryClientPixmapBytes requests. +type QueryClientPixmapBytesCookie 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, ClientMajor byte, ClientMinor byte) QueryVersionCookie { +// QueryClientPixmapBytes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryClientPixmapBytesCookie.Reply() +func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) + return QueryClientPixmapBytesCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// QueryClientPixmapBytesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { +func QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) + return QueryClientPixmapBytesCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// QueryClientPixmapBytesReply represents the data returned from a QueryClientPixmapBytes request. +type QueryClientPixmapBytesReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 + Bytes uint32 + BytesOverflow 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 QueryClientPixmapBytes request. +func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -217,12 +217,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return queryClientPixmapBytesReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// queryClientPixmapBytesReply reads a byte slice into a QueryClientPixmapBytesReply value. +func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { + v := new(QueryClientPixmapBytesReply) b := 1 // skip reply determinant b += 1 // padding @@ -233,18 +233,18 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ServerMajor = xgb.Get16(buf[b:]) - b += 2 + v.Bytes = xgb.Get32(buf[b:]) + b += 4 - v.ServerMinor = xgb.Get16(buf[b:]) - b += 2 + v.BytesOverflow = 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, ClientMajor byte, ClientMinor byte) []byte { +// Write request to wire for QueryClientPixmapBytes +// queryClientPixmapBytesRequest writes a QueryClientPixmapBytes request to a byte slice. +func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -252,60 +252,57 @@ func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte buf[b] = c.Extensions["X-RESOURCE"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = ClientMajor - b += 1 - - buf[b] = ClientMinor - b += 1 + xgb.Put32(buf[b:], Xid) + b += 4 return buf } -// QueryClientsCookie is a cookie used only for QueryClients requests. -type QueryClientsCookie struct { +// QueryClientResourcesCookie is a cookie used only for QueryClientResources requests. +type QueryClientResourcesCookie struct { *xgb.Cookie } -// QueryClients sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryClientsCookie.Reply() -func QueryClients(c *xgb.Conn) QueryClientsCookie { +// QueryClientResources sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryClientResourcesCookie.Reply() +func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryClientsRequest(c), cookie) - return QueryClientsCookie{cookie} + c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) + return QueryClientResourcesCookie{cookie} } -// QueryClientsUnchecked sends an unchecked request. +// QueryClientResourcesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie { +func QueryClientResourcesUnchecked(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryClientsRequest(c), cookie) - return QueryClientsCookie{cookie} + c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) + return QueryClientResourcesCookie{cookie} } -// QueryClientsReply represents the data returned from a QueryClients request. -type QueryClientsReply struct { +// QueryClientResourcesReply represents the data returned from a QueryClientResources request. +type QueryClientResourcesReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumClients uint32 + NumTypes uint32 // padding: 20 bytes - Clients []Client // size: xgb.Pad((int(NumClients) * 8)) + Types []Type // size: xgb.Pad((int(NumTypes) * 8)) } -// Reply blocks and returns the reply data for a QueryClients request. -func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) { +// Reply blocks and returns the reply data for a QueryClientResources request. +func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -313,12 +310,12 @@ func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) { if buf == nil { return nil, nil } - return queryClientsReply(buf), nil + return queryClientResourcesReply(buf), nil } -// queryClientsReply reads a byte slice into a QueryClientsReply value. -func queryClientsReply(buf []byte) *QueryClientsReply { - v := new(QueryClientsReply) +// queryClientResourcesReply reads a byte slice into a QueryClientResourcesReply value. +func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply { + v := new(QueryClientResourcesReply) b := 1 // skip reply determinant b += 1 // padding @@ -329,75 +326,78 @@ func queryClientsReply(buf []byte) *QueryClientsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumClients = xgb.Get32(buf[b:]) + v.NumTypes = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - v.Clients = make([]Client, v.NumClients) - b += ClientReadList(buf[b:], v.Clients) + v.Types = make([]Type, v.NumTypes) + b += TypeReadList(buf[b:], v.Types) return v } -// Write request to wire for QueryClients -// queryClientsRequest writes a QueryClients request to a byte slice. -func queryClientsRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for QueryClientResources +// queryClientResourcesRequest writes a QueryClientResources request to a byte slice. +func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["X-RESOURCE"] b += 1 - buf[b] = 1 // request opcode + 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:], Xid) + b += 4 + return buf } -// QueryClientResourcesCookie is a cookie used only for QueryClientResources requests. -type QueryClientResourcesCookie struct { +// QueryClientsCookie is a cookie used only for QueryClients requests. +type QueryClientsCookie struct { *xgb.Cookie } -// QueryClientResources sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryClientResourcesCookie.Reply() -func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { +// QueryClients sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryClientsCookie.Reply() +func QueryClients(c *xgb.Conn) QueryClientsCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) - return QueryClientResourcesCookie{cookie} + c.NewRequest(queryClientsRequest(c), cookie) + return QueryClientsCookie{cookie} } -// QueryClientResourcesUnchecked sends an unchecked request. +// QueryClientsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryClientResourcesUnchecked(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { +func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) - return QueryClientResourcesCookie{cookie} + c.NewRequest(queryClientsRequest(c), cookie) + return QueryClientsCookie{cookie} } -// QueryClientResourcesReply represents the data returned from a QueryClientResources request. -type QueryClientResourcesReply struct { +// QueryClientsReply represents the data returned from a QueryClients request. +type QueryClientsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumTypes uint32 + NumClients uint32 // padding: 20 bytes - Types []Type // size: xgb.Pad((int(NumTypes) * 8)) + Clients []Client // size: xgb.Pad((int(NumClients) * 8)) } -// Reply blocks and returns the reply data for a QueryClientResources request. -func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, error) { +// Reply blocks and returns the reply data for a QueryClients request. +func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -405,12 +405,12 @@ func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, erro if buf == nil { return nil, nil } - return queryClientResourcesReply(buf), nil + return queryClientsReply(buf), nil } -// queryClientResourcesReply reads a byte slice into a QueryClientResourcesReply value. -func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply { - v := new(QueryClientResourcesReply) +// queryClientsReply reads a byte slice into a QueryClientsReply value. +func queryClientsReply(buf []byte) *QueryClientsReply { + v := new(QueryClientsReply) b := 1 // skip reply determinant b += 1 // padding @@ -421,77 +421,74 @@ func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumTypes = xgb.Get32(buf[b:]) + v.NumClients = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - v.Types = make([]Type, v.NumTypes) - b += TypeReadList(buf[b:], v.Types) + v.Clients = make([]Client, v.NumClients) + b += ClientReadList(buf[b:], v.Clients) return v } -// Write request to wire for QueryClientResources -// queryClientResourcesRequest writes a QueryClientResources request to a byte slice. -func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte { - size := 8 +// Write request to wire for QueryClients +// queryClientsRequest writes a QueryClients request to a byte slice. +func queryClientsRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["X-RESOURCE"] b += 1 - buf[b] = 2 // request opcode + 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:], Xid) - b += 4 - return buf } -// QueryClientPixmapBytesCookie is a cookie used only for QueryClientPixmapBytes requests. -type QueryClientPixmapBytesCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// QueryClientPixmapBytes sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryClientPixmapBytesCookie.Reply() -func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { +// 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, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) - return QueryClientPixmapBytesCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// QueryClientPixmapBytesUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["X-RESOURCE"]; !ok { - panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) - return QueryClientPixmapBytesCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// QueryClientPixmapBytesReply represents the data returned from a QueryClientPixmapBytes request. -type QueryClientPixmapBytesReply struct { +// 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 - Bytes uint32 - BytesOverflow uint32 + ServerMajor uint16 + ServerMinor uint16 } -// Reply blocks and returns the reply data for a QueryClientPixmapBytes request. -func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, error) { +// 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 @@ -499,12 +496,12 @@ func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, if buf == nil { return nil, nil } - return queryClientPixmapBytesReply(buf), nil + return queryVersionReply(buf), nil } -// queryClientPixmapBytesReply reads a byte slice into a QueryClientPixmapBytesReply value. -func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { - v := new(QueryClientPixmapBytesReply) +// 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 @@ -515,18 +512,18 @@ func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Bytes = xgb.Get32(buf[b:]) - b += 4 + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 - v.BytesOverflow = xgb.Get32(buf[b:]) - b += 4 + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for QueryClientPixmapBytes -// queryClientPixmapBytesRequest writes a QueryClientPixmapBytes request to a byte slice. -func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte { +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -534,14 +531,17 @@ func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte { buf[b] = c.Extensions["X-RESOURCE"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Xid) - b += 4 + buf[b] = ClientMajor + b += 1 + + buf[b] = ClientMinor + b += 1 return buf } diff --git a/nexgb/screensaver/screensaver.go b/nexgb/screensaver/screensaver.go index f336d0d..f693b52 100644 --- a/nexgb/screensaver/screensaver.go +++ b/nexgb/screensaver/screensaver.go @@ -2,7 +2,7 @@ package screensaver /* - This file was generated by screensaver.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by screensaver.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,46 +40,15 @@ func init() { xgb.NewExtErrorFuncs["MIT-SCREEN-SAVER"] = make(map[int]xgb.NewErrorFun) } -// 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' - -// Skipping definition for base type 'Card16' - -const ( - KindBlanked = 0 - KindInternal = 1 - KindExternal = 2 -) - const ( EventNotifyMask = 1 EventCycleMask = 2 ) const ( - StateOff = 0 - StateOn = 1 - StateCycle = 2 - StateDisabled = 3 + KindBlanked = 0 + KindInternal = 1 + KindExternal = 2 ) // Notify is the event number for a NotifyEvent. @@ -214,105 +183,36 @@ func init() { xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"][0] = NotifyEventNew } -// 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, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { - if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { - if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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 - ServerMajorVersion uint16 - ServerMinorVersion uint16 - // padding: 20 bytes -} - -// 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 +const ( + StateOff = 0 + StateOn = 1 + StateCycle = 2 + StateDisabled = 3 +) - v.ServerMajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Bool' - v.ServerMinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Byte' - b += 20 // padding +// Skipping definition for base type 'Card8' - return v -} +// Skipping definition for base type 'Char' -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Void' - buf[b] = c.Extensions["MIT-SCREEN-SAVER"] - b += 1 +// Skipping definition for base type 'Double' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Float' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Int16' - buf[b] = ClientMajorVersion - b += 1 +// Skipping definition for base type 'Int32' - buf[b] = ClientMinorVersion - b += 1 +// Skipping definition for base type 'Int8' - b += 2 // padding +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // QueryInfoCookie is a cookie used only for QueryInfo requests. type QueryInfoCookie struct { @@ -422,6 +322,106 @@ func queryInfoRequest(c *xgb.Conn, Drawable xproto.Drawable) []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, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { + if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { + if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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 + ServerMajorVersion uint16 + ServerMinorVersion uint16 + // padding: 20 bytes +} + +// 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.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + 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] = ClientMajorVersion + b += 1 + + buf[b] = ClientMinorVersion + b += 1 + + b += 2 // padding + + return buf +} + // SelectInputCookie is a cookie used only for SelectInput requests. type SelectInputCookie struct { *xgb.Cookie @@ -567,42 +567,42 @@ func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int1 return buf } -// UnsetAttributesCookie is a cookie used only for UnsetAttributes requests. -type UnsetAttributesCookie struct { +// SuspendCookie is a cookie used only for Suspend requests. +type SuspendCookie struct { *xgb.Cookie } -// UnsetAttributes sends an unchecked request. +// Suspend sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnsetAttributes(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { +func Suspend(c *xgb.Conn, Suspend bool) SuspendCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) - return UnsetAttributesCookie{cookie} + c.NewRequest(suspendRequest(c, Suspend), cookie) + return SuspendCookie{cookie} } -// UnsetAttributesChecked sends a checked request. -// If an error occurs, it can be retrieved using UnsetAttributesCookie.Check() -func UnsetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { +// SuspendChecked sends a checked request. +// If an error occurs, it can be retrieved using SuspendCookie.Check() +func SuspendChecked(c *xgb.Conn, Suspend bool) SuspendCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) - return UnsetAttributesCookie{cookie} + c.NewRequest(suspendRequest(c, Suspend), cookie) + return SuspendCookie{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 UnsetAttributesCookie) Check() error { +func (cook SuspendCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnsetAttributes -// unsetAttributesRequest writes a UnsetAttributes request to a byte slice. -func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { +// Write request to wire for Suspend +// suspendRequest writes a Suspend request to a byte slice. +func suspendRequest(c *xgb.Conn, Suspend bool) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -610,54 +610,60 @@ func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { buf[b] = c.Extensions["MIT-SCREEN-SAVER"] b += 1 - buf[b] = 4 // request opcode + 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:], uint32(Drawable)) - b += 4 + if Suspend { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding return buf } -// SuspendCookie is a cookie used only for Suspend requests. -type SuspendCookie struct { +// UnsetAttributesCookie is a cookie used only for UnsetAttributes requests. +type UnsetAttributesCookie struct { *xgb.Cookie } -// Suspend sends an unchecked request. +// UnsetAttributes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Suspend(c *xgb.Conn, Suspend bool) SuspendCookie { +func UnsetAttributes(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(suspendRequest(c, Suspend), cookie) - return SuspendCookie{cookie} + c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) + return UnsetAttributesCookie{cookie} } -// SuspendChecked sends a checked request. -// If an error occurs, it can be retrieved using SuspendCookie.Check() -func SuspendChecked(c *xgb.Conn, Suspend bool) SuspendCookie { +// UnsetAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using UnsetAttributesCookie.Check() +func UnsetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(suspendRequest(c, Suspend), cookie) - return SuspendCookie{cookie} + c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) + return UnsetAttributesCookie{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 SuspendCookie) Check() error { +func (cook UnsetAttributesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Suspend -// suspendRequest writes a Suspend request to a byte slice. -func suspendRequest(c *xgb.Conn, Suspend bool) []byte { +// Write request to wire for UnsetAttributes +// unsetAttributesRequest writes a UnsetAttributes request to a byte slice. +func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -665,20 +671,14 @@ func suspendRequest(c *xgb.Conn, Suspend bool) []byte { buf[b] = c.Extensions["MIT-SCREEN-SAVER"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - if Suspend { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 return buf } diff --git a/nexgb/shape/shape.go b/nexgb/shape/shape.go index b98a001..d0d5b8c 100644 --- a/nexgb/shape/shape.go +++ b/nexgb/shape/shape.go @@ -2,7 +2,7 @@ package shape /* - This file was generated by shape.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by shape.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,46 +40,6 @@ func init() { xgb.NewExtErrorFuncs["SHAPE"] = 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' - -const ( - SoSet = 0 - SoUnion = 1 - SoIntersect = 2 - SoSubtract = 3 - SoInvert = 4 -) - -const ( - SkBounding = 0 - SkClip = 1 - SkInput = 2 -) - -type Op byte - type Kind byte // Notify is the event number for a NotifyEvent. @@ -209,139 +169,90 @@ func init() { xgb.NewExtEventFuncs["SHAPE"][0] = NotifyEventNew } -// 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["SHAPE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SHAPE'. shape.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["SHAPE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} -} +type Op byte -// 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 - MajorVersion uint16 - MinorVersion uint16 -} +const ( + SkBounding = 0 + SkClip = 1 + SkInput = 2 +) -// 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 -} +const ( + SoSet = 0 + SoUnion = 1 + SoIntersect = 2 + SoSubtract = 3 + SoInvert = 4 +) -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - b := 1 // skip reply determinant +// Skipping definition for base type 'Bool' - b += 1 // padding +// 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.MajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Void' - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Double' - return v -} +// Skipping definition for base type 'Float' -// 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) +// Skipping definition for base type 'Int16' - buf[b] = c.Extensions["SHAPE"] - b += 1 +// Skipping definition for base type 'Int32' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Int8' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' -// RectanglesCookie is a cookie used only for Rectangles requests. -type RectanglesCookie struct { +// CombineCookie is a cookie used only for Combine requests. +type CombineCookie struct { *xgb.Cookie } -// Rectangles sends an unchecked request. +// Combine sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Rectangles(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { +func Combine(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'Rectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'Combine' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) - return RectanglesCookie{cookie} + c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) + return CombineCookie{cookie} } -// RectanglesChecked sends a checked request. -// If an error occurs, it can be retrieved using RectanglesCookie.Check() -func RectanglesChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { +// CombineChecked sends a checked request. +// If an error occurs, it can be retrieved using CombineCookie.Check() +func CombineChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'Rectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'Combine' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) - return RectanglesCookie{cookie} + c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) + return CombineCookie{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 RectanglesCookie) Check() error { +func (cook CombineCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Rectangles -// rectanglesRequest writes a Rectangles request to a byte slice. -func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8)))) +// Write request to wire for Combine +// combineRequest writes a Combine request to a byte slice. +func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SHAPE"] 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 @@ -353,7 +264,7 @@ func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering buf[b] = byte(DestinationKind) b += 1 - buf[b] = Ordering + buf[b] = byte(SourceKind) b += 1 b += 1 // padding @@ -367,119 +278,238 @@ func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering xgb.Put16(buf[b:], uint16(YOffset)) b += 2 - b += xproto.RectangleListBytes(buf[b:], Rectangles) + xgb.Put32(buf[b:], uint32(SourceWindow)) + b += 4 return buf } -// MaskCookie is a cookie used only for Mask requests. -type MaskCookie struct { +// GetRectanglesCookie is a cookie used only for GetRectangles requests. +type GetRectanglesCookie struct { *xgb.Cookie } -// Mask sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Mask(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { +// GetRectangles sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetRectanglesCookie.Reply() +func GetRectangles(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'Mask' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'GetRectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) - return MaskCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) + return GetRectanglesCookie{cookie} } -// MaskChecked sends a checked request. -// If an error occurs, it can be retrieved using MaskCookie.Check() -func MaskChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { +// GetRectanglesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetRectanglesUnchecked(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'Mask' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'GetRectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) - return MaskCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) + return GetRectanglesCookie{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 MaskCookie) Check() error { - return cook.Cookie.Check() +// GetRectanglesReply represents the data returned from a GetRectangles request. +type GetRectanglesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Ordering byte + RectanglesLen uint32 + // padding: 20 bytes + Rectangles []xproto.Rectangle // size: xgb.Pad((int(RectanglesLen) * 8)) } -// Write request to wire for Mask -// maskRequest writes a Mask request to a byte slice. -func maskRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) []byte { - size := 20 +// Reply blocks and returns the reply data for a GetRectangles request. +func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getRectanglesReply(buf), nil +} + +// getRectanglesReply reads a byte slice into a GetRectanglesReply value. +func getRectanglesReply(buf []byte) *GetRectanglesReply { + v := new(GetRectanglesReply) + b := 1 // skip reply determinant + + v.Ordering = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RectanglesLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Rectangles = make([]xproto.Rectangle, v.RectanglesLen) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for GetRectangles +// getRectanglesRequest writes a GetRectangles request to a byte slice. +func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SHAPE"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = byte(Operation) + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = byte(SourceKind) b += 1 - buf[b] = byte(DestinationKind) + b += 3 // padding + + return buf +} + +// InputSelectedCookie is a cookie used only for InputSelected requests. +type InputSelectedCookie struct { + *xgb.Cookie +} + +// InputSelected sends a checked request. +// If an error occurs, it will be returned with the reply by calling InputSelectedCookie.Reply() +func InputSelected(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { + if _, ok := c.Extensions["SHAPE"]; !ok { + panic("Cannot issue request 'InputSelected' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) + return InputSelectedCookie{cookie} +} + +// InputSelectedUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func InputSelectedUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { + if _, ok := c.Extensions["SHAPE"]; !ok { + panic("Cannot issue request 'InputSelected' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) + return InputSelectedCookie{cookie} +} + +// InputSelectedReply represents the data returned from a InputSelected request. +type InputSelectedReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Enabled bool +} + +// Reply blocks and returns the reply data for a InputSelected request. +func (cook InputSelectedCookie) Reply() (*InputSelectedReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return inputSelectedReply(buf), nil +} + +// inputSelectedReply reads a byte slice into a InputSelectedReply value. +func inputSelectedReply(buf []byte) *InputSelectedReply { + v := new(InputSelectedReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.Enabled = true + } else { + v.Enabled = false + } b += 1 - b += 2 // padding + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(DestinationWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], uint16(XOffset)) - b += 2 + return v +} - xgb.Put16(buf[b:], uint16(YOffset)) +// Write request to wire for InputSelected +// inputSelectedRequest writes a InputSelected request to a byte slice. +func inputSelectedRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + 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:], uint32(SourceBitmap)) + xgb.Put32(buf[b:], uint32(DestinationWindow)) b += 4 return buf } -// CombineCookie is a cookie used only for Combine requests. -type CombineCookie struct { +// MaskCookie is a cookie used only for Mask requests. +type MaskCookie struct { *xgb.Cookie } -// Combine sends an unchecked request. +// Mask sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Combine(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { +func Mask(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'Combine' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'Mask' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) - return CombineCookie{cookie} + c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) + return MaskCookie{cookie} } -// CombineChecked sends a checked request. -// If an error occurs, it can be retrieved using CombineCookie.Check() -func CombineChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { +// MaskChecked sends a checked request. +// If an error occurs, it can be retrieved using MaskCookie.Check() +func MaskChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'Combine' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'Mask' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) - return CombineCookie{cookie} + c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) + return MaskCookie{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 CombineCookie) Check() error { +func (cook MaskCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Combine -// combineRequest writes a Combine request to a byte slice. -func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) []byte { +// Write request to wire for Mask +// maskRequest writes a Mask request to a byte slice. +func maskRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) []byte { size := 20 b := 0 buf := make([]byte, size) @@ -487,7 +517,7 @@ func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind buf[b] = c.Extensions["SHAPE"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -499,10 +529,7 @@ func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind buf[b] = byte(DestinationKind) b += 1 - buf[b] = byte(SourceKind) - b += 1 - - b += 1 // padding + b += 2 // padding xgb.Put32(buf[b:], uint32(DestinationWindow)) b += 4 @@ -513,7 +540,7 @@ func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind xgb.Put16(buf[b:], uint16(YOffset)) b += 2 - xgb.Put32(buf[b:], uint32(SourceWindow)) + xgb.Put32(buf[b:], uint32(SourceBitmap)) b += 4 return buf @@ -720,106 +747,44 @@ func queryExtentsRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { return buf } -// SelectInputCookie is a cookie used only for SelectInput requests. -type SelectInputCookie struct { - *xgb.Cookie -} - -// SelectInput sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectInput(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { - if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) - return SelectInputCookie{cookie} -} - -// SelectInputChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectInputCookie.Check() -func SelectInputChecked(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { - if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) - return SelectInputCookie{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 SelectInputCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SelectInput -// selectInputRequest writes a SelectInput request to a byte slice. -func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SHAPE"] - 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:], uint32(DestinationWindow)) - b += 4 - - if Enable { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// InputSelectedCookie is a cookie used only for InputSelected requests. -type InputSelectedCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// InputSelected sends a checked request. -// If an error occurs, it will be returned with the reply by calling InputSelectedCookie.Reply() -func InputSelected(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { +// 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["SHAPE"]; !ok { - panic("Cannot issue request 'InputSelected' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) - return InputSelectedCookie{cookie} + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} } -// InputSelectedUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InputSelectedUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'InputSelected' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) - return InputSelectedCookie{cookie} + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} } -// InputSelectedReply represents the data returned from a InputSelected request. -type InputSelectedReply struct { +// 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 - Enabled bool + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 } -// Reply blocks and returns the reply data for a InputSelected request. -func (cook InputSelectedCookie) Reply() (*InputSelectedReply, error) { +// 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 @@ -827,20 +792,15 @@ func (cook InputSelectedCookie) Reply() (*InputSelectedReply, error) { if buf == nil { return nil, nil } - return inputSelectedReply(buf), nil + return queryVersionReply(buf), nil } -// inputSelectedReply reads a byte slice into a InputSelectedReply value. -func inputSelectedReply(buf []byte) *InputSelectedReply { - v := new(InputSelectedReply) +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) b := 1 // skip reply determinant - if buf[b] == 1 { - v.Enabled = true - } else { - v.Enabled = false - } - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -848,108 +808,144 @@ func inputSelectedReply(buf []byte) *InputSelectedReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + return v } -// Write request to wire for InputSelected -// inputSelectedRequest writes a InputSelected request to a byte slice. -func inputSelectedRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { - size := 8 +// 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["SHAPE"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 0 // 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(DestinationWindow)) - b += 4 - return buf } -// GetRectanglesCookie is a cookie used only for GetRectangles requests. -type GetRectanglesCookie struct { +// RectanglesCookie is a cookie used only for Rectangles requests. +type RectanglesCookie struct { *xgb.Cookie } -// GetRectangles sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetRectanglesCookie.Reply() -func GetRectangles(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { +// Rectangles sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Rectangles(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'GetRectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'Rectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) - return GetRectanglesCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) + return RectanglesCookie{cookie} } -// GetRectanglesUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetRectanglesUnchecked(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { +// RectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using RectanglesCookie.Check() +func RectanglesChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'GetRectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + panic("Cannot issue request 'Rectangles' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) - return GetRectanglesCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) + return RectanglesCookie{cookie} } -// GetRectanglesReply represents the data returned from a GetRectangles request. -type GetRectanglesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Ordering byte - RectanglesLen uint32 - // padding: 20 bytes - Rectangles []xproto.Rectangle // size: xgb.Pad((int(RectanglesLen) * 8)) +// 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 RectanglesCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetRectangles request. -func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getRectanglesReply(buf), nil -} +// Write request to wire for Rectangles +// rectanglesRequest writes a Rectangles request to a byte slice. +func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) -// getRectanglesReply reads a byte slice into a GetRectanglesReply value. -func getRectanglesReply(buf []byte) *GetRectanglesReply { - v := new(GetRectanglesReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["SHAPE"] + b += 1 - v.Ordering = buf[b] + buf[b] = 1 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + buf[b] = byte(Operation) + b += 1 - v.RectanglesLen = xgb.Get32(buf[b:]) + buf[b] = byte(DestinationKind) + b += 1 + + buf[b] = Ordering + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(DestinationWindow)) b += 4 - b += 20 // padding + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 - v.Rectangles = make([]xproto.Rectangle, v.RectanglesLen) - b += xproto.RectangleReadList(buf[b:], v.Rectangles) + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 - return v + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf } -// Write request to wire for GetRectangles -// getRectanglesRequest writes a GetRectangles request to a byte slice. -func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte { +// SelectInputCookie is a cookie used only for SelectInput requests. +type SelectInputCookie struct { + *xgb.Cookie +} + +// SelectInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SelectInput(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { + if _, ok := c.Extensions["SHAPE"]; !ok { + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) + return SelectInputCookie{cookie} +} + +// SelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectInputCookie.Check() +func SelectInputChecked(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { + if _, ok := c.Extensions["SHAPE"]; !ok { + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'SHAPE'. shape.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) + return SelectInputCookie{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 SelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectInput +// selectInputRequest writes a SelectInput request to a byte slice. +func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -957,16 +953,20 @@ func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) [] buf[b] = c.Extensions["SHAPE"] b += 1 - buf[b] = 8 // request opcode + 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:], uint32(Window)) + xgb.Put32(buf[b:], uint32(DestinationWindow)) b += 4 - buf[b] = byte(SourceKind) + if Enable { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 b += 3 // padding diff --git a/nexgb/shm/shm.go b/nexgb/shm/shm.go index 97ce9ff..bd5d638 100644 --- a/nexgb/shm/shm.go +++ b/nexgb/shm/shm.go @@ -2,7 +2,7 @@ package shm /* - This file was generated by shm.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by shm.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,38 +40,42 @@ func init() { xgb.NewExtErrorFuncs["MIT-SHM"] = make(map[int]xgb.NewErrorFun) } -// 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' +// BadBadSeg is the error number for a BadBadSeg. +const BadBadSeg = 0 -// Skipping definition for base type 'Void' +type BadSegError xproto.ValueError -// Skipping definition for base type 'Byte' +// BadSegErrorNew constructs a BadSegError value that implements xgb.Error from a byte slice. +func BadSegErrorNew(buf []byte) xgb.Error { + v := BadSegError(xproto.ValueErrorNew(buf).(xproto.ValueError)) + v.NiceName = "BadSeg" + return v +} -// Skipping definition for base type 'Int8' +// SequenceId returns the sequence id attached to the BadBadSeg error. +// This is mostly used internally. +func (err BadSegError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Card16' +// BadId returns the 'BadValue' number if one exists for the BadBadSeg error. If no bad value exists, 0 is returned. +func (err BadSegError) BadId() uint32 { + return 0 +} -type Seg uint32 +// Error returns a rudimentary string representation of the BadBadSeg error. +func (err BadSegError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadSeg {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -func NewSegId(c *xgb.Conn) (Seg, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Seg(id), nil +func init() { + xgb.NewExtErrorFuncs["MIT-SHM"][0] = BadSegErrorNew } // Completion is the event number for a CompletionEvent. @@ -174,152 +178,39 @@ func init() { xgb.NewExtEventFuncs["MIT-SHM"][0] = CompletionEventNew } -// BadBadSeg is the error number for a BadBadSeg. -const BadBadSeg = 0 - -type BadSegError xproto.ValueError - -// BadSegErrorNew constructs a BadSegError value that implements xgb.Error from a byte slice. -func BadSegErrorNew(buf []byte) xgb.Error { - v := BadSegError(xproto.ValueErrorNew(buf).(xproto.ValueError)) - v.NiceName = "BadSeg" - return v -} - -// SequenceId returns the sequence id attached to the BadBadSeg error. -// This is mostly used internally. -func (err BadSegError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadBadSeg error. If no bad value exists, 0 is returned. -func (err BadSegError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadBadSeg error. -func (err BadSegError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadSeg {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["MIT-SHM"][0] = BadSegErrorNew -} - -// 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["MIT-SHM"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.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["MIT-SHM"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.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 - SharedPixmaps bool - MajorVersion uint16 - MinorVersion uint16 - Uid uint16 - Gid uint16 - PixmapFormat byte - // padding: 15 bytes -} +type Seg uint32 -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { - buf, err := cook.Cookie.Reply() +func NewSegId(c *xgb.Conn) (Seg, error) { + id, err := c.NewId() if err != nil { - return nil, err - } - if buf == nil { - return nil, nil + return 0, err } - return queryVersionReply(buf), nil + return Seg(id), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SharedPixmaps = true - } else { - v.SharedPixmaps = false - } - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Bool' - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Byte' - v.Uid = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card8' - v.Gid = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Char' - v.PixmapFormat = buf[b] - b += 1 +// Skipping definition for base type 'Void' - b += 15 // padding +// Skipping definition for base type 'Double' - return v -} +// Skipping definition for base type 'Float' -// 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) +// Skipping definition for base type 'Int16' - buf[b] = c.Extensions["MIT-SHM"] - b += 1 +// Skipping definition for base type 'Int32' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Int8' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // AttachCookie is a cookie used only for Attach requests. type AttachCookie struct { @@ -388,157 +279,133 @@ func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte return buf } -// DetachCookie is a cookie used only for Detach requests. -type DetachCookie struct { +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { *xgb.Cookie } -// Detach sends an unchecked request. +// CreatePixmap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Detach(c *xgb.Conn, Shmseg Seg) DetachCookie { +func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { if _, ok := c.Extensions["MIT-SHM"]; !ok { - panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(detachRequest(c, Shmseg), cookie) - return DetachCookie{cookie} + c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) + return CreatePixmapCookie{cookie} } -// DetachChecked sends a checked request. -// If an error occurs, it can be retrieved using DetachCookie.Check() -func DetachChecked(c *xgb.Conn, Shmseg Seg) DetachCookie { +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() +func CreatePixmapChecked(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { if _, ok := c.Extensions["MIT-SHM"]; !ok { - panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(detachRequest(c, Shmseg), cookie) - return DetachCookie{cookie} + c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) + return CreatePixmapCookie{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 DetachCookie) Check() error { +func (cook CreatePixmapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Detach -// detachRequest writes a Detach request to a byte slice. -func detachRequest(c *xgb.Conn, Shmseg Seg) []byte { - size := 8 +// Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. +func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) []byte { + size := 28 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["MIT-SHM"] 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 b += 2 + xgb.Put32(buf[b:], uint32(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + buf[b] = Depth + b += 1 + + b += 3 // padding + xgb.Put32(buf[b:], uint32(Shmseg)) b += 4 + xgb.Put32(buf[b:], Offset) + b += 4 + return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// DetachCookie is a cookie used only for Detach requests. +type DetachCookie struct { *xgb.Cookie } -// PutImage sends an unchecked request. +// Detach sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutImage(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { +func Detach(c *xgb.Conn, Shmseg Seg) DetachCookie { if _, ok := c.Extensions["MIT-SHM"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) - return PutImageCookie{cookie} + c.NewRequest(detachRequest(c, Shmseg), cookie) + return DetachCookie{cookie} } -// PutImageChecked sends a checked request. -// If an error occurs, it can be retrieved using PutImageCookie.Check() -func PutImageChecked(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { +// DetachChecked sends a checked request. +// If an error occurs, it can be retrieved using DetachCookie.Check() +func DetachChecked(c *xgb.Conn, Shmseg Seg) DetachCookie { if _, ok := c.Extensions["MIT-SHM"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) - return PutImageCookie{cookie} + c.NewRequest(detachRequest(c, Shmseg), cookie) + return DetachCookie{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 PutImageCookie) Check() error { +func (cook DetachCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutImage -// putImageRequest writes a PutImage request to a byte slice. -func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) []byte { - size := 40 +// Write request to wire for Detach +// detachRequest writes a Detach request to a byte slice. +func detachRequest(c *xgb.Conn, Shmseg Seg) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["MIT-SHM"] b += 1 - buf[b] = 3 // request opcode + 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], TotalWidth) - b += 2 - - xgb.Put16(buf[b:], TotalHeight) - b += 2 - - xgb.Put16(buf[b:], SrcX) - b += 2 - - xgb.Put16(buf[b:], SrcY) - b += 2 - - xgb.Put16(buf[b:], SrcWidth) - b += 2 - - xgb.Put16(buf[b:], SrcHeight) - b += 2 - - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstY)) - b += 2 - - buf[b] = Depth - b += 1 - - buf[b] = Format - b += 1 - - buf[b] = SendEvent - b += 1 - - b += 1 // padding - xgb.Put32(buf[b:], uint32(Shmseg)) b += 4 - xgb.Put32(buf[b:], Offset) - b += 4 - return buf } @@ -661,71 +528,95 @@ func getImageRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Wi return buf } -// CreatePixmapCookie is a cookie used only for CreatePixmap requests. -type CreatePixmapCookie struct { +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { *xgb.Cookie } -// CreatePixmap sends an unchecked request. +// PutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { +func PutImage(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { if _, ok := c.Extensions["MIT-SHM"]; !ok { - panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) - return CreatePixmapCookie{cookie} + c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) + return PutImageCookie{cookie} } -// CreatePixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() -func CreatePixmapChecked(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() +func PutImageChecked(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { if _, ok := c.Extensions["MIT-SHM"]; !ok { - panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) - return CreatePixmapCookie{cookie} + c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) + return PutImageCookie{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 CreatePixmapCookie) Check() error { +func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreatePixmap -// createPixmapRequest writes a CreatePixmap request to a byte slice. -func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) []byte { - size := 28 +// Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. +func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) []byte { + size := 40 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["MIT-SHM"] b += 1 - buf[b] = 5 // request opcode + 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(Pid)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], Width) + xgb.Put16(buf[b:], TotalWidth) b += 2 - xgb.Put16(buf[b:], Height) + xgb.Put16(buf[b:], TotalHeight) + b += 2 + + xgb.Put16(buf[b:], SrcX) + b += 2 + + xgb.Put16(buf[b:], SrcY) + b += 2 + + xgb.Put16(buf[b:], SrcWidth) + b += 2 + + xgb.Put16(buf[b:], SrcHeight) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) b += 2 buf[b] = Depth b += 1 - b += 3 // padding + buf[b] = Format + b += 1 + + buf[b] = SendEvent + b += 1 + + b += 1 // padding xgb.Put32(buf[b:], uint32(Shmseg)) b += 4 @@ -735,3 +626,112 @@ func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawabl 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["MIT-SHM"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.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["MIT-SHM"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.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 + SharedPixmaps bool + MajorVersion uint16 + MinorVersion uint16 + Uid uint16 + Gid uint16 + PixmapFormat byte + // padding: 15 bytes +} + +// 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 + + if buf[b] == 1 { + v.SharedPixmaps = true + } else { + v.SharedPixmaps = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Uid = xgb.Get16(buf[b:]) + b += 2 + + v.Gid = xgb.Get16(buf[b:]) + b += 2 + + v.PixmapFormat = buf[b] + b += 1 + + b += 15 // padding + + 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["MIT-SHM"] + 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 +} diff --git a/nexgb/sync/sync.go b/nexgb/sync/sync.go index a7046b7..ff83384 100644 --- a/nexgb/sync/sync.go +++ b/nexgb/sync/sync.go @@ -2,7 +2,7 @@ package sync /* - This file was generated by sync.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by sync.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,29 +40,183 @@ func init() { xgb.NewExtErrorFuncs["SYNC"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Float' +type Alarm uint32 -// Skipping definition for base type 'Card8' +func NewAlarmId(c *xgb.Conn) (Alarm, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Alarm(id), nil +} -// Skipping definition for base type 'Int16' +// BadAlarm is the error number for a BadAlarm. +const BadAlarm = 1 -// Skipping definition for base type 'Int32' +type AlarmError struct { + Sequence uint16 + NiceName string + BadAlarm uint32 + MinorOpcode uint16 + MajorOpcode byte +} -// Skipping definition for base type 'Void' +// AlarmErrorNew constructs a AlarmError value that implements xgb.Error from a byte slice. +func AlarmErrorNew(buf []byte) xgb.Error { + v := AlarmError{} + v.NiceName = "Alarm" -// Skipping definition for base type 'Byte' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Int8' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card16' + v.BadAlarm = xgb.Get32(buf[b:]) + b += 4 -// Skipping definition for base type 'Char' + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card32' + v.MajorOpcode = buf[b] + b += 1 -// Skipping definition for base type 'Double' + return v +} -// Skipping definition for base type 'Bool' +// SequenceId returns the sequence id attached to the BadAlarm error. +// This is mostly used internally. +func (err AlarmError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadAlarm error. If no bad value exists, 0 is returned. +func (err AlarmError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadAlarm error. + +func (err AlarmError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadAlarm: %d", err.BadAlarm)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlarm {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew +} + +// AlarmNotify is the event number for a AlarmNotifyEvent. +const AlarmNotify = 1 + +type AlarmNotifyEvent struct { + Sequence uint16 + Kind byte + Alarm Alarm + CounterValue Int64 + AlarmValue Int64 + Timestamp xproto.Timestamp + State byte + // padding: 3 bytes +} + +// AlarmNotifyEventNew constructs a AlarmNotifyEvent value that implements xgb.Event from a byte slice. +func AlarmNotifyEventNew(buf []byte) xgb.Event { + v := AlarmNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Alarm = Alarm(xgb.Get32(buf[b:])) + b += 4 + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.AlarmValue = Int64{} + b += Int64Read(buf[b:], &v.AlarmValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a AlarmNotifyEvent value to a byte slice. +func (v AlarmNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Alarm)) + b += 4 + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.AlarmValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the AlarmNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v AlarmNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of AlarmNotifyEvent. +func (v AlarmNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Alarm: %d", v.Alarm)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "AlarmNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew +} const ( AlarmstateActive = 0 @@ -71,18 +225,6 @@ const ( ) const ( - TesttypePositiveTransition = 0 - TesttypeNegativeTransition = 1 - TesttypePositiveComparison = 2 - TesttypeNegativeComparison = 3 -) - -const ( - ValuetypeAbsolute = 0 - ValuetypeRelative = 1 -) - -const ( CaCounter = 1 CaValueType = 2 CaValue = 4 @@ -91,24 +233,198 @@ const ( CaEvents = 32 ) -type Alarm uint32 +type Counter uint32 -func NewAlarmId(c *xgb.Conn) (Alarm, error) { +func NewCounterId(c *xgb.Conn) (Counter, error) { id, err := c.NewId() if err != nil { return 0, err } - return Alarm(id), nil + return Counter(id), nil } -type Counter uint32 +// BadCounter is the error number for a BadCounter. +const BadCounter = 0 -func NewCounterId(c *xgb.Conn) (Counter, error) { - id, err := c.NewId() - if err != nil { - return 0, err +type CounterError struct { + Sequence uint16 + NiceName string + BadCounter uint32 + MinorOpcode uint16 + MajorOpcode byte +} + +// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. +func CounterErrorNew(buf []byte) xgb.Error { + v := CounterError{} + v.NiceName = "Counter" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadCounter = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + return v +} + +// SequenceId returns the sequence id attached to the BadCounter error. +// This is mostly used internally. +func (err CounterError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadCounter error. If no bad value exists, 0 is returned. +func (err CounterError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadCounter error. + +func (err CounterError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadCounter: %d", err.BadCounter)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCounter {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew +} + +// CounterNotify is the event number for a CounterNotifyEvent. +const CounterNotify = 0 + +type CounterNotifyEvent struct { + Sequence uint16 + Kind byte + Counter Counter + WaitValue Int64 + CounterValue Int64 + Timestamp xproto.Timestamp + Count uint16 + Destroyed bool + // padding: 1 bytes +} + +// CounterNotifyEventNew constructs a CounterNotifyEvent value that implements xgb.Event from a byte slice. +func CounterNotifyEventNew(buf []byte) xgb.Event { + v := CounterNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.WaitValue = Int64{} + b += Int64Read(buf[b:], &v.WaitValue) + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.Destroyed = true + } else { + v.Destroyed = false } - return Counter(id), nil + b += 1 + + b += 1 // padding + + return v +} + +// Bytes writes a CounterNotifyEvent value to a byte slice. +func (v CounterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + { + structBytes := v.WaitValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + if v.Destroyed { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the CounterNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CounterNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of CounterNotifyEvent. +func (v CounterNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Counter: %d", v.Counter)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Destroyed: %t", v.Destroyed)) + return "CounterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew } type Fence uint32 @@ -259,6 +575,13 @@ func SystemcounterListSize(list []Systemcounter) int { return size } +const ( + TesttypePositiveTransition = 0 + TesttypeNegativeTransition = 1 + TesttypePositiveComparison = 2 + TesttypeNegativeComparison = 3 +) + type Trigger struct { Counter Counter WaitType uint32 @@ -330,6 +653,11 @@ func TriggerListBytes(buf []byte, list []Trigger) int { return b } +const ( + ValuetypeAbsolute = 0 + ValuetypeRelative = 1 +) + type Waitcondition struct { Trigger Trigger EventThreshold Int64 @@ -390,545 +718,326 @@ func WaitconditionListBytes(buf []byte, list []Waitcondition) int { return b } -// CounterNotify is the event number for a CounterNotifyEvent. -const CounterNotify = 0 +// Skipping definition for base type 'Bool' -type CounterNotifyEvent struct { - Sequence uint16 - Kind byte - Counter Counter - WaitValue Int64 - CounterValue Int64 - Timestamp xproto.Timestamp - Count uint16 - Destroyed bool - // padding: 1 bytes -} +// Skipping definition for base type 'Byte' -// CounterNotifyEventNew constructs a CounterNotifyEvent value that implements xgb.Event from a byte slice. -func CounterNotifyEventNew(buf []byte) xgb.Event { - v := CounterNotifyEvent{} - b := 1 // don't read event number +// Skipping definition for base type 'Card8' - v.Kind = buf[b] - b += 1 +// Skipping definition for base type 'Char' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Void' - v.Counter = Counter(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Double' - v.WaitValue = Int64{} - b += Int64Read(buf[b:], &v.WaitValue) +// Skipping definition for base type 'Float' - v.CounterValue = Int64{} - b += Int64Read(buf[b:], &v.CounterValue) +// Skipping definition for base type 'Int16' - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Int32' - v.Count = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int8' - if buf[b] == 1 { - v.Destroyed = true - } else { - v.Destroyed = false - } - b += 1 +// Skipping definition for base type 'Card16' - b += 1 // padding +// Skipping definition for base type 'Card32' - return v +// AwaitCookie is a cookie used only for Await requests. +type AwaitCookie struct { + *xgb.Cookie } -// Bytes writes a CounterNotifyEvent value to a byte slice. -func (v CounterNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Kind - b += 1 - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Counter)) - b += 4 - - { - structBytes := v.WaitValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - xgb.Put16(buf[b:], v.Count) - b += 2 - - if v.Destroyed { - buf[b] = 1 - } else { - buf[b] = 0 +// Await sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Await(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'Await' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - b += 1 - - b += 1 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the CounterNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CounterNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of CounterNotifyEvent. -func (v CounterNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, xgb.Sprintf("Counter: %d", v.Counter)) - fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, xgb.Sprintf("Destroyed: %t", v.Destroyed)) - return "CounterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew + cookie := c.NewCookie(false, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{cookie} } -// AlarmNotify is the event number for a AlarmNotifyEvent. -const AlarmNotify = 1 - -type AlarmNotifyEvent struct { - Sequence uint16 - Kind byte - Alarm Alarm - CounterValue Int64 - AlarmValue Int64 - Timestamp xproto.Timestamp - State byte - // padding: 3 bytes +// AwaitChecked sends a checked request. +// If an error occurs, it can be retrieved using AwaitCookie.Check() +func AwaitChecked(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'Await' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{cookie} } -// AlarmNotifyEventNew constructs a AlarmNotifyEvent value that implements xgb.Event from a byte slice. -func AlarmNotifyEventNew(buf []byte) xgb.Event { - v := AlarmNotifyEvent{} - b := 1 // don't read event number - - v.Kind = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Alarm = Alarm(xgb.Get32(buf[b:])) - b += 4 - - v.CounterValue = Int64{} - b += Int64Read(buf[b:], &v.CounterValue) - - v.AlarmValue = Int64{} - b += Int64Read(buf[b:], &v.AlarmValue) - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 - - b += 3 // padding - - 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 AwaitCookie) Check() error { + return cook.Cookie.Check() } -// Bytes writes a AlarmNotifyEvent value to a byte slice. -func (v AlarmNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// Write request to wire for Await +// awaitRequest writes a Await request to a byte slice. +func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { + size := xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) b := 0 + buf := make([]byte, size) - // write event number - buf[b] = 1 + buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = v.Kind + buf[b] = 7 // request opcode b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Alarm)) - b += 4 - - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.AlarmValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - buf[b] = v.State - b += 1 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - b += 3 // padding + b += WaitconditionListBytes(buf[b:], WaitList) return buf } -// SequenceId returns the sequence id attached to the AlarmNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v AlarmNotifyEvent) SequenceId() uint16 { - return v.Sequence +// AwaitFenceCookie is a cookie used only for AwaitFence requests. +type AwaitFenceCookie struct { + *xgb.Cookie } -// String is a rudimentary string representation of AlarmNotifyEvent. -func (v AlarmNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, xgb.Sprintf("Alarm: %d", v.Alarm)) - fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "AlarmNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AwaitFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AwaitFence(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'AwaitFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} } -func init() { - xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew +// AwaitFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using AwaitFenceCookie.Check() +func AwaitFenceChecked(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'AwaitFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} } -// BadCounter is the error number for a BadCounter. -const BadCounter = 0 - -type CounterError struct { - Sequence uint16 - NiceName string - BadCounter uint32 - MinorOpcode uint16 - MajorOpcode byte +// 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 AwaitFenceCookie) Check() error { + return cook.Cookie.Check() } -// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. -func CounterErrorNew(buf []byte) xgb.Error { - v := CounterError{} - v.NiceName = "Counter" - - b := 1 // skip error determinant - b += 1 // don't read error number +// Write request to wire for AwaitFence +// awaitFenceRequest writes a AwaitFence request to a byte slice. +func awaitFenceRequest(c *xgb.Conn, FenceList []Fence) []byte { + size := xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) + b := 0 + buf := make([]byte, size) - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + buf[b] = c.Extensions["SYNC"] + b += 1 - v.BadCounter = xgb.Get32(buf[b:]) - b += 4 + buf[b] = 19 // request opcode + b += 1 - v.MinorOpcode = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.MajorOpcode = buf[b] - b += 1 + for i := 0; i < int(len(FenceList)); i++ { + xgb.Put32(buf[b:], uint32(FenceList[i])) + b += 4 + } + b = xgb.Pad(b) - return v + return buf } -// SequenceId returns the sequence id attached to the BadCounter error. -// This is mostly used internally. -func (err CounterError) SequenceId() uint16 { - return err.Sequence +// ChangeAlarmCookie is a cookie used only for ChangeAlarm requests. +type ChangeAlarmCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadCounter error. If no bad value exists, 0 is returned. -func (err CounterError) BadId() uint32 { - return 0 +// ChangeAlarm sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'ChangeAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return ChangeAlarmCookie{cookie} } -// Error returns a rudimentary string representation of the BadCounter error. - -func (err CounterError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadCounter: %d", err.BadCounter)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadCounter {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeAlarmCookie.Check() +func ChangeAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'ChangeAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return ChangeAlarmCookie{cookie} } -func init() { - xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew +// 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 ChangeAlarmCookie) Check() error { + return cook.Cookie.Check() } -// BadAlarm is the error number for a BadAlarm. -const BadAlarm = 1 - -type AlarmError struct { - Sequence uint16 - NiceName string - BadAlarm uint32 - MinorOpcode uint16 - MajorOpcode byte -} +// Write request to wire for ChangeAlarm +// changeAlarmRequest writes a ChangeAlarm request to a byte slice. +func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) -// AlarmErrorNew constructs a AlarmError value that implements xgb.Error from a byte slice. -func AlarmErrorNew(buf []byte) xgb.Error { - v := AlarmError{} - v.NiceName = "Alarm" + buf[b] = c.Extensions["SYNC"] + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = 9 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.BadAlarm = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(Id)) b += 4 - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - return v -} - -// SequenceId returns the sequence id attached to the BadAlarm error. -// This is mostly used internally. -func (err AlarmError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadAlarm error. If no bad value exists, 0 is returned. -func (err AlarmError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadAlarm error. - -func (err AlarmError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadAlarm: %d", err.BadAlarm)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAlarm {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) -func init() { - xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew + return buf } -// InitializeCookie is a cookie used only for Initialize requests. -type InitializeCookie struct { +// ChangeCounterCookie is a cookie used only for ChangeCounter requests. +type ChangeCounterCookie struct { *xgb.Cookie } -// Initialize sends a checked request. -// If an error occurs, it will be returned with the reply by calling InitializeCookie.Reply() -func Initialize(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'Initialize' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) - return InitializeCookie{cookie} -} - -// InitializeUnchecked sends an unchecked request. +// ChangeCounter sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InitializeUnchecked(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { +func ChangeCounter(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'Initialize' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) - return InitializeCookie{cookie} -} - -// InitializeReply represents the data returned from a Initialize request. -type InitializeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MajorVersion byte - MinorVersion byte - // padding: 22 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} } -// Reply blocks and returns the reply data for a Initialize request. -func (cook InitializeCookie) Reply() (*InitializeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// ChangeCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCounterCookie.Check() +func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'ChangeCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - return initializeReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} } -// initializeReply reads a byte slice into a InitializeReply value. -func initializeReply(buf []byte) *InitializeReply { - v := new(InitializeReply) - 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.MajorVersion = buf[b] - b += 1 - - v.MinorVersion = buf[b] - b += 1 - - b += 22 // padding - - 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 ChangeCounterCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for Initialize -// initializeRequest writes a Initialize request to a byte slice. -func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { - size := 8 +// Write request to wire for ChangeCounter +// changeCounterRequest writes a ChangeCounter request to a byte slice. +func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = DesiredMajorVersion - b += 1 + xgb.Put32(buf[b:], uint32(Counter)) + b += 4 - buf[b] = DesiredMinorVersion - b += 1 + { + structBytes := Amount.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// ListSystemCountersCookie is a cookie used only for ListSystemCounters requests. -type ListSystemCountersCookie struct { +// CreateAlarmCookie is a cookie used only for CreateAlarm requests. +type CreateAlarmCookie struct { *xgb.Cookie } -// ListSystemCounters sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListSystemCountersCookie.Reply() -func ListSystemCounters(c *xgb.Conn) ListSystemCountersCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ListSystemCounters' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(listSystemCountersRequest(c), cookie) - return ListSystemCountersCookie{cookie} -} - -// ListSystemCountersUnchecked sends an unchecked request. +// CreateAlarm sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListSystemCountersUnchecked(c *xgb.Conn) ListSystemCountersCookie { +func CreateAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ListSystemCounters' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(listSystemCountersRequest(c), cookie) - return ListSystemCountersCookie{cookie} -} - -// ListSystemCountersReply represents the data returned from a ListSystemCounters request. -type ListSystemCountersReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - CountersLen uint32 - // padding: 20 bytes - Counters []Systemcounter // size: SystemcounterListSize(Counters) + cookie := c.NewCookie(false, false) + c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return CreateAlarmCookie{cookie} } -// Reply blocks and returns the reply data for a ListSystemCounters request. -func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// CreateAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateAlarmCookie.Check() +func CreateAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'CreateAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - return listSystemCountersReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return CreateAlarmCookie{cookie} } -// listSystemCountersReply reads a byte slice into a ListSystemCountersReply value. -func listSystemCountersReply(buf []byte) *ListSystemCountersReply { - v := new(ListSystemCountersReply) - 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.CountersLen = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Counters = make([]Systemcounter, v.CountersLen) - b += SystemcounterReadList(buf[b:], v.Counters) - - 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 CreateAlarmCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for ListSystemCounters -// listSystemCountersRequest writes a ListSystemCounters request to a byte slice. -func listSystemCountersRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for CreateAlarm +// createAlarmRequest writes a CreateAlarm request to a byte slice. +func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 1 // request opcode + 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:], uint32(Id)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } @@ -993,130 +1102,107 @@ func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { return buf } -// DestroyCounterCookie is a cookie used only for DestroyCounter requests. -type DestroyCounterCookie struct { +// CreateFenceCookie is a cookie used only for CreateFence requests. +type CreateFenceCookie struct { *xgb.Cookie } -// DestroyCounter sends an unchecked request. +// CreateFence sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyCounter(c *xgb.Conn, Counter Counter) DestroyCounterCookie { +func CreateFence(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(destroyCounterRequest(c, Counter), cookie) - return DestroyCounterCookie{cookie} + c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) + return CreateFenceCookie{cookie} } -// DestroyCounterChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyCounterCookie.Check() -func DestroyCounterChecked(c *xgb.Conn, Counter Counter) DestroyCounterCookie { +// CreateFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateFenceCookie.Check() +func CreateFenceChecked(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(destroyCounterRequest(c, Counter), cookie) - return DestroyCounterCookie{cookie} + c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) + return CreateFenceCookie{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 DestroyCounterCookie) Check() error { +func (cook CreateFenceCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyCounter -// destroyCounterRequest writes a DestroyCounter request to a byte slice. -func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { - size := 8 +// Write request to wire for CreateFence +// createFenceRequest writes a CreateFence request to a byte slice. +func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 14 // 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(Counter)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + if InitiallyTriggered { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + return buf } -// QueryCounterCookie is a cookie used only for QueryCounter requests. -type QueryCounterCookie struct { +// DestroyAlarmCookie is a cookie used only for DestroyAlarm requests. +type DestroyAlarmCookie struct { *xgb.Cookie } -// QueryCounter sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryCounterCookie.Reply() -func QueryCounter(c *xgb.Conn, Counter Counter) QueryCounterCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'QueryCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryCounterRequest(c, Counter), cookie) - return QueryCounterCookie{cookie} -} - -// QueryCounterUnchecked sends an unchecked request. +// DestroyAlarm sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryCounterUnchecked(c *xgb.Conn, Counter Counter) QueryCounterCookie { +func DestroyAlarm(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'QueryCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryCounterRequest(c, Counter), cookie) - return QueryCounterCookie{cookie} -} - -// QueryCounterReply represents the data returned from a QueryCounter request. -type QueryCounterReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - CounterValue Int64 + cookie := c.NewCookie(false, false) + c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) + return DestroyAlarmCookie{cookie} } -// Reply blocks and returns the reply data for a QueryCounter request. -func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DestroyAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyAlarmCookie.Check() +func DestroyAlarmChecked(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'DestroyAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - return queryCounterReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) + return DestroyAlarmCookie{cookie} } -// queryCounterReply reads a byte slice into a QueryCounterReply value. -func queryCounterReply(buf []byte) *QueryCounterReply { - v := new(QueryCounterReply) - 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.CounterValue = Int64{} - b += Int64Read(buf[b:], &v.CounterValue) - - 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 DestroyAlarmCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryCounter -// queryCounterRequest writes a QueryCounter request to a byte slice. -func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { +// Write request to wire for DestroyAlarm +// destroyAlarmRequest writes a DestroyAlarm request to a byte slice. +func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1124,372 +1210,403 @@ func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 5 // 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:], uint32(Counter)) + xgb.Put32(buf[b:], uint32(Alarm)) b += 4 return buf } -// AwaitCookie is a cookie used only for Await requests. -type AwaitCookie struct { +// DestroyCounterCookie is a cookie used only for DestroyCounter requests. +type DestroyCounterCookie struct { *xgb.Cookie } -// Await sends an unchecked request. +// DestroyCounter sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Await(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { +func DestroyCounter(c *xgb.Conn, Counter Counter) DestroyCounterCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'Await' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(awaitRequest(c, WaitList), cookie) - return AwaitCookie{cookie} + c.NewRequest(destroyCounterRequest(c, Counter), cookie) + return DestroyCounterCookie{cookie} } -// AwaitChecked sends a checked request. -// If an error occurs, it can be retrieved using AwaitCookie.Check() -func AwaitChecked(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { +// DestroyCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyCounterCookie.Check() +func DestroyCounterChecked(c *xgb.Conn, Counter Counter) DestroyCounterCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'Await' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(awaitRequest(c, WaitList), cookie) - return AwaitCookie{cookie} + c.NewRequest(destroyCounterRequest(c, Counter), cookie) + return DestroyCounterCookie{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 AwaitCookie) Check() error { +func (cook DestroyCounterCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Await -// awaitRequest writes a Await request to a byte slice. -func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { - size := xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) +// Write request to wire for DestroyCounter +// destroyCounterRequest writes a DestroyCounter request to a byte slice. +func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - b += WaitconditionListBytes(buf[b:], WaitList) + xgb.Put32(buf[b:], uint32(Counter)) + b += 4 return buf } -// ChangeCounterCookie is a cookie used only for ChangeCounter requests. -type ChangeCounterCookie struct { +// DestroyFenceCookie is a cookie used only for DestroyFence requests. +type DestroyFenceCookie struct { *xgb.Cookie } -// ChangeCounter sends an unchecked request. +// DestroyFence sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeCounter(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { +func DestroyFence(c *xgb.Conn, Fence Fence) DestroyFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ChangeCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) - return ChangeCounterCookie{cookie} + c.NewRequest(destroyFenceRequest(c, Fence), cookie) + return DestroyFenceCookie{cookie} } -// ChangeCounterChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeCounterCookie.Check() -func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { +// DestroyFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyFenceCookie.Check() +func DestroyFenceChecked(c *xgb.Conn, Fence Fence) DestroyFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ChangeCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) - return ChangeCounterCookie{cookie} + c.NewRequest(destroyFenceRequest(c, Fence), cookie) + return DestroyFenceCookie{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 ChangeCounterCookie) Check() error { +func (cook DestroyFenceCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeCounter -// changeCounterRequest writes a ChangeCounter request to a byte slice. -func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { - size := 16 +// Write request to wire for DestroyFence +// destroyFenceRequest writes a DestroyFence request to a byte slice. +func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 17 // 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(Counter)) + xgb.Put32(buf[b:], uint32(Fence)) b += 4 - { - structBytes := Amount.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return buf } -// SetCounterCookie is a cookie used only for SetCounter requests. -type SetCounterCookie struct { +// GetPriorityCookie is a cookie used only for GetPriority requests. +type GetPriorityCookie struct { *xgb.Cookie } -// SetCounter sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetCounter(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { +// GetPriority sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPriorityCookie.Reply() +func GetPriority(c *xgb.Conn, Id uint32) GetPriorityCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'SetCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setCounterRequest(c, Counter, Value), cookie) - return SetCounterCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getPriorityRequest(c, Id), cookie) + return GetPriorityCookie{cookie} } -// SetCounterChecked sends a checked request. -// If an error occurs, it can be retrieved using SetCounterCookie.Check() -func SetCounterChecked(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { +// GetPriorityUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPriorityUnchecked(c *xgb.Conn, Id uint32) GetPriorityCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'SetCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setCounterRequest(c, Counter, Value), cookie) - return SetCounterCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getPriorityRequest(c, Id), cookie) + return GetPriorityCookie{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 SetCounterCookie) Check() error { - return cook.Cookie.Check() +// GetPriorityReply represents the data returned from a GetPriority request. +type GetPriorityReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Priority int32 } -// Write request to wire for SetCounter -// setCounterRequest writes a SetCounter request to a byte slice. -func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { - size := 16 +// Reply blocks and returns the reply data for a GetPriority request. +func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPriorityReply(buf), nil +} + +// getPriorityReply reads a byte slice into a GetPriorityReply value. +func getPriorityReply(buf []byte) *GetPriorityReply { + v := new(GetPriorityReply) + 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.Priority = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetPriority +// getPriorityRequest writes a GetPriority request to a byte slice. +func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 13 // 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(Counter)) + xgb.Put32(buf[b:], Id) b += 4 - { - structBytes := Value.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return buf } -// CreateAlarmCookie is a cookie used only for CreateAlarm requests. -type CreateAlarmCookie struct { +// InitializeCookie is a cookie used only for Initialize requests. +type InitializeCookie struct { *xgb.Cookie } -// CreateAlarm sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { +// Initialize sends a checked request. +// If an error occurs, it will be returned with the reply by calling InitializeCookie.Reply() +func Initialize(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'CreateAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'Initialize' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) - return CreateAlarmCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) + return InitializeCookie{cookie} } -// CreateAlarmChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateAlarmCookie.Check() -func CreateAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { +// InitializeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func InitializeUnchecked(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'CreateAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'Initialize' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) - return CreateAlarmCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) + return InitializeCookie{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 CreateAlarmCookie) Check() error { - return cook.Cookie.Check() +// InitializeReply represents the data returned from a Initialize request. +type InitializeReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MajorVersion byte + MinorVersion byte + // padding: 22 bytes } -// Write request to wire for CreateAlarm -// createAlarmRequest writes a CreateAlarm request to a byte slice. -func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Reply blocks and returns the reply data for a Initialize request. +func (cook InitializeCookie) Reply() (*InitializeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return initializeReply(buf), nil +} + +// initializeReply reads a byte slice into a InitializeReply value. +func initializeReply(buf []byte) *InitializeReply { + v := new(InitializeReply) + 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.MajorVersion = buf[b] + b += 1 + + v.MinorVersion = buf[b] + b += 1 + + b += 22 // padding + + return v +} + +// Write request to wire for Initialize +// initializeRequest writes a Initialize request to a byte slice. +func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 0 // 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(Id)) - b += 4 + buf[b] = DesiredMajorVersion + b += 1 - xgb.Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + buf[b] = DesiredMinorVersion + b += 1 return buf } -// ChangeAlarmCookie is a cookie used only for ChangeAlarm requests. -type ChangeAlarmCookie struct { +// ListSystemCountersCookie is a cookie used only for ListSystemCounters requests. +type ListSystemCountersCookie struct { *xgb.Cookie } -// ChangeAlarm sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { +// ListSystemCounters sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSystemCountersCookie.Reply() +func ListSystemCounters(c *xgb.Conn) ListSystemCountersCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ChangeAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSystemCounters' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) - return ChangeAlarmCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(listSystemCountersRequest(c), cookie) + return ListSystemCountersCookie{cookie} } -// ChangeAlarmChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeAlarmCookie.Check() -func ChangeAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { +// ListSystemCountersUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListSystemCountersUnchecked(c *xgb.Conn) ListSystemCountersCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ChangeAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSystemCounters' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) - return ChangeAlarmCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(listSystemCountersRequest(c), cookie) + return ListSystemCountersCookie{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 ChangeAlarmCookie) Check() error { - return cook.Cookie.Check() +// ListSystemCountersReply represents the data returned from a ListSystemCounters request. +type ListSystemCountersReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + CountersLen uint32 + // padding: 20 bytes + Counters []Systemcounter // size: SystemcounterListSize(Counters) } -// Write request to wire for ChangeAlarm -// changeAlarmRequest writes a ChangeAlarm request to a byte slice. -func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a ListSystemCounters request. +func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSystemCountersReply(buf), nil +} - buf[b] = c.Extensions["SYNC"] - b += 1 +// listSystemCountersReply reads a byte slice into a ListSystemCountersReply value. +func listSystemCountersReply(buf []byte) *ListSystemCountersReply { + v := new(ListSystemCountersReply) + b := 1 // skip reply determinant - buf[b] = 9 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Id)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], ValueMask) + v.CountersLen = xgb.Get32(buf[b:]) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) - return buf -} - -// DestroyAlarmCookie is a cookie used only for DestroyAlarm requests. -type DestroyAlarmCookie struct { - *xgb.Cookie -} - -// DestroyAlarm sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyAlarm(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) - return DestroyAlarmCookie{cookie} -} + b += 20 // padding -// DestroyAlarmChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyAlarmCookie.Check() -func DestroyAlarmChecked(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyAlarm' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) - return DestroyAlarmCookie{cookie} -} + v.Counters = make([]Systemcounter, v.CountersLen) + b += SystemcounterReadList(buf[b:], v.Counters) -// 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 DestroyAlarmCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for DestroyAlarm -// destroyAlarmRequest writes a DestroyAlarm request to a byte slice. -func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { - size := 8 +// Write request to wire for ListSystemCounters +// listSystemCountersRequest writes a ListSystemCounters request to a byte slice. +func listSystemCountersRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] 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 b += 2 - xgb.Put32(buf[b:], uint32(Alarm)) - b += 4 - return buf } @@ -1600,101 +1717,43 @@ func queryAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { return buf } -// SetPriorityCookie is a cookie used only for SetPriority requests. -type SetPriorityCookie struct { - *xgb.Cookie -} - -// SetPriority sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPriority(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'SetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) - return SetPriorityCookie{cookie} -} - -// SetPriorityChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPriorityCookie.Check() -func SetPriorityChecked(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'SetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) - return SetPriorityCookie{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 SetPriorityCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPriority -// setPriorityRequest writes a SetPriority request to a byte slice. -func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SYNC"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Id) - b += 4 - - xgb.Put32(buf[b:], uint32(Priority)) - b += 4 - - return buf -} - -// GetPriorityCookie is a cookie used only for GetPriority requests. -type GetPriorityCookie struct { +// QueryCounterCookie is a cookie used only for QueryCounter requests. +type QueryCounterCookie struct { *xgb.Cookie } -// GetPriority sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPriorityCookie.Reply() -func GetPriority(c *xgb.Conn, Id uint32) GetPriorityCookie { +// QueryCounter sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryCounterCookie.Reply() +func QueryCounter(c *xgb.Conn, Counter Counter) QueryCounterCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'GetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPriorityRequest(c, Id), cookie) - return GetPriorityCookie{cookie} + c.NewRequest(queryCounterRequest(c, Counter), cookie) + return QueryCounterCookie{cookie} } -// GetPriorityUnchecked sends an unchecked request. +// QueryCounterUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPriorityUnchecked(c *xgb.Conn, Id uint32) GetPriorityCookie { +func QueryCounterUnchecked(c *xgb.Conn, Counter Counter) QueryCounterCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'GetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPriorityRequest(c, Id), cookie) - return GetPriorityCookie{cookie} + c.NewRequest(queryCounterRequest(c, Counter), cookie) + return QueryCounterCookie{cookie} } -// GetPriorityReply represents the data returned from a GetPriority request. -type GetPriorityReply struct { +// QueryCounterReply represents the data returned from a QueryCounter request. +type QueryCounterReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Priority int32 + CounterValue Int64 } -// Reply blocks and returns the reply data for a GetPriority request. -func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { +// Reply blocks and returns the reply data for a QueryCounter request. +func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1702,12 +1761,12 @@ func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { if buf == nil { return nil, nil } - return getPriorityReply(buf), nil + return queryCounterReply(buf), nil } -// getPriorityReply reads a byte slice into a GetPriorityReply value. -func getPriorityReply(buf []byte) *GetPriorityReply { - v := new(GetPriorityReply) +// queryCounterReply reads a byte slice into a QueryCounterReply value. +func queryCounterReply(buf []byte) *QueryCounterReply { + v := new(QueryCounterReply) b := 1 // skip reply determinant b += 1 // padding @@ -1718,15 +1777,15 @@ func getPriorityReply(buf []byte) *GetPriorityReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Priority = int32(xgb.Get32(buf[b:])) - b += 4 + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) return v } -// Write request to wire for GetPriority -// getPriorityRequest writes a GetPriority request to a byte slice. -func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { +// Write request to wire for QueryCounter +// queryCounterRequest writes a QueryCounter request to a byte slice. +func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1734,119 +1793,94 @@ func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 13 // request opcode + 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:], Id) + xgb.Put32(buf[b:], uint32(Counter)) b += 4 return buf } -// CreateFenceCookie is a cookie used only for CreateFence requests. -type CreateFenceCookie struct { +// QueryFenceCookie is a cookie used only for QueryFence requests. +type QueryFenceCookie struct { *xgb.Cookie } -// CreateFence sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateFence(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { +// QueryFence sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFenceCookie.Reply() +func QueryFence(c *xgb.Conn, Fence Fence) QueryFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'CreateFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) - return CreateFenceCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryFenceRequest(c, Fence), cookie) + return QueryFenceCookie{cookie} } -// CreateFenceChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateFenceCookie.Check() -func CreateFenceChecked(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { +// QueryFenceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryFenceUnchecked(c *xgb.Conn, Fence Fence) QueryFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'CreateFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) - return CreateFenceCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(queryFenceRequest(c, Fence), cookie) + return QueryFenceCookie{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 CreateFenceCookie) Check() error { - return cook.Cookie.Check() +// QueryFenceReply represents the data returned from a QueryFence request. +type QueryFenceReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Triggered bool + // padding: 23 bytes } -// Write request to wire for CreateFence -// createFenceRequest writes a CreateFence request to a byte slice. -func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) []byte { - size := 16 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a QueryFence request. +func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFenceReply(buf), nil +} - buf[b] = c.Extensions["SYNC"] - b += 1 +// queryFenceReply reads a byte slice into a QueryFenceReply value. +func queryFenceReply(buf []byte) *QueryFenceReply { + v := new(QueryFenceReply) + b := 1 // skip reply determinant - buf[b] = 14 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Fence)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - if InitiallyTriggered { - buf[b] = 1 + if buf[b] == 1 { + v.Triggered = true } else { - buf[b] = 0 + v.Triggered = false } b += 1 - return buf -} - -// TriggerFenceCookie is a cookie used only for TriggerFence requests. -type TriggerFenceCookie struct { - *xgb.Cookie -} - -// TriggerFence sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func TriggerFence(c *xgb.Conn, Fence Fence) TriggerFenceCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'TriggerFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(triggerFenceRequest(c, Fence), cookie) - return TriggerFenceCookie{cookie} -} - -// TriggerFenceChecked sends a checked request. -// If an error occurs, it can be retrieved using TriggerFenceCookie.Check() -func TriggerFenceChecked(c *xgb.Conn, Fence Fence) TriggerFenceCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'TriggerFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(triggerFenceRequest(c, Fence), cookie) - return TriggerFenceCookie{cookie} -} + b += 23 // padding -// 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 TriggerFenceCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for TriggerFence -// triggerFenceRequest writes a TriggerFence request to a byte slice. -func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { +// Write request to wire for QueryFence +// queryFenceRequest writes a QueryFence request to a byte slice. +func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1854,7 +1888,7 @@ func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 15 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1921,210 +1955,176 @@ func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// DestroyFenceCookie is a cookie used only for DestroyFence requests. -type DestroyFenceCookie struct { +// SetCounterCookie is a cookie used only for SetCounter requests. +type SetCounterCookie struct { *xgb.Cookie } -// DestroyFence sends an unchecked request. +// SetCounter sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyFence(c *xgb.Conn, Fence Fence) DestroyFenceCookie { +func SetCounter(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(destroyFenceRequest(c, Fence), cookie) - return DestroyFenceCookie{cookie} + c.NewRequest(setCounterRequest(c, Counter, Value), cookie) + return SetCounterCookie{cookie} } -// DestroyFenceChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyFenceCookie.Check() -func DestroyFenceChecked(c *xgb.Conn, Fence Fence) DestroyFenceCookie { +// SetCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCounterCookie.Check() +func SetCounterChecked(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(destroyFenceRequest(c, Fence), cookie) - return DestroyFenceCookie{cookie} + c.NewRequest(setCounterRequest(c, Counter, Value), cookie) + return SetCounterCookie{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 DestroyFenceCookie) Check() error { +func (cook SetCounterCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyFence -// destroyFenceRequest writes a DestroyFence request to a byte slice. -func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { - size := 8 +// Write request to wire for SetCounter +// setCounterRequest writes a SetCounter request to a byte slice. +func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 17 // request opcode + 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(Fence)) + xgb.Put32(buf[b:], uint32(Counter)) b += 4 + { + structBytes := Value.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return buf } -// QueryFenceCookie is a cookie used only for QueryFence requests. -type QueryFenceCookie struct { +// SetPriorityCookie is a cookie used only for SetPriority requests. +type SetPriorityCookie struct { *xgb.Cookie } -// QueryFence sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryFenceCookie.Reply() -func QueryFence(c *xgb.Conn, Fence Fence) QueryFenceCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'QueryFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryFenceRequest(c, Fence), cookie) - return QueryFenceCookie{cookie} -} - -// QueryFenceUnchecked sends an unchecked request. +// SetPriority sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryFenceUnchecked(c *xgb.Conn, Fence Fence) QueryFenceCookie { +func SetPriority(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'QueryFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryFenceRequest(c, Fence), cookie) - return QueryFenceCookie{cookie} -} - -// QueryFenceReply represents the data returned from a QueryFence request. -type QueryFenceReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Triggered bool - // padding: 23 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) + return SetPriorityCookie{cookie} } -// Reply blocks and returns the reply data for a QueryFence request. -func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SetPriorityChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPriorityCookie.Check() +func SetPriorityChecked(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'SetPriority' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - return queryFenceReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) + return SetPriorityCookie{cookie} } -// queryFenceReply reads a byte slice into a QueryFenceReply value. -func queryFenceReply(buf []byte) *QueryFenceReply { - v := new(QueryFenceReply) - 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.Triggered = true - } else { - v.Triggered = false - } - b += 1 - - b += 23 // padding - - 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 SetPriorityCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryFence -// queryFenceRequest writes a QueryFence request to a byte slice. -func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { - size := 8 +// Write request to wire for SetPriority +// setPriorityRequest writes a SetPriority request to a byte slice. +func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 12 // 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(Fence)) + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], uint32(Priority)) b += 4 return buf } -// AwaitFenceCookie is a cookie used only for AwaitFence requests. -type AwaitFenceCookie struct { +// TriggerFenceCookie is a cookie used only for TriggerFence requests. +type TriggerFenceCookie struct { *xgb.Cookie } -// AwaitFence sends an unchecked request. +// TriggerFence sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AwaitFence(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { +func TriggerFence(c *xgb.Conn, Fence Fence) TriggerFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'AwaitFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'TriggerFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(awaitFenceRequest(c, FenceList), cookie) - return AwaitFenceCookie{cookie} + c.NewRequest(triggerFenceRequest(c, Fence), cookie) + return TriggerFenceCookie{cookie} } -// AwaitFenceChecked sends a checked request. -// If an error occurs, it can be retrieved using AwaitFenceCookie.Check() -func AwaitFenceChecked(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { +// TriggerFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using TriggerFenceCookie.Check() +func TriggerFenceChecked(c *xgb.Conn, Fence Fence) TriggerFenceCookie { if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'AwaitFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'TriggerFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(awaitFenceRequest(c, FenceList), cookie) - return AwaitFenceCookie{cookie} + c.NewRequest(triggerFenceRequest(c, Fence), cookie) + return TriggerFenceCookie{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 AwaitFenceCookie) Check() error { +func (cook TriggerFenceCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for AwaitFence -// awaitFenceRequest writes a AwaitFence request to a byte slice. -func awaitFenceRequest(c *xgb.Conn, FenceList []Fence) []byte { - size := xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) +// Write request to wire for TriggerFence +// triggerFenceRequest writes a TriggerFence request to a byte slice. +func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 15 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - for i := 0; i < int(len(FenceList)); i++ { - xgb.Put32(buf[b:], uint32(FenceList[i])) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 return buf } diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index dce0e9d..e32ae42 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by xc_misc.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,29 +40,29 @@ func init() { xgb.NewExtErrorFuncs["XC-MISC"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int8' +// Skipping definition for base type 'Bool' -// Skipping definition for base type 'Card16' +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Card8' // Skipping definition for base type 'Char' -// Skipping definition for base type 'Card32' +// Skipping definition for base type 'Void' // 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 'Int8' -// Skipping definition for base type 'Byte' +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' // GetVersionCookie is a cookie used only for GetVersion requests. type GetVersionCookie struct { @@ -159,44 +159,45 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio return buf } -// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. -type GetXIDRangeCookie struct { +// GetXIDListCookie is a cookie used only for GetXIDList requests. +type GetXIDListCookie struct { *xgb.Cookie } -// GetXIDRange sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() -func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { +// GetXIDList sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() +func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getXIDRangeRequest(c), cookie) - return GetXIDRangeCookie{cookie} + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} } -// GetXIDRangeUnchecked sends an unchecked request. +// GetXIDListUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { +func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getXIDRangeRequest(c), cookie) - return GetXIDRangeCookie{cookie} + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} } -// GetXIDRangeReply represents the data returned from a GetXIDRange request. -type GetXIDRangeReply struct { +// GetXIDListReply represents the data returned from a GetXIDList request. +type GetXIDListReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - StartId uint32 - Count uint32 + IdsLen uint32 + // padding: 20 bytes + Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) } -// Reply blocks and returns the reply data for a GetXIDRange request. -func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { +// Reply blocks and returns the reply data for a GetXIDList request. +func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -204,12 +205,12 @@ func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { if buf == nil { return nil, nil } - return getXIDRangeReply(buf), nil + return getXIDListReply(buf), nil } -// getXIDRangeReply reads a byte slice into a GetXIDRangeReply value. -func getXIDRangeReply(buf []byte) *GetXIDRangeReply { - v := new(GetXIDRangeReply) +// getXIDListReply reads a byte slice into a GetXIDListReply value. +func getXIDListReply(buf []byte) *GetXIDListReply { + v := new(GetXIDListReply) b := 1 // skip reply determinant b += 1 // padding @@ -220,73 +221,81 @@ func getXIDRangeReply(buf []byte) *GetXIDRangeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.StartId = xgb.Get32(buf[b:]) + v.IdsLen = xgb.Get32(buf[b:]) b += 4 - v.Count = xgb.Get32(buf[b:]) - b += 4 + b += 20 // padding + + v.Ids = make([]uint32, v.IdsLen) + for i := 0; i < int(v.IdsLen); i++ { + v.Ids[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for GetXIDRange -// getXIDRangeRequest writes a GetXIDRange request to a byte slice. -func getXIDRangeRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GetXIDList +// getXIDListRequest writes a GetXIDList request to a byte slice. +func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XC-MISC"] b += 1 - buf[b] = 1 // request opcode + 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:], Count) + b += 4 + return buf } -// GetXIDListCookie is a cookie used only for GetXIDList requests. -type GetXIDListCookie struct { +// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. +type GetXIDRangeCookie struct { *xgb.Cookie } -// GetXIDList sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() -func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { +// GetXIDRange sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() +func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getXIDListRequest(c, Count), cookie) - return GetXIDListCookie{cookie} + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} } -// GetXIDListUnchecked sends an unchecked request. +// GetXIDRangeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { +func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getXIDListRequest(c, Count), cookie) - return GetXIDListCookie{cookie} + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} } -// GetXIDListReply represents the data returned from a GetXIDList request. -type GetXIDListReply struct { +// GetXIDRangeReply represents the data returned from a GetXIDRange request. +type GetXIDRangeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - IdsLen uint32 - // padding: 20 bytes - Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) + StartId uint32 + Count uint32 } -// Reply blocks and returns the reply data for a GetXIDList request. -func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { +// Reply blocks and returns the reply data for a GetXIDRange request. +func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -294,12 +303,12 @@ func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { if buf == nil { return nil, nil } - return getXIDListReply(buf), nil + return getXIDRangeReply(buf), nil } -// getXIDListReply reads a byte slice into a GetXIDListReply value. -func getXIDListReply(buf []byte) *GetXIDListReply { - v := new(GetXIDListReply) +// getXIDRangeReply reads a byte slice into a GetXIDRangeReply value. +func getXIDRangeReply(buf []byte) *GetXIDRangeReply { + v := new(GetXIDRangeReply) b := 1 // skip reply determinant b += 1 // padding @@ -310,39 +319,30 @@ func getXIDListReply(buf []byte) *GetXIDListReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.IdsLen = xgb.Get32(buf[b:]) + v.StartId = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding - - v.Ids = make([]uint32, v.IdsLen) - for i := 0; i < int(v.IdsLen); i++ { - v.Ids[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Count = xgb.Get32(buf[b:]) + b += 4 return v } -// Write request to wire for GetXIDList -// getXIDListRequest writes a GetXIDList request to a byte slice. -func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { - size := 8 +// Write request to wire for GetXIDRange +// getXIDRangeRequest writes a GetXIDRange request to a byte slice. +func getXIDRangeRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XC-MISC"] b += 1 - buf[b] = 2 // request opcode + 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:], Count) - b += 4 - return buf } diff --git a/nexgb/xevie/xevie.go b/nexgb/xevie/xevie.go index 83dadef..0dd5aca 100644 --- a/nexgb/xevie/xevie.go +++ b/nexgb/xevie/xevie.go @@ -2,7 +2,7 @@ package xevie /* - This file was generated by xevie.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by xevie.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["XEVIE"] = 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' - const ( DatatypeUnmodified = 0 DatatypeModified = 1 @@ -114,45 +90,67 @@ func EventListBytes(buf []byte, list []Event) 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' + +// EndCookie is a cookie used only for End requests. +type EndCookie 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, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { +// End sends a checked request. +// If an error occurs, it will be returned with the reply by calling EndCookie.Reply() +func End(c *xgb.Conn, Cmap uint32) EndCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'End' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(endRequest(c, Cmap), cookie) + return EndCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// EndUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { +func EndUnchecked(c *xgb.Conn, Cmap uint32) EndCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'End' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(endRequest(c, Cmap), cookie) + return EndCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// EndReply represents the data returned from a End request. +type EndReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ServerMajorVersion uint16 - ServerMinorVersion uint16 - // padding: 20 bytes + // padding: 24 bytes } -// 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 End request. +func (cook EndCookie) Reply() (*EndReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -160,12 +158,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return endReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// endReply reads a byte slice into a EndReply value. +func endReply(buf []byte) *EndReply { + v := new(EndReply) b := 1 // skip reply determinant b += 1 // padding @@ -176,20 +174,14 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ServerMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ServerMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - b += 20 // padding + b += 24 // padding return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { +// Write request to wire for End +// endRequest writes a End request to a byte slice. +func endRequest(c *xgb.Conn, Cmap uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -197,58 +189,57 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVers buf[b] = c.Extensions["XEVIE"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], ClientMajorVersion) - b += 2 - - xgb.Put16(buf[b:], ClientMinorVersion) - b += 2 + xgb.Put32(buf[b:], Cmap) + b += 4 return buf } -// StartCookie is a cookie used only for Start requests. -type StartCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// Start sends a checked request. -// If an error occurs, it will be returned with the reply by calling StartCookie.Reply() -func Start(c *xgb.Conn, Screen uint32) StartCookie { +// 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, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'Start' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(startRequest(c, Screen), cookie) - return StartCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// StartUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func StartUnchecked(c *xgb.Conn, Screen uint32) StartCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'Start' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(startRequest(c, Screen), cookie) - return StartCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// StartReply represents the data returned from a Start request. -type StartReply struct { +// 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 - // padding: 24 bytes + ServerMajorVersion uint16 + ServerMinorVersion uint16 + // padding: 20 bytes } -// Reply blocks and returns the reply data for a Start request. -func (cook StartCookie) Reply() (*StartReply, error) { +// 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 @@ -256,12 +247,12 @@ func (cook StartCookie) Reply() (*StartReply, error) { if buf == nil { return nil, nil } - return startReply(buf), nil + return queryVersionReply(buf), nil } -// startReply reads a byte slice into a StartReply value. -func startReply(buf []byte) *StartReply { - v := new(StartReply) +// 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 @@ -272,14 +263,20 @@ func startReply(buf []byte) *StartReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 24 // padding + v.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding return v } -// Write request to wire for Start -// startRequest writes a Start request to a byte slice. -func startRequest(c *xgb.Conn, Screen uint32) []byte { +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -287,55 +284,58 @@ func startRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["XEVIE"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 0 // 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.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) + b += 2 return buf } -// EndCookie is a cookie used only for End requests. -type EndCookie struct { +// SelectInputCookie is a cookie used only for SelectInput requests. +type SelectInputCookie struct { *xgb.Cookie } -// End sends a checked request. -// If an error occurs, it will be returned with the reply by calling EndCookie.Reply() -func End(c *xgb.Conn, Cmap uint32) EndCookie { +// SelectInput sends a checked request. +// If an error occurs, it will be returned with the reply by calling SelectInputCookie.Reply() +func SelectInput(c *xgb.Conn, EventMask uint32) SelectInputCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'End' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(endRequest(c, Cmap), cookie) - return EndCookie{cookie} + c.NewRequest(selectInputRequest(c, EventMask), cookie) + return SelectInputCookie{cookie} } -// EndUnchecked sends an unchecked request. +// SelectInputUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func EndUnchecked(c *xgb.Conn, Cmap uint32) EndCookie { +func SelectInputUnchecked(c *xgb.Conn, EventMask uint32) SelectInputCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'End' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(endRequest(c, Cmap), cookie) - return EndCookie{cookie} + c.NewRequest(selectInputRequest(c, EventMask), cookie) + return SelectInputCookie{cookie} } -// EndReply represents the data returned from a End request. -type EndReply struct { +// SelectInputReply represents the data returned from a SelectInput request. +type SelectInputReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes } -// Reply blocks and returns the reply data for a End request. -func (cook EndCookie) Reply() (*EndReply, error) { +// Reply blocks and returns the reply data for a SelectInput request. +func (cook SelectInputCookie) Reply() (*SelectInputReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -343,12 +343,12 @@ func (cook EndCookie) Reply() (*EndReply, error) { if buf == nil { return nil, nil } - return endReply(buf), nil + return selectInputReply(buf), nil } -// endReply reads a byte slice into a EndReply value. -func endReply(buf []byte) *EndReply { - v := new(EndReply) +// selectInputReply reads a byte slice into a SelectInputReply value. +func selectInputReply(buf []byte) *SelectInputReply { + v := new(SelectInputReply) b := 1 // skip reply determinant b += 1 // padding @@ -364,9 +364,9 @@ func endReply(buf []byte) *EndReply { return v } -// Write request to wire for End -// endRequest writes a End request to a byte slice. -func endRequest(c *xgb.Conn, Cmap uint32) []byte { +// Write request to wire for SelectInput +// selectInputRequest writes a SelectInput request to a byte slice. +func selectInputRequest(c *xgb.Conn, EventMask uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -374,13 +374,13 @@ func endRequest(c *xgb.Conn, Cmap uint32) []byte { buf[b] = c.Extensions["XEVIE"] b += 1 - buf[b] = 2 // request opcode + 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:], Cmap) + xgb.Put32(buf[b:], EventMask) b += 4 return buf @@ -481,43 +481,43 @@ func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte { return buf } -// SelectInputCookie is a cookie used only for SelectInput requests. -type SelectInputCookie struct { +// StartCookie is a cookie used only for Start requests. +type StartCookie struct { *xgb.Cookie } -// SelectInput sends a checked request. -// If an error occurs, it will be returned with the reply by calling SelectInputCookie.Reply() -func SelectInput(c *xgb.Conn, EventMask uint32) SelectInputCookie { +// Start sends a checked request. +// If an error occurs, it will be returned with the reply by calling StartCookie.Reply() +func Start(c *xgb.Conn, Screen uint32) StartCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'Start' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(selectInputRequest(c, EventMask), cookie) - return SelectInputCookie{cookie} + c.NewRequest(startRequest(c, Screen), cookie) + return StartCookie{cookie} } -// SelectInputUnchecked sends an unchecked request. +// StartUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectInputUnchecked(c *xgb.Conn, EventMask uint32) SelectInputCookie { +func StartUnchecked(c *xgb.Conn, Screen uint32) StartCookie { if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") + panic("Cannot issue request 'Start' using the uninitialized extension 'XEVIE'. xevie.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(selectInputRequest(c, EventMask), cookie) - return SelectInputCookie{cookie} + c.NewRequest(startRequest(c, Screen), cookie) + return StartCookie{cookie} } -// SelectInputReply represents the data returned from a SelectInput request. -type SelectInputReply struct { +// StartReply represents the data returned from a Start request. +type StartReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes } -// Reply blocks and returns the reply data for a SelectInput request. -func (cook SelectInputCookie) Reply() (*SelectInputReply, error) { +// Reply blocks and returns the reply data for a Start request. +func (cook StartCookie) Reply() (*StartReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -525,12 +525,12 @@ func (cook SelectInputCookie) Reply() (*SelectInputReply, error) { if buf == nil { return nil, nil } - return selectInputReply(buf), nil + return startReply(buf), nil } -// selectInputReply reads a byte slice into a SelectInputReply value. -func selectInputReply(buf []byte) *SelectInputReply { - v := new(SelectInputReply) +// startReply reads a byte slice into a StartReply value. +func startReply(buf []byte) *StartReply { + v := new(StartReply) b := 1 // skip reply determinant b += 1 // padding @@ -546,9 +546,9 @@ func selectInputReply(buf []byte) *SelectInputReply { return v } -// Write request to wire for SelectInput -// selectInputRequest writes a SelectInput request to a byte slice. -func selectInputRequest(c *xgb.Conn, EventMask uint32) []byte { +// Write request to wire for Start +// startRequest writes a Start request to a byte slice. +func startRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -556,13 +556,13 @@ func selectInputRequest(c *xgb.Conn, EventMask uint32) []byte { buf[b] = c.Extensions["XEVIE"] b += 1 - buf[b] = 4 // request opcode + 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:], EventMask) + xgb.Put32(buf[b:], Screen) b += 4 return buf 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,74 +192,129 @@ 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.Authenticated = xgb.Get32(buf[b:]) + b += 4 - v.DriMinorVersion = xgb.Get16(buf[b:]) + 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 + 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 - v.DriMinorPatch = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], Screen) b += 4 - return v + xgb.Put32(buf[b:], Magic) + b += 4 + + return buf } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn) []byte { - size := 4 +// 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] = 0 // request opcode + 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 } -// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. -type QueryDirectRenderingCapableCookie struct { +// CreateContextCookie is a cookie used only for CreateContext requests. +type CreateContextCookie 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 { +// 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 'QueryDirectRenderingCapable' 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(queryDirectRenderingCapableRequest(c, Screen), cookie) - return QueryDirectRenderingCapableCookie{cookie} + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} } -// QueryDirectRenderingCapableUnchecked 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 QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { +func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { 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 'CreateContext' 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} + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} } -// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. -type QueryDirectRenderingCapableReply 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 - IsCapable bool + HwContext uint32 } -// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request. -func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, 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 @@ -269,12 +322,12 @@ func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapa if buf == nil { return nil, nil } - return queryDirectRenderingCapableReply(buf), nil + return createContextReply(buf), nil } -// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. -func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { - v := new(QueryDirectRenderingCapableReply) +// 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 @@ -285,27 +338,23 @@ func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableRe v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - if buf[b] == 1 { - v.IsCapable = true - } else { - v.IsCapable = false - } - b += 1 + v.HwContext = xgb.Get32(buf[b:]) + b += 4 return v } -// 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 +// 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] = 1 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -314,50 +363,52 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], Visual) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + return buf } -// OpenConnectionCookie is a cookie used only for OpenConnection requests. -type OpenConnectionCookie struct { +// CreateDrawableCookie is a cookie used only for CreateDrawable requests. +type CreateDrawableCookie 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 { +// 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 'OpenConnection' 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(openConnectionRequest(c, Screen), cookie) - return OpenConnectionCookie{cookie} + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} } -// OpenConnectionUnchecked 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 OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { +func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { 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 'CreateDrawable' 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(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} } -// OpenConnectionReply represents the data returned from a OpenConnection request. -type OpenConnectionReply 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 - SareaHandleLow uint32 - SareaHandleHigh uint32 - BusIdLen uint32 - // padding: 12 bytes - BusId string // size: xgb.Pad((int(BusIdLen) * 1)) + HwDrawableHandle 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 CreateDrawable request. +func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -365,12 +416,12 @@ func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { if buf == nil { return nil, nil } - return openConnectionReply(buf), nil + return createDrawableReply(buf), nil } -// openConnectionReply reads a byte slice into a OpenConnectionReply value. -func openConnectionReply(buf []byte) *OpenConnectionReply { - v := new(OpenConnectionReply) +// 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 @@ -381,38 +432,81 @@ func openConnectionReply(buf []byte) *OpenConnectionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.SareaHandleLow = xgb.Get32(buf[b:]) + v.HwDrawableHandle = xgb.Get32(buf[b:]) b += 4 - v.SareaHandleHigh = xgb.Get32(buf[b:]) + 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 + 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 - v.BusIdLen = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], Drawable) b += 4 - b += 12 // padding + return buf +} - { - byteString := make([]byte, v.BusIdLen) - copy(byteString[:v.BusIdLen], buf[b:]) - v.BusId = string(byteString) - b += xgb.Pad(int(v.BusIdLen)) +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { + *xgb.Cookie +} + +// 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} +} - return v +// 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} } -// 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 +// 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 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -421,53 +515,56 @@ func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], Context) + b += 4 + return buf } -// CloseConnectionCookie is a cookie used only for CloseConnection requests. -type CloseConnectionCookie struct { +// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. +type DestroyDrawableCookie struct { *xgb.Cookie } -// CloseConnection 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 CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { +func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { 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.") + 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(closeConnectionRequest(c, Screen), cookie) - return CloseConnectionCookie{cookie} + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{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 { +// 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 'CloseConnection' 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(closeConnectionRequest(c, Screen), cookie) - return CloseConnectionCookie{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 CloseConnectionCookie) Check() error { +func (cook DestroyDrawableCookie) 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 +// 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) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -476,6 +573,9 @@ func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], Drawable) + b += 4 + return buf } @@ -590,43 +690,49 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { +// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. +type GetDeviceInfoCookie 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 { +// 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 'CreateContext' 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, true) - c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) - return CreateContextCookie{cookie} + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} } -// CreateContextUnchecked sends an unchecked request. +// GetDeviceInfoUnchecked 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 GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { 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 'GetDeviceInfo' 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} + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} } -// CreateContextReply represents the data returned from a CreateContext request. -type CreateContextReply struct { +// 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 - HwContext uint32 + 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 CreateContext request. -func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { +// 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 @@ -634,12 +740,12 @@ func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { if buf == nil { return nil, nil } - return createContextReply(buf), nil + return getDeviceInfoReply(buf), nil } -// createContextReply reads a byte slice into a CreateContextReply value. -func createContextReply(buf []byte) *CreateContextReply { - v := new(CreateContextReply) +// 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 @@ -650,233 +756,45 @@ func createContextReply(buf []byte) *CreateContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.HwContext = xgb.Get32(buf[b:]) + v.FramebufferHandleLow = xgb.Get32(buf[b:]) b += 4 - return v -} - -// 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] = 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) + v.FramebufferHandleHigh = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], Visual) + v.FramebufferOriginOffset = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], Context) + v.FramebufferSize = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// DestroyContextCookie is a cookie used only for DestroyContext requests. -type DestroyContextCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// 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 - 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) + v.FramebufferStride = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], Context) + v.DevicePrivateSize = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// 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 { - 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} -} - -// 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} -} - -// 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 - HwDrawableHandle uint32 -} - -// 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 - } - if buf == nil { - return nil, nil + v.DevicePrivate = make([]uint32, v.DevicePrivateSize) + for i := 0; i < int(v.DevicePrivateSize); i++ { + v.DevicePrivate[i] = xgb.Get32(buf[b:]) + b += 4 } - return createDrawableReply(buf), nil -} - -// 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 - - 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 + b = xgb.Pad(b) 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 - 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 -} - -// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. -type DestroyDrawableCookie 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 { - 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} -} - -// 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} -} - -// 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 +// 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 } diff --git a/nexgb/xf86vidmode/xf86vidmode.go b/nexgb/xf86vidmode/xf86vidmode.go index 7665cbf..17c3f3c 100644 --- a/nexgb/xf86vidmode/xf86vidmode.go +++ b/nexgb/xf86vidmode/xf86vidmode.go @@ -2,7 +2,7 @@ package xf86vidmode /* - This file was generated by xf86vidmode.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by xf86vidmode.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,193 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"] = 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' - -// 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' - -const ( - ModeFlagPositiveHsync = 1 - ModeFlagNegativeHsync = 2 - ModeFlagPositiveVsync = 4 - ModeFlagNegativeVsync = 8 - ModeFlagInterlace = 16 - ModeFlagCompositeSync = 32 - ModeFlagPositiveCsync = 64 - ModeFlagNegativeCsync = 128 - ModeFlagHSkew = 256 - ModeFlagBroadcast = 512 - ModeFlagPixmux = 1024 - ModeFlagDoubleClock = 2048 - ModeFlagHalfClock = 4096 -) - -const ( - ClockFlagProgramable = 1 -) - -const ( - PermissionRead = 1 - PermissionWrite = 2 -) - -type Syncrange uint32 - -type Dotclock uint32 - -type ModeInfo struct { - Dotclock Dotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint32 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 4 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 -} - -// ModeInfoRead reads a byte slice into a ModeInfo value. -func ModeInfoRead(buf []byte, v *ModeInfo) int { - b := 0 - - v.Dotclock = Dotclock(xgb.Get32(buf[b:])) - b += 4 - - v.Hdisplay = xgb.Get16(buf[b:]) - b += 2 - - v.Hsyncstart = xgb.Get16(buf[b:]) - b += 2 - - v.Hsyncend = xgb.Get16(buf[b:]) - b += 2 - - v.Htotal = xgb.Get16(buf[b:]) - b += 2 - - v.Hskew = xgb.Get32(buf[b:]) - b += 4 - - v.Vdisplay = xgb.Get16(buf[b:]) - b += 2 - - v.Vsyncstart = xgb.Get16(buf[b:]) - b += 2 - - v.Vsyncend = xgb.Get16(buf[b:]) - b += 2 - - v.Vtotal = xgb.Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Privsize = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// ModeInfoReadList reads a byte slice into a list of ModeInfo values. -func ModeInfoReadList(buf []byte, dest []ModeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ModeInfo{} - b += ModeInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a ModeInfo value to a byte slice. -func (v ModeInfo) Bytes() []byte { - buf := make([]byte, 48) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Dotclock)) - b += 4 - - xgb.Put16(buf[b:], v.Hdisplay) - b += 2 - - xgb.Put16(buf[b:], v.Hsyncstart) - b += 2 - - xgb.Put16(buf[b:], v.Hsyncend) - b += 2 - - xgb.Put16(buf[b:], v.Htotal) - b += 2 - - xgb.Put32(buf[b:], v.Hskew) - b += 4 - - xgb.Put16(buf[b:], v.Vdisplay) - b += 2 - - xgb.Put16(buf[b:], v.Vsyncstart) - b += 2 - - xgb.Put16(buf[b:], v.Vsyncend) - b += 2 - - xgb.Put16(buf[b:], v.Vtotal) - b += 2 - - b += 4 // padding - - xgb.Put32(buf[b:], v.Flags) - b += 4 - - b += 12 // padding - - xgb.Put32(buf[b:], v.Privsize) - b += 4 - - return buf -} - -// ModeInfoListBytes writes a list of ModeInfo values to a byte slice. -func ModeInfoListBytes(buf []byte, list []ModeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - // BadBadClock is the error number for a BadBadClock. const BadBadClock = 0 @@ -365,18 +178,18 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][2] = BadVTimingsErrorNew } -// BadModeUnsuitable is the error number for a BadModeUnsuitable. -const BadModeUnsuitable = 3 +// BadClientNotLocal is the error number for a BadClientNotLocal. +const BadClientNotLocal = 5 -type ModeUnsuitableError struct { +type ClientNotLocalError struct { Sequence uint16 NiceName string } -// ModeUnsuitableErrorNew constructs a ModeUnsuitableError value that implements xgb.Error from a byte slice. -func ModeUnsuitableErrorNew(buf []byte) xgb.Error { - v := ModeUnsuitableError{} - v.NiceName = "ModeUnsuitable" +// ClientNotLocalErrorNew constructs a ClientNotLocalError value that implements xgb.Error from a byte slice. +func ClientNotLocalErrorNew(buf []byte) xgb.Error { + v := ClientNotLocalError{} + v.NiceName = "ClientNotLocal" b := 1 // skip error determinant b += 1 // don't read error number @@ -387,30 +200,36 @@ func ModeUnsuitableErrorNew(buf []byte) xgb.Error { return v } -// SequenceId returns the sequence id attached to the BadModeUnsuitable error. +// SequenceId returns the sequence id attached to the BadClientNotLocal error. // This is mostly used internally. -func (err ModeUnsuitableError) SequenceId() uint16 { +func (err ClientNotLocalError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadModeUnsuitable error. If no bad value exists, 0 is returned. -func (err ModeUnsuitableError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadClientNotLocal error. If no bad value exists, 0 is returned. +func (err ClientNotLocalError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadModeUnsuitable error. +// Error returns a rudimentary string representation of the BadClientNotLocal error. -func (err ModeUnsuitableError) Error() string { +func (err ClientNotLocalError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadModeUnsuitable {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadClientNotLocal {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][3] = ModeUnsuitableErrorNew + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][5] = ClientNotLocalErrorNew } +const ( + ClockFlagProgramable = 1 +) + +type Dotclock uint32 + // BadExtensionDisabled is the error number for a BadExtensionDisabled. const BadExtensionDisabled = 4 @@ -457,18 +276,168 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][4] = ExtensionDisabledErrorNew } -// BadClientNotLocal is the error number for a BadClientNotLocal. -const BadClientNotLocal = 5 +const ( + ModeFlagPositiveHsync = 1 + ModeFlagNegativeHsync = 2 + ModeFlagPositiveVsync = 4 + ModeFlagNegativeVsync = 8 + ModeFlagInterlace = 16 + ModeFlagCompositeSync = 32 + ModeFlagPositiveCsync = 64 + ModeFlagNegativeCsync = 128 + ModeFlagHSkew = 256 + ModeFlagBroadcast = 512 + ModeFlagPixmux = 1024 + ModeFlagDoubleClock = 2048 + ModeFlagHalfClock = 4096 +) -type ClientNotLocalError struct { +type ModeInfo struct { + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint32 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 4 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 +} + +// ModeInfoRead reads a byte slice into a ModeInfo value. +func ModeInfoRead(buf []byte, v *ModeInfo) int { + b := 0 + + v.Dotclock = Dotclock(xgb.Get32(buf[b:])) + b += 4 + + v.Hdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get32(buf[b:]) + b += 4 + + v.Vdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Privsize = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// ModeInfoReadList reads a byte slice into a list of ModeInfo values. +func ModeInfoReadList(buf []byte, dest []ModeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ModeInfo{} + b += ModeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a ModeInfo value to a byte slice. +func (v ModeInfo) Bytes() []byte { + buf := make([]byte, 48) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Dotclock)) + b += 4 + + xgb.Put16(buf[b:], v.Hdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Htotal) + b += 2 + + xgb.Put32(buf[b:], v.Hskew) + b += 4 + + xgb.Put16(buf[b:], v.Vdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Vtotal) + b += 2 + + b += 4 // padding + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], v.Privsize) + b += 4 + + return buf +} + +// ModeInfoListBytes writes a list of ModeInfo values to a byte slice. +func ModeInfoListBytes(buf []byte, list []ModeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// BadModeUnsuitable is the error number for a BadModeUnsuitable. +const BadModeUnsuitable = 3 + +type ModeUnsuitableError struct { Sequence uint16 NiceName string } -// ClientNotLocalErrorNew constructs a ClientNotLocalError value that implements xgb.Error from a byte slice. -func ClientNotLocalErrorNew(buf []byte) xgb.Error { - v := ClientNotLocalError{} - v.NiceName = "ClientNotLocal" +// ModeUnsuitableErrorNew constructs a ModeUnsuitableError value that implements xgb.Error from a byte slice. +func ModeUnsuitableErrorNew(buf []byte) xgb.Error { + v := ModeUnsuitableError{} + v.NiceName = "ModeUnsuitable" b := 1 // skip error determinant b += 1 // don't read error number @@ -479,30 +448,37 @@ func ClientNotLocalErrorNew(buf []byte) xgb.Error { return v } -// SequenceId returns the sequence id attached to the BadClientNotLocal error. +// SequenceId returns the sequence id attached to the BadModeUnsuitable error. // This is mostly used internally. -func (err ClientNotLocalError) SequenceId() uint16 { +func (err ModeUnsuitableError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadClientNotLocal error. If no bad value exists, 0 is returned. -func (err ClientNotLocalError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadModeUnsuitable error. If no bad value exists, 0 is returned. +func (err ModeUnsuitableError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadClientNotLocal error. +// Error returns a rudimentary string representation of the BadModeUnsuitable error. -func (err ClientNotLocalError) Error() string { +func (err ModeUnsuitableError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadClientNotLocal {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadModeUnsuitable {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][5] = ClientNotLocalErrorNew + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][3] = ModeUnsuitableErrorNew } +const ( + PermissionRead = 1 + PermissionWrite = 2 +) + +type Syncrange uint32 + // BadZoomLocked is the error number for a BadZoomLocked. const BadZoomLocked = 6 @@ -549,284 +525,209 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][6] = ZoomLockedErrorNew } -// 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-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 - MajorVersion uint16 - MinorVersion 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 +// Skipping definition for base type 'Bool' - b += 1 // padding +// 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.MajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Void' - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Double' - return v -} +// Skipping definition for base type 'Float' -// 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) +// Skipping definition for base type 'Int16' - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 +// Skipping definition for base type 'Int32' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Int8' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' -// GetModeLineCookie is a cookie used only for GetModeLine requests. -type GetModeLineCookie struct { +// AddModeLineCookie is a cookie used only for AddModeLine requests. +type AddModeLineCookie struct { *xgb.Cookie } -// GetModeLine sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetModeLineCookie.Reply() -func GetModeLine(c *xgb.Conn, Screen uint16) GetModeLineCookie { +// AddModeLine sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AddModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'AddModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getModeLineRequest(c, Screen), cookie) - return GetModeLineCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) + return AddModeLineCookie{cookie} } -// GetModeLineUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { +// AddModeLineChecked sends a checked request. +// If an error occurs, it can be retrieved using AddModeLineCookie.Check() +func AddModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'AddModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getModeLineRequest(c, Screen), cookie) - return GetModeLineCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) + return AddModeLineCookie{cookie} } -// GetModeLineReply represents the data returned from a GetModeLine request. -type GetModeLineReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Dotclock Dotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint16 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 2 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 - Private []byte // size: xgb.Pad((int(Privsize) * 1)) +// 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 AddModeLineCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetModeLine request. -func (cook GetModeLineCookie) Reply() (*GetModeLineReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getModeLineReply(buf), nil -} +// Write request to wire for AddModeLine +// addModeLineRequest writes a AddModeLine request to a byte slice. +func addModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) []byte { + size := xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) -// getModeLineReply reads a byte slice into a GetModeLineReply value. -func getModeLineReply(buf []byte) *GetModeLineReply { - v := new(GetModeLineReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 - b += 1 // padding + buf[b] = 7 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], Screen) b += 4 - v.Dotclock = Dotclock(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Dotclock)) b += 4 - v.Hdisplay = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Hdisplay) b += 2 - v.Hsyncstart = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Hsyncstart) b += 2 - v.Hsyncend = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Hsyncend) b += 2 - v.Htotal = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Htotal) b += 2 - v.Hskew = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Hskew) b += 2 - v.Vdisplay = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Vdisplay) b += 2 - v.Vsyncstart = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Vsyncstart) b += 2 - v.Vsyncend = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Vsyncend) b += 2 - v.Vtotal = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Vtotal) b += 2 b += 2 // padding - v.Flags = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], Flags) b += 4 b += 12 // padding - v.Privsize = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], Privsize) b += 4 - v.Private = make([]byte, v.Privsize) - copy(v.Private[:v.Privsize], buf[b:]) - b += xgb.Pad(int(v.Privsize)) + xgb.Put32(buf[b:], uint32(AfterDotclock)) + b += 4 - return v -} + xgb.Put16(buf[b:], AfterHdisplay) + b += 2 -// Write request to wire for GetModeLine -// getModeLineRequest writes a GetModeLine request to a byte slice. -func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], AfterHsyncstart) + b += 2 - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 + xgb.Put16(buf[b:], AfterHsyncend) + b += 2 - buf[b] = 1 // request opcode - b += 1 + xgb.Put16(buf[b:], AfterHtotal) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], AfterHskew) b += 2 - xgb.Put16(buf[b:], Screen) + xgb.Put16(buf[b:], AfterVdisplay) + b += 2 + + xgb.Put16(buf[b:], AfterVsyncstart) + b += 2 + + xgb.Put16(buf[b:], AfterVsyncend) + b += 2 + + xgb.Put16(buf[b:], AfterVtotal) b += 2 b += 2 // padding + xgb.Put32(buf[b:], AfterFlags) + b += 4 + + b += 12 // padding + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + return buf } -// ModModeLineCookie is a cookie used only for ModModeLine requests. -type ModModeLineCookie struct { +// DeleteModeLineCookie is a cookie used only for DeleteModeLine requests. +type DeleteModeLineCookie struct { *xgb.Cookie } -// ModModeLine sends an unchecked request. +// DeleteModeLine sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ModModeLine(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { +func DeleteModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'ModModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return ModModeLineCookie{cookie} + c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return DeleteModeLineCookie{cookie} } -// ModModeLineChecked sends a checked request. -// If an error occurs, it can be retrieved using ModModeLineCookie.Check() -func ModModeLineChecked(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { +// DeleteModeLineChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteModeLineCookie.Check() +func DeleteModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'ModModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return ModModeLineCookie{cookie} + c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return DeleteModeLineCookie{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 ModModeLineCookie) Check() error { +func (cook DeleteModeLineCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ModModeLine -// modModeLineRequest writes a ModModeLine request to a byte slice. -func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) +// Write request to wire for DeleteModeLine +// deleteModeLineRequest writes a DeleteModeLine request to a byte slice. +func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -835,6 +736,9 @@ func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + xgb.Put16(buf[b:], Hdisplay) b += 2 @@ -878,42 +782,82 @@ func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart return buf } -// SwitchModeCookie is a cookie used only for SwitchMode requests. -type SwitchModeCookie struct { +// GetAllModeLinesCookie is a cookie used only for GetAllModeLines requests. +type GetAllModeLinesCookie struct { *xgb.Cookie } -// SwitchMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SwitchMode(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { +// GetAllModeLines sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetAllModeLinesCookie.Reply() +func GetAllModeLines(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SwitchMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetAllModeLines' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) - return SwitchModeCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} } -// SwitchModeChecked sends a checked request. -// If an error occurs, it can be retrieved using SwitchModeCookie.Check() -func SwitchModeChecked(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { +// GetAllModeLinesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SwitchMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetAllModeLines' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) - return SwitchModeCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{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 SwitchModeCookie) Check() error { - return cook.Cookie.Check() +// GetAllModeLinesReply represents the data returned from a GetAllModeLines request. +type GetAllModeLinesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Modecount uint32 + // padding: 20 bytes + Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) } -// Write request to wire for SwitchMode -// switchModeRequest writes a SwitchMode request to a byte slice. -func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { +// Reply blocks and returns the reply data for a GetAllModeLines request. +func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getAllModeLinesReply(buf), nil +} + +// getAllModeLinesReply reads a byte slice into a GetAllModeLinesReply value. +func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { + v := new(GetAllModeLinesReply) + 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.Modecount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Modeinfo = make([]ModeInfo, v.Modecount) + b += ModeInfoReadList(buf[b:], v.Modeinfo) + + return v +} + +// Write request to wire for GetAllModeLines +// getAllModeLinesRequest writes a GetAllModeLines request to a byte slice. +func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -921,7 +865,7 @@ func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -930,58 +874,52 @@ func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { xgb.Put16(buf[b:], Screen) b += 2 - xgb.Put16(buf[b:], Zoom) - b += 2 + b += 2 // padding return buf } -// GetMonitorCookie is a cookie used only for GetMonitor requests. -type GetMonitorCookie struct { +// GetDotClocksCookie is a cookie used only for GetDotClocks requests. +type GetDotClocksCookie struct { *xgb.Cookie } -// GetMonitor sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMonitorCookie.Reply() -func GetMonitor(c *xgb.Conn, Screen uint16) GetMonitorCookie { +// GetDotClocks sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDotClocksCookie.Reply() +func GetDotClocks(c *xgb.Conn, Screen uint16) GetDotClocksCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetMonitor' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDotClocks' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMonitorRequest(c, Screen), cookie) - return GetMonitorCookie{cookie} + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} } -// GetMonitorUnchecked sends an unchecked request. +// GetDotClocksUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMonitorUnchecked(c *xgb.Conn, Screen uint16) GetMonitorCookie { +func GetDotClocksUnchecked(c *xgb.Conn, Screen uint16) GetDotClocksCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetMonitor' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDotClocks' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMonitorRequest(c, Screen), cookie) - return GetMonitorCookie{cookie} + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} } -// GetMonitorReply represents the data returned from a GetMonitor request. -type GetMonitorReply struct { +// GetDotClocksReply represents the data returned from a GetDotClocks request. +type GetDotClocksReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - VendorLength byte - ModelLength byte - NumHsync byte - NumVsync byte - // padding: 20 bytes - Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4)) - Vsync []Syncrange // size: xgb.Pad((int(NumVsync) * 4)) - Vendor string // size: xgb.Pad((int(VendorLength) * 1)) - AlignmentPad []byte // size: xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1)) - Model string // size: xgb.Pad((int(ModelLength) * 1)) + Flags uint32 + Clocks uint32 + Maxclocks uint32 + // padding: 12 bytes + Clock []uint32 // size: xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) } -// Reply blocks and returns the reply data for a GetMonitor request. -func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { +// Reply blocks and returns the reply data for a GetDotClocks request. +func (cook GetDotClocksCookie) Reply() (*GetDotClocksReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -989,12 +927,12 @@ func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { if buf == nil { return nil, nil } - return getMonitorReply(buf), nil + return getDotClocksReply(buf), nil } -// getMonitorReply reads a byte slice into a GetMonitorReply value. -func getMonitorReply(buf []byte) *GetMonitorReply { - v := new(GetMonitorReply) +// getDotClocksReply reads a byte slice into a GetDotClocksReply value. +func getDotClocksReply(buf []byte) *GetDotClocksReply { + v := new(GetDotClocksReply) b := 1 // skip reply determinant b += 1 // padding @@ -1005,58 +943,30 @@ func getMonitorReply(buf []byte) *GetMonitorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.VendorLength = buf[b] - b += 1 - - v.ModelLength = buf[b] - b += 1 - - v.NumHsync = buf[b] - b += 1 + v.Flags = xgb.Get32(buf[b:]) + b += 4 - v.NumVsync = buf[b] - b += 1 + v.Clocks = xgb.Get32(buf[b:]) + b += 4 - b += 20 // padding + v.Maxclocks = xgb.Get32(buf[b:]) + b += 4 - v.Hsync = make([]Syncrange, v.NumHsync) - for i := 0; i < int(v.NumHsync); i++ { - v.Hsync[i] = Syncrange(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + b += 12 // padding - v.Vsync = make([]Syncrange, v.NumVsync) - for i := 0; i < int(v.NumVsync); i++ { - v.Vsync[i] = Syncrange(xgb.Get32(buf[b:])) + v.Clock = make([]uint32, ((1 - (int(v.Flags) & 1)) * int(v.Clocks))) + for i := 0; i < int(((1 - (int(v.Flags) & 1)) * int(v.Clocks))); i++ { + v.Clock[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) - { - byteString := make([]byte, v.VendorLength) - copy(byteString[:v.VendorLength], buf[b:]) - v.Vendor = string(byteString) - b += xgb.Pad(int(v.VendorLength)) - } - - v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) - copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) - b += xgb.Pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) - - { - byteString := make([]byte, v.ModelLength) - copy(byteString[:v.ModelLength], buf[b:]) - v.Model = string(byteString) - b += xgb.Pad(int(v.ModelLength)) - } - return v } -// Write request to wire for GetMonitor -// getMonitorRequest writes a GetMonitor request to a byte slice. -func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { +// Write request to wire for GetDotClocks +// getDotClocksRequest writes a GetDotClocks request to a byte slice. +func getDotClocksRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1064,7 +974,7 @@ func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1078,50 +988,94 @@ func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// LockModeSwitchCookie is a cookie used only for LockModeSwitch requests. -type LockModeSwitchCookie struct { +// GetGammaCookie is a cookie used only for GetGamma requests. +type GetGammaCookie struct { *xgb.Cookie } -// LockModeSwitch sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func LockModeSwitch(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { +// GetGamma sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGammaCookie.Reply() +func GetGamma(c *xgb.Conn, Screen uint16) GetGammaCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'LockModeSwitch' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) - return LockModeSwitchCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRequest(c, Screen), cookie) + return GetGammaCookie{cookie} } -// LockModeSwitchChecked sends a checked request. -// If an error occurs, it can be retrieved using LockModeSwitchCookie.Check() -func LockModeSwitchChecked(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { +// GetGammaUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetGammaUnchecked(c *xgb.Conn, Screen uint16) GetGammaCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'LockModeSwitch' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) - return LockModeSwitchCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRequest(c, Screen), cookie) + return GetGammaCookie{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 LockModeSwitchCookie) Check() error { - return cook.Cookie.Check() +// GetGammaReply represents the data returned from a GetGamma request. +type GetGammaReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Red uint32 + Green uint32 + Blue uint32 + // padding: 12 bytes } -// Write request to wire for LockModeSwitch -// lockModeSwitchRequest writes a LockModeSwitch request to a byte slice. -func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { - size := 8 +// Reply blocks and returns the reply data for a GetGamma request. +func (cook GetGammaCookie) Reply() (*GetGammaReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaReply(buf), nil +} + +// getGammaReply reads a byte slice into a GetGammaReply value. +func getGammaReply(buf []byte) *GetGammaReply { + v := new(GetGammaReply) + 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.Red = xgb.Get32(buf[b:]) + b += 4 + + v.Green = xgb.Get32(buf[b:]) + b += 4 + + v.Blue = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + return v +} + +// Write request to wire for GetGamma +// getGammaRequest writes a GetGamma request to a byte slice. +func getGammaRequest(c *xgb.Conn, Screen uint16) []byte { + size := 32 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1130,51 +1084,52 @@ func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { xgb.Put16(buf[b:], Screen) b += 2 - xgb.Put16(buf[b:], Lock) - b += 2 + b += 26 // padding return buf } -// GetAllModeLinesCookie is a cookie used only for GetAllModeLines requests. -type GetAllModeLinesCookie struct { +// GetGammaRampCookie is a cookie used only for GetGammaRamp requests. +type GetGammaRampCookie struct { *xgb.Cookie } -// GetAllModeLines sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetAllModeLinesCookie.Reply() -func GetAllModeLines(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { +// GetGammaRamp sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGammaRampCookie.Reply() +func GetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetAllModeLines' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) - return GetAllModeLinesCookie{cookie} + c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} } -// GetAllModeLinesUnchecked sends an unchecked request. +// GetGammaRampUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { +func GetGammaRampUnchecked(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetAllModeLines' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) - return GetAllModeLinesCookie{cookie} + c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} } -// GetAllModeLinesReply represents the data returned from a GetAllModeLines request. -type GetAllModeLinesReply struct { +// GetGammaRampReply represents the data returned from a GetGammaRamp request. +type GetGammaRampReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Modecount uint32 - // padding: 20 bytes - Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) + Size uint16 + // padding: 22 bytes + Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + Green []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) } -// Reply blocks and returns the reply data for a GetAllModeLines request. -func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { +// Reply blocks and returns the reply data for a GetGammaRamp request. +func (cook GetGammaRampCookie) Reply() (*GetGammaRampReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1182,12 +1137,12 @@ func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { if buf == nil { return nil, nil } - return getAllModeLinesReply(buf), nil + return getGammaRampReply(buf), nil } -// getAllModeLinesReply reads a byte slice into a GetAllModeLinesReply value. -func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { - v := new(GetAllModeLinesReply) +// getGammaRampReply reads a byte slice into a GetGammaRampReply value. +func getGammaRampReply(buf []byte) *GetGammaRampReply { + v := new(GetGammaRampReply) b := 1 // skip reply determinant b += 1 // padding @@ -1198,20 +1153,38 @@ func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Modecount = xgb.Get32(buf[b:]) - b += 4 + v.Size = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding + b += 22 // padding - v.Modeinfo = make([]ModeInfo, v.Modecount) - b += ModeInfoReadList(buf[b:], v.Modeinfo) + v.Red = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Red[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Green = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Green[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Blue = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Blue[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) return v } -// Write request to wire for GetAllModeLines -// getAllModeLinesRequest writes a GetAllModeLines request to a byte slice. -func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { +// Write request to wire for GetGammaRamp +// getGammaRampRequest writes a GetGammaRamp request to a byte slice. +func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1219,7 +1192,7 @@ func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1228,282 +1201,296 @@ func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { xgb.Put16(buf[b:], Screen) b += 2 - b += 2 // padding + xgb.Put16(buf[b:], Size) + b += 2 return buf } -// AddModeLineCookie is a cookie used only for AddModeLine requests. -type AddModeLineCookie struct { +// GetGammaRampSizeCookie is a cookie used only for GetGammaRampSize requests. +type GetGammaRampSizeCookie struct { *xgb.Cookie } -// AddModeLine sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AddModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { +// GetGammaRampSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGammaRampSizeCookie.Reply() +func GetGammaRampSize(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'AddModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetGammaRampSize' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) - return AddModeLineCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{cookie} } -// AddModeLineChecked sends a checked request. -// If an error occurs, it can be retrieved using AddModeLineCookie.Check() -func AddModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { +// GetGammaRampSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetGammaRampSizeUnchecked(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'AddModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetGammaRampSize' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) - return AddModeLineCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{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 AddModeLineCookie) Check() error { - return cook.Cookie.Check() +// GetGammaRampSizeReply represents the data returned from a GetGammaRampSize request. +type GetGammaRampSizeReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Size uint16 + // padding: 22 bytes } -// Write request to wire for AddModeLine -// addModeLineRequest writes a AddModeLine request to a byte slice. -func addModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) []byte { - size := xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - 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:], uint32(Dotclock)) - b += 4 - - xgb.Put16(buf[b:], Hdisplay) - b += 2 - - xgb.Put16(buf[b:], Hsyncstart) - b += 2 - - xgb.Put16(buf[b:], Hsyncend) - b += 2 - - xgb.Put16(buf[b:], Htotal) - b += 2 - - xgb.Put16(buf[b:], Hskew) - b += 2 - - xgb.Put16(buf[b:], Vdisplay) - b += 2 +// Reply blocks and returns the reply data for a GetGammaRampSize request. +func (cook GetGammaRampSizeCookie) Reply() (*GetGammaRampSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaRampSizeReply(buf), nil +} - xgb.Put16(buf[b:], Vsyncstart) - b += 2 +// getGammaRampSizeReply reads a byte slice into a GetGammaRampSizeReply value. +func getGammaRampSizeReply(buf []byte) *GetGammaRampSizeReply { + v := new(GetGammaRampSizeReply) + b := 1 // skip reply determinant - xgb.Put16(buf[b:], Vsyncend) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], Vtotal) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - b += 2 // padding - - xgb.Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - xgb.Put32(buf[b:], Privsize) - b += 4 - - xgb.Put32(buf[b:], uint32(AfterDotclock)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], AfterHdisplay) - b += 2 - - xgb.Put16(buf[b:], AfterHsyncstart) + v.Size = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], AfterHsyncend) - b += 2 + b += 22 // padding - xgb.Put16(buf[b:], AfterHtotal) - b += 2 + return v +} - xgb.Put16(buf[b:], AfterHskew) - b += 2 +// Write request to wire for GetGammaRampSize +// getGammaRampSizeRequest writes a GetGammaRampSize request to a byte slice. +func getGammaRampSizeRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) - xgb.Put16(buf[b:], AfterVdisplay) - b += 2 + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 - xgb.Put16(buf[b:], AfterVsyncstart) - b += 2 + buf[b] = 19 // request opcode + b += 1 - xgb.Put16(buf[b:], AfterVsyncend) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], AfterVtotal) + xgb.Put16(buf[b:], Screen) b += 2 b += 2 // padding - xgb.Put32(buf[b:], AfterFlags) - b += 4 - - b += 12 // padding - - copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) - return buf } -// DeleteModeLineCookie is a cookie used only for DeleteModeLine requests. -type DeleteModeLineCookie struct { +// GetModeLineCookie is a cookie used only for GetModeLine requests. +type GetModeLineCookie struct { *xgb.Cookie } -// DeleteModeLine sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { +// GetModeLine sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetModeLineCookie.Reply() +func GetModeLine(c *xgb.Conn, Screen uint16) GetModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'DeleteModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return DeleteModeLineCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{cookie} } -// DeleteModeLineChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteModeLineCookie.Check() -func DeleteModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { +// GetModeLineUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'DeleteModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return DeleteModeLineCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{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 DeleteModeLineCookie) Check() error { - return cook.Cookie.Check() +// GetModeLineReply represents the data returned from a GetModeLine request. +type GetModeLineReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint16 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 2 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 + Private []byte // size: xgb.Pad((int(Privsize) * 1)) } -// Write request to wire for DeleteModeLine -// deleteModeLineRequest writes a DeleteModeLine request to a byte slice. -func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetModeLine request. +func (cook GetModeLineCookie) Reply() (*GetModeLineReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getModeLineReply(buf), nil +} - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 +// getModeLineReply reads a byte slice into a GetModeLineReply value. +func getModeLineReply(buf []byte) *GetModeLineReply { + v := new(GetModeLineReply) + b := 1 // skip reply determinant - buf[b] = 8 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], Screen) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Dotclock)) + v.Dotclock = Dotclock(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], Hdisplay) + v.Hdisplay = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Hsyncstart) + v.Hsyncstart = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Hsyncend) + v.Hsyncend = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Htotal) + v.Htotal = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Hskew) + v.Hskew = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Vdisplay) + v.Vdisplay = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Vsyncstart) + v.Vsyncstart = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Vsyncend) + v.Vsyncend = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Vtotal) + v.Vtotal = xgb.Get16(buf[b:]) b += 2 b += 2 // padding - xgb.Put32(buf[b:], Flags) + v.Flags = xgb.Get32(buf[b:]) b += 4 b += 12 // padding - xgb.Put32(buf[b:], Privsize) + v.Privsize = xgb.Get32(buf[b:]) b += 4 - copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) + v.Private = make([]byte, v.Privsize) + copy(v.Private[:v.Privsize], buf[b:]) + b += xgb.Pad(int(v.Privsize)) + + return v +} + +// Write request to wire for GetModeLine +// getModeLineRequest writes a GetModeLine request to a byte slice. +func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding return buf } -// ValidateModeLineCookie is a cookie used only for ValidateModeLine requests. -type ValidateModeLineCookie struct { +// GetMonitorCookie is a cookie used only for GetMonitor requests. +type GetMonitorCookie struct { *xgb.Cookie } -// ValidateModeLine sends a checked request. -// If an error occurs, it will be returned with the reply by calling ValidateModeLineCookie.Reply() -func ValidateModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { +// GetMonitor sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMonitorCookie.Reply() +func GetMonitor(c *xgb.Conn, Screen uint16) GetMonitorCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'ValidateModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMonitor' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return ValidateModeLineCookie{cookie} + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} } -// ValidateModeLineUnchecked sends an unchecked request. +// GetMonitorUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ValidateModeLineUnchecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { +func GetMonitorUnchecked(c *xgb.Conn, Screen uint16) GetMonitorCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'ValidateModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMonitor' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return ValidateModeLineCookie{cookie} + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} } -// ValidateModeLineReply represents the data returned from a ValidateModeLine request. -type ValidateModeLineReply struct { +// GetMonitorReply represents the data returned from a GetMonitor request. +type GetMonitorReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Status uint32 + VendorLength byte + ModelLength byte + NumHsync byte + NumVsync byte // padding: 20 bytes + Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4)) + Vsync []Syncrange // size: xgb.Pad((int(NumVsync) * 4)) + Vendor string // size: xgb.Pad((int(VendorLength) * 1)) + AlignmentPad []byte // size: xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1)) + Model string // size: xgb.Pad((int(ModelLength) * 1)) } -// Reply blocks and returns the reply data for a ValidateModeLine request. -func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { +// Reply blocks and returns the reply data for a GetMonitor request. +func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1511,12 +1498,12 @@ func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { if buf == nil { return nil, nil } - return validateModeLineReply(buf), nil + return getMonitorReply(buf), nil } -// validateModeLineReply reads a byte slice into a ValidateModeLineReply value. -func validateModeLineReply(buf []byte) *ValidateModeLineReply { - v := new(ValidateModeLineReply) +// getMonitorReply reads a byte slice into a GetMonitorReply value. +func getMonitorReply(buf []byte) *GetMonitorReply { + v := new(GetMonitorReply) b := 1 // skip reply determinant b += 1 // padding @@ -1527,174 +1514,169 @@ func validateModeLineReply(buf []byte) *ValidateModeLineReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - return v -} + v.VendorLength = buf[b] + b += 1 -// Write request to wire for ValidateModeLine -// validateModeLineRequest writes a ValidateModeLine request to a byte slice. -func validateModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) + v.ModelLength = buf[b] + b += 1 - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + v.NumHsync = buf[b] b += 1 - buf[b] = 9 // request opcode + v.NumVsync = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + b += 20 // padding - xgb.Put32(buf[b:], Screen) - b += 4 + v.Hsync = make([]Syncrange, v.NumHsync) + for i := 0; i < int(v.NumHsync); i++ { + v.Hsync[i] = Syncrange(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) - xgb.Put32(buf[b:], uint32(Dotclock)) - b += 4 + v.Vsync = make([]Syncrange, v.NumVsync) + for i := 0; i < int(v.NumVsync); i++ { + v.Vsync[i] = Syncrange(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) - xgb.Put16(buf[b:], Hdisplay) - b += 2 + { + byteString := make([]byte, v.VendorLength) + copy(byteString[:v.VendorLength], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLength)) + } - xgb.Put16(buf[b:], Hsyncstart) - b += 2 + v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) + copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) + b += xgb.Pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) - xgb.Put16(buf[b:], Hsyncend) - b += 2 + { + byteString := make([]byte, v.ModelLength) + copy(byteString[:v.ModelLength], buf[b:]) + v.Model = string(byteString) + b += xgb.Pad(int(v.ModelLength)) + } - xgb.Put16(buf[b:], Htotal) - b += 2 + return v +} - xgb.Put16(buf[b:], Hskew) - b += 2 +// Write request to wire for GetMonitor +// getMonitorRequest writes a GetMonitor request to a byte slice. +func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) - xgb.Put16(buf[b:], Vdisplay) - b += 2 + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 - xgb.Put16(buf[b:], Vsyncstart) - b += 2 + buf[b] = 4 // request opcode + b += 1 - xgb.Put16(buf[b:], Vsyncend) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], Vtotal) + xgb.Put16(buf[b:], Screen) b += 2 b += 2 // padding - xgb.Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - xgb.Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) - return buf } -// SwitchToModeCookie is a cookie used only for SwitchToMode requests. -type SwitchToModeCookie struct { +// GetPermissionsCookie is a cookie used only for GetPermissions requests. +type GetPermissionsCookie struct { *xgb.Cookie } -// SwitchToMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SwitchToMode(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { +// GetPermissions sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPermissionsCookie.Reply() +func GetPermissions(c *xgb.Conn, Screen uint16) GetPermissionsCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SwitchToMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPermissions' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return SwitchToModeCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getPermissionsRequest(c, Screen), cookie) + return GetPermissionsCookie{cookie} } -// SwitchToModeChecked sends a checked request. -// If an error occurs, it can be retrieved using SwitchToModeCookie.Check() -func SwitchToModeChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { +// GetPermissionsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPermissionsUnchecked(c *xgb.Conn, Screen uint16) GetPermissionsCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SwitchToMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPermissions' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return SwitchToModeCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getPermissionsRequest(c, Screen), cookie) + return GetPermissionsCookie{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 SwitchToModeCookie) Check() error { - return cook.Cookie.Check() +// GetPermissionsReply represents the data returned from a GetPermissions request. +type GetPermissionsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Permissions uint32 + // padding: 20 bytes } -// Write request to wire for SwitchToMode -// switchToModeRequest writes a SwitchToMode request to a byte slice. -func switchToModeRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetPermissions request. +func (cook GetPermissionsCookie) Reply() (*GetPermissionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPermissionsReply(buf), nil +} - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 +// getPermissionsReply reads a byte slice into a GetPermissionsReply value. +func getPermissionsReply(buf []byte) *GetPermissionsReply { + v := new(GetPermissionsReply) + b := 1 // skip reply determinant - buf[b] = 10 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], Screen) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Dotclock)) + v.Permissions = xgb.Get32(buf[b:]) b += 4 - xgb.Put16(buf[b:], Hdisplay) - b += 2 - - xgb.Put16(buf[b:], Hsyncstart) - b += 2 - - xgb.Put16(buf[b:], Hsyncend) - b += 2 + b += 20 // padding - xgb.Put16(buf[b:], Htotal) - b += 2 + return v +} - xgb.Put16(buf[b:], Hskew) - b += 2 +// Write request to wire for GetPermissions +// getPermissionsRequest writes a GetPermissions request to a byte slice. +func getPermissionsRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) - xgb.Put16(buf[b:], Vdisplay) - b += 2 + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 - xgb.Put16(buf[b:], Vsyncstart) - b += 2 + buf[b] = 20 // request opcode + b += 1 - xgb.Put16(buf[b:], Vsyncend) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], Vtotal) + xgb.Put16(buf[b:], Screen) b += 2 b += 2 // padding - xgb.Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - xgb.Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) - return buf } @@ -1795,50 +1777,50 @@ func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// SetViewPortCookie is a cookie used only for SetViewPort requests. -type SetViewPortCookie struct { +// LockModeSwitchCookie is a cookie used only for LockModeSwitch requests. +type LockModeSwitchCookie struct { *xgb.Cookie } -// SetViewPort sends an unchecked request. +// LockModeSwitch sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetViewPort(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { +func LockModeSwitch(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'LockModeSwitch' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) - return SetViewPortCookie{cookie} + c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) + return LockModeSwitchCookie{cookie} } -// SetViewPortChecked sends a checked request. -// If an error occurs, it can be retrieved using SetViewPortCookie.Check() -func SetViewPortChecked(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { +// LockModeSwitchChecked sends a checked request. +// If an error occurs, it can be retrieved using LockModeSwitchCookie.Check() +func LockModeSwitchChecked(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'LockModeSwitch' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) - return SetViewPortCookie{cookie} + c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) + return LockModeSwitchCookie{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 SetViewPortCookie) Check() error { +func (cook LockModeSwitchCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetViewPort -// setViewPortRequest writes a SetViewPort request to a byte slice. -func setViewPortRequest(c *xgb.Conn, Screen uint16, X uint32, Y uint32) []byte { - size := 16 +// Write request to wire for LockModeSwitch +// lockModeSwitchRequest writes a LockModeSwitch request to a byte slice. +func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1847,58 +1829,145 @@ func setViewPortRequest(c *xgb.Conn, Screen uint16, X uint32, Y uint32) []byte { xgb.Put16(buf[b:], Screen) b += 2 + xgb.Put16(buf[b:], Lock) + b += 2 + + return buf +} + +// ModModeLineCookie is a cookie used only for ModModeLine requests. +type ModModeLineCookie struct { + *xgb.Cookie +} + +// ModModeLine sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ModModeLine(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'ModModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ModModeLineCookie{cookie} +} + +// ModModeLineChecked sends a checked request. +// If an error occurs, it can be retrieved using ModModeLineCookie.Check() +func ModModeLineChecked(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'ModModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ModModeLineCookie{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 ModModeLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ModModeLine +// modModeLineRequest writes a ModModeLine request to a byte slice. +func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + b += 2 // padding - xgb.Put32(buf[b:], X) + xgb.Put32(buf[b:], Flags) b += 4 - xgb.Put32(buf[b:], Y) + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) b += 4 + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + return buf } -// GetDotClocksCookie is a cookie used only for GetDotClocks requests. -type GetDotClocksCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// GetDotClocks sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDotClocksCookie.Reply() -func GetDotClocks(c *xgb.Conn, Screen uint16) GetDotClocksCookie { +// 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-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetDotClocks' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDotClocksRequest(c, Screen), cookie) - return GetDotClocksCookie{cookie} + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} } -// GetDotClocksUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDotClocksUnchecked(c *xgb.Conn, Screen uint16) GetDotClocksCookie { +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetDotClocks' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDotClocksRequest(c, Screen), cookie) - return GetDotClocksCookie{cookie} + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} } -// GetDotClocksReply represents the data returned from a GetDotClocks request. -type GetDotClocksReply struct { +// 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 - Flags uint32 - Clocks uint32 - Maxclocks uint32 - // padding: 12 bytes - Clock []uint32 // size: xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) + MajorVersion uint16 + MinorVersion uint16 } -// Reply blocks and returns the reply data for a GetDotClocks request. -func (cook GetDotClocksCookie) Reply() (*GetDotClocksReply, error) { +// 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 @@ -1906,12 +1975,12 @@ func (cook GetDotClocksCookie) Reply() (*GetDotClocksReply, error) { if buf == nil { return nil, nil } - return getDotClocksReply(buf), nil + return queryVersionReply(buf), nil } -// getDotClocksReply reads a byte slice into a GetDotClocksReply value. -func getDotClocksReply(buf []byte) *GetDotClocksReply { - v := new(GetDotClocksReply) +// 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 @@ -1922,48 +1991,31 @@ func getDotClocksReply(buf []byte) *GetDotClocksReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - v.Clocks = xgb.Get32(buf[b:]) - b += 4 - - v.Maxclocks = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Clock = make([]uint32, ((1 - (int(v.Flags) & 1)) * int(v.Clocks))) - for i := 0; i < int(((1 - (int(v.Flags) & 1)) * int(v.Clocks))); i++ { - v.Clock[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for GetDotClocks -// getDotClocksRequest writes a GetDotClocks request to a byte slice. -func getDotClocksRequest(c *xgb.Conn, Screen uint16) []byte { - size := 8 +// 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-VIDMODEEXTENSION"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - return buf } @@ -2093,94 +2145,50 @@ func setGammaRequest(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue return buf } -// GetGammaCookie is a cookie used only for GetGamma requests. -type GetGammaCookie struct { +// SetGammaRampCookie is a cookie used only for SetGammaRamp requests. +type SetGammaRampCookie struct { *xgb.Cookie } -// GetGamma sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetGammaCookie.Reply() -func GetGamma(c *xgb.Conn, Screen uint16) GetGammaCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getGammaRequest(c, Screen), cookie) - return GetGammaCookie{cookie} -} - -// GetGammaUnchecked sends an unchecked request. +// SetGammaRamp sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetGammaUnchecked(c *xgb.Conn, Screen uint16) GetGammaCookie { +func SetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'SetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getGammaRequest(c, Screen), cookie) - return GetGammaCookie{cookie} -} - -// GetGammaReply represents the data returned from a GetGamma request. -type GetGammaReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Red uint32 - Green uint32 - Blue uint32 - // padding: 12 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{cookie} } -// Reply blocks and returns the reply data for a GetGamma request. -func (cook GetGammaCookie) Reply() (*GetGammaReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SetGammaRampChecked sends a checked request. +// If an error occurs, it can be retrieved using SetGammaRampCookie.Check() +func SetGammaRampChecked(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'SetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - return getGammaReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{cookie} } -// getGammaReply reads a byte slice into a GetGammaReply value. -func getGammaReply(buf []byte) *GetGammaReply { - v := new(GetGammaReply) - 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.Red = xgb.Get32(buf[b:]) - b += 4 - - v.Green = xgb.Get32(buf[b:]) - b += 4 - - v.Blue = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - 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 SetGammaRampCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetGamma -// getGammaRequest writes a GetGamma request to a byte slice. -func getGammaRequest(c *xgb.Conn, Screen uint16) []byte { - size := 32 +// Write request to wire for SetGammaRamp +// setGammaRampRequest writes a SetGammaRamp request to a byte slice. +func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { + size := xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 16 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2189,115 +2197,74 @@ func getGammaRequest(c *xgb.Conn, Screen uint16) []byte { xgb.Put16(buf[b:], Screen) b += 2 - b += 26 // padding + xgb.Put16(buf[b:], Size) + b += 2 + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Red[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Green[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Blue[i]) + b += 2 + } + b = xgb.Pad(b) return buf } -// GetGammaRampCookie is a cookie used only for GetGammaRamp requests. -type GetGammaRampCookie struct { +// SetViewPortCookie is a cookie used only for SetViewPort requests. +type SetViewPortCookie struct { *xgb.Cookie } -// GetGammaRamp sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetGammaRampCookie.Reply() -func GetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) - return GetGammaRampCookie{cookie} -} - -// GetGammaRampUnchecked sends an unchecked request. +// SetViewPort sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetGammaRampUnchecked(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { +func SetViewPort(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'SetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) - return GetGammaRampCookie{cookie} -} - -// GetGammaRampReply represents the data returned from a GetGammaRamp request. -type GetGammaRampReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Size uint16 - // padding: 22 bytes - Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) - Green []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) - Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + cookie := c.NewCookie(false, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{cookie} } -// Reply blocks and returns the reply data for a GetGammaRamp request. -func (cook GetGammaRampCookie) Reply() (*GetGammaRampReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SetViewPortChecked sends a checked request. +// If an error occurs, it can be retrieved using SetViewPortCookie.Check() +func SetViewPortChecked(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'SetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - return getGammaRampReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{cookie} } -// getGammaRampReply reads a byte slice into a GetGammaRampReply value. -func getGammaRampReply(buf []byte) *GetGammaRampReply { - v := new(GetGammaRampReply) - 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.Size = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Red = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Red[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) - - v.Green = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Green[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) - - v.Blue = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Blue[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) - - 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 SetViewPortCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetGammaRamp -// getGammaRampRequest writes a GetGammaRamp request to a byte slice. -func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { - size := 8 +// Write request to wire for SetViewPort +// setViewPortRequest writes a SetViewPort request to a byte slice. +func setViewPortRequest(c *xgb.Conn, Screen uint16, X uint32, Y uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 17 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2306,56 +2273,61 @@ func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { xgb.Put16(buf[b:], Screen) b += 2 - xgb.Put16(buf[b:], Size) - b += 2 + b += 2 // padding + + xgb.Put32(buf[b:], X) + b += 4 + + xgb.Put32(buf[b:], Y) + b += 4 return buf } -// SetGammaRampCookie is a cookie used only for SetGammaRamp requests. -type SetGammaRampCookie struct { +// SwitchModeCookie is a cookie used only for SwitchMode requests. +type SwitchModeCookie struct { *xgb.Cookie } -// SetGammaRamp sends an unchecked request. +// SwitchMode sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { +func SwitchMode(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'SwitchMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) - return SetGammaRampCookie{cookie} + c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) + return SwitchModeCookie{cookie} } -// SetGammaRampChecked sends a checked request. -// If an error occurs, it can be retrieved using SetGammaRampCookie.Check() -func SetGammaRampChecked(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { +// SwitchModeChecked sends a checked request. +// If an error occurs, it can be retrieved using SwitchModeCookie.Check() +func SwitchModeChecked(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'SwitchMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) - return SetGammaRampCookie{cookie} + c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) + return SwitchModeCookie{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 SetGammaRampCookie) Check() error { +func (cook SwitchModeCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetGammaRamp -// setGammaRampRequest writes a SetGammaRamp request to a byte slice. -func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { - size := xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) +// Write request to wire for SwitchMode +// switchModeRequest writes a SwitchMode request to a byte slice. +func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2364,161 +2336,148 @@ func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, xgb.Put16(buf[b:], Screen) b += 2 - xgb.Put16(buf[b:], Size) + xgb.Put16(buf[b:], Zoom) b += 2 - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - xgb.Put16(buf[b:], Red[i]) - b += 2 - } - b = xgb.Pad(b) - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - xgb.Put16(buf[b:], Green[i]) - b += 2 - } - b = xgb.Pad(b) - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - xgb.Put16(buf[b:], Blue[i]) - b += 2 - } - b = xgb.Pad(b) - return buf } -// GetGammaRampSizeCookie is a cookie used only for GetGammaRampSize requests. -type GetGammaRampSizeCookie struct { +// SwitchToModeCookie is a cookie used only for SwitchToMode requests. +type SwitchToModeCookie struct { *xgb.Cookie } -// GetGammaRampSize sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetGammaRampSizeCookie.Reply() -func GetGammaRampSize(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { +// SwitchToMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SwitchToMode(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetGammaRampSize' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'SwitchToMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) - return GetGammaRampSizeCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return SwitchToModeCookie{cookie} } -// GetGammaRampSizeUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetGammaRampSizeUnchecked(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { +// SwitchToModeChecked sends a checked request. +// If an error occurs, it can be retrieved using SwitchToModeCookie.Check() +func SwitchToModeChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetGammaRampSize' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'SwitchToMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) - return GetGammaRampSizeCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return SwitchToModeCookie{cookie} } -// GetGammaRampSizeReply represents the data returned from a GetGammaRampSize request. -type GetGammaRampSizeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Size uint16 - // padding: 22 bytes +// 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 SwitchToModeCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetGammaRampSize request. -func (cook GetGammaRampSizeCookie) Reply() (*GetGammaRampSizeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getGammaRampSizeReply(buf), nil -} +// Write request to wire for SwitchToMode +// switchToModeRequest writes a SwitchToMode request to a byte slice. +func switchToModeRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) -// getGammaRampSizeReply reads a byte slice into a GetGammaRampSizeReply value. -func getGammaRampSizeReply(buf []byte) *GetGammaRampSizeReply { - v := new(GetGammaRampSizeReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 - b += 1 // padding + buf[b] = 10 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], Screen) b += 4 - v.Size = xgb.Get16(buf[b:]) + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) b += 2 - b += 22 // padding + xgb.Put16(buf[b:], Hsyncstart) + b += 2 - return v -} + xgb.Put16(buf[b:], Hsyncend) + b += 2 -// Write request to wire for GetGammaRampSize -// getGammaRampSizeRequest writes a GetGammaRampSize request to a byte slice. -func getGammaRampSizeRequest(c *xgb.Conn, Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], Htotal) + b += 2 - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 + xgb.Put16(buf[b:], Hskew) + b += 2 - buf[b] = 19 // request opcode - b += 1 + xgb.Put16(buf[b:], Vdisplay) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Vsyncstart) b += 2 - xgb.Put16(buf[b:], Screen) + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) b += 2 b += 2 // padding + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + return buf } -// GetPermissionsCookie is a cookie used only for GetPermissions requests. -type GetPermissionsCookie struct { +// ValidateModeLineCookie is a cookie used only for ValidateModeLine requests. +type ValidateModeLineCookie struct { *xgb.Cookie } -// GetPermissions sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPermissionsCookie.Reply() -func GetPermissions(c *xgb.Conn, Screen uint16) GetPermissionsCookie { +// ValidateModeLine sends a checked request. +// If an error occurs, it will be returned with the reply by calling ValidateModeLineCookie.Reply() +func ValidateModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetPermissions' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'ValidateModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPermissionsRequest(c, Screen), cookie) - return GetPermissionsCookie{cookie} + c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ValidateModeLineCookie{cookie} } -// GetPermissionsUnchecked sends an unchecked request. +// ValidateModeLineUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPermissionsUnchecked(c *xgb.Conn, Screen uint16) GetPermissionsCookie { +func ValidateModeLineUnchecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetPermissions' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'ValidateModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPermissionsRequest(c, Screen), cookie) - return GetPermissionsCookie{cookie} + c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ValidateModeLineCookie{cookie} } -// GetPermissionsReply represents the data returned from a GetPermissions request. -type GetPermissionsReply struct { +// ValidateModeLineReply represents the data returned from a ValidateModeLine request. +type ValidateModeLineReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Permissions uint32 + Status uint32 // padding: 20 bytes } -// Reply blocks and returns the reply data for a GetPermissions request. -func (cook GetPermissionsCookie) Reply() (*GetPermissionsReply, error) { +// Reply blocks and returns the reply data for a ValidateModeLine request. +func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2526,12 +2485,12 @@ func (cook GetPermissionsCookie) Reply() (*GetPermissionsReply, error) { if buf == nil { return nil, nil } - return getPermissionsReply(buf), nil + return validateModeLineReply(buf), nil } -// getPermissionsReply reads a byte slice into a GetPermissionsReply value. -func getPermissionsReply(buf []byte) *GetPermissionsReply { - v := new(GetPermissionsReply) +// validateModeLineReply reads a byte slice into a ValidateModeLineReply value. +func validateModeLineReply(buf []byte) *ValidateModeLineReply { + v := new(ValidateModeLineReply) b := 1 // skip reply determinant b += 1 // padding @@ -2542,7 +2501,7 @@ func getPermissionsReply(buf []byte) *GetPermissionsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Permissions = xgb.Get32(buf[b:]) + v.Status = xgb.Get32(buf[b:]) b += 4 b += 20 // padding @@ -2550,26 +2509,67 @@ func getPermissionsReply(buf []byte) *GetPermissionsReply { return v } -// Write request to wire for GetPermissions -// getPermissionsRequest writes a GetPermissions request to a byte slice. -func getPermissionsRequest(c *xgb.Conn, Screen uint16) []byte { - size := 8 +// Write request to wire for ValidateModeLine +// validateModeLineRequest writes a ValidateModeLine request to a byte slice. +func validateModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], Screen) + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) b += 2 b += 2 // padding + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + return buf } diff --git a/nexgb/xfixes/xfixes.go b/nexgb/xfixes/xfixes.go index 42e9e99..76ffddf 100644 --- a/nexgb/xfixes/xfixes.go +++ b/nexgb/xfixes/xfixes.go @@ -2,7 +2,7 @@ package xfixes /* - This file was generated by xfixes.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xfixes.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -42,79 +42,196 @@ func init() { xgb.NewExtErrorFuncs["XFIXES"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int16' +// BadBadRegion is the error number for a BadBadRegion. +const BadBadRegion = 0 -// Skipping definition for base type 'Int32' +type BadRegionError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Void' +// BadRegionErrorNew constructs a BadRegionError value that implements xgb.Error from a byte slice. +func BadRegionErrorNew(buf []byte) xgb.Error { + v := BadRegionError{} + v.NiceName = "BadRegion" -// Skipping definition for base type 'Byte' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Int8' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card16' + return v +} -// Skipping definition for base type 'Char' +// SequenceId returns the sequence id attached to the BadBadRegion error. +// This is mostly used internally. +func (err BadRegionError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Card32' +// BadId returns the 'BadValue' number if one exists for the BadBadRegion error. If no bad value exists, 0 is returned. +func (err BadRegionError) BadId() uint32 { + return 0 +} -// Skipping definition for base type 'Double' +// Error returns a rudimentary string representation of the BadBadRegion error. -// Skipping definition for base type 'Bool' +func (err BadRegionError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Float' +func init() { + xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew +} -// Skipping definition for base type 'Card8' +// CursorNotify is the event number for a CursorNotifyEvent. +const CursorNotify = 1 + +type CursorNotifyEvent struct { + Sequence uint16 + Subtype byte + Window xproto.Window + CursorSerial uint32 + Timestamp xproto.Timestamp + Name xproto.Atom + // padding: 12 bytes +} + +// CursorNotifyEventNew constructs a CursorNotifyEvent value that implements xgb.Event from a byte slice. +func CursorNotifyEventNew(buf []byte) xgb.Event { + v := CursorNotifyEvent{} + b := 1 // don't read event number + + v.Subtype = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Name = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + return v +} + +// Bytes writes a CursorNotifyEvent value to a byte slice. +func (v CursorNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Subtype + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], v.CursorSerial) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + b += 12 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the CursorNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CursorNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of CursorNotifyEvent. +func (v CursorNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("CursorSerial: %d", v.CursorSerial)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Name: %d", v.Name)) + return "CursorNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew +} const ( - SaveSetModeInsert = 0 - SaveSetModeDelete = 1 + CursorNotifyDisplayCursor = 0 ) const ( - SaveSetTargetNearest = 0 - SaveSetTargetRoot = 1 + CursorNotifyMaskDisplayCursor = 1 ) +type Region uint32 + +func NewRegionId(c *xgb.Conn) (Region, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Region(id), nil +} + const ( - SaveSetMappingMap = 0 - SaveSetMappingUnmap = 1 + RegionNone = 0 ) const ( - SelectionEventSetSelectionOwner = 0 - SelectionEventSelectionWindowDestroy = 1 - SelectionEventSelectionClientClose = 2 + SaveSetMappingMap = 0 + SaveSetMappingUnmap = 1 ) const ( - SelectionEventMaskSetSelectionOwner = 1 - SelectionEventMaskSelectionWindowDestroy = 2 - SelectionEventMaskSelectionClientClose = 4 + SaveSetModeInsert = 0 + SaveSetModeDelete = 1 ) const ( - CursorNotifyDisplayCursor = 0 + SaveSetTargetNearest = 0 + SaveSetTargetRoot = 1 ) const ( - CursorNotifyMaskDisplayCursor = 1 + SelectionEventSetSelectionOwner = 0 + SelectionEventSelectionWindowDestroy = 1 + SelectionEventSelectionClientClose = 2 ) const ( - RegionNone = 0 + SelectionEventMaskSetSelectionOwner = 1 + SelectionEventMaskSelectionWindowDestroy = 2 + SelectionEventMaskSelectionClientClose = 4 ) -type Region uint32 - -func NewRegionId(c *xgb.Conn) (Region, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Region(id), nil -} - // SelectionNotify is the event number for a SelectionNotifyEvent. const SelectionNotify = 0 @@ -218,241 +335,147 @@ func init() { xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew } -// CursorNotify is the event number for a CursorNotifyEvent. -const CursorNotify = 1 - -type CursorNotifyEvent struct { - Sequence uint16 - Subtype byte - Window xproto.Window - CursorSerial uint32 - Timestamp xproto.Timestamp - Name xproto.Atom - // padding: 12 bytes -} - -// CursorNotifyEventNew constructs a CursorNotifyEvent value that implements xgb.Event from a byte slice. -func CursorNotifyEventNew(buf []byte) xgb.Event { - v := CursorNotifyEvent{} - b := 1 // don't read event number - - v.Subtype = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - v.CursorSerial = xgb.Get32(buf[b:]) - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Name = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Bool' - b += 12 // padding +// Skipping definition for base type 'Byte' - return v -} +// Skipping definition for base type 'Card8' -// Bytes writes a CursorNotifyEvent value to a byte slice. -func (v CursorNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 +// Skipping definition for base type 'Char' - // write event number - buf[b] = 1 - b += 1 +// Skipping definition for base type 'Void' - buf[b] = v.Subtype - b += 1 +// Skipping definition for base type 'Double' - b += 2 // skip sequence number +// Skipping definition for base type 'Float' - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 +// Skipping definition for base type 'Int16' - xgb.Put32(buf[b:], v.CursorSerial) - b += 4 +// Skipping definition for base type 'Int32' - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 +// Skipping definition for base type 'Int8' - xgb.Put32(buf[b:], uint32(v.Name)) - b += 4 +// Skipping definition for base type 'Card16' - b += 12 // padding +// Skipping definition for base type 'Card32' - return buf +// ChangeCursorCookie is a cookie used only for ChangeCursor requests. +type ChangeCursorCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the CursorNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CursorNotifyEvent) SequenceId() uint16 { - return v.Sequence +// ChangeCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} } -// String is a rudimentary string representation of CursorNotifyEvent. -func (v CursorNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("CursorSerial: %d", v.CursorSerial)) - fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, xgb.Sprintf("Name: %d", v.Name)) - return "CursorNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCursorCookie.Check() +func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} } -func init() { - xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew +// 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 ChangeCursorCookie) Check() error { + return cook.Cookie.Check() } -// BadBadRegion is the error number for a BadBadRegion. -const BadBadRegion = 0 - -type BadRegionError struct { - Sequence uint16 - NiceName string -} +// Write request to wire for ChangeCursor +// changeCursorRequest writes a ChangeCursor request to a byte slice. +func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { + size := 12 + b := 0 + buf := make([]byte, size) -// BadRegionErrorNew constructs a BadRegionError value that implements xgb.Error from a byte slice. -func BadRegionErrorNew(buf []byte) xgb.Error { - v := BadRegionError{} - v.NiceName = "BadRegion" + buf[b] = c.Extensions["XFIXES"] + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = 26 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return v -} - -// SequenceId returns the sequence id attached to the BadBadRegion error. -// This is mostly used internally. -func (err BadRegionError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadBadRegion error. If no bad value exists, 0 is returned. -func (err BadRegionError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadBadRegion error. + xgb.Put32(buf[b:], uint32(Source)) + b += 4 -func (err BadRegionError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 -func init() { - xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew + return buf } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests. +type ChangeCursorByNameCookie 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionUnchecked sends an unchecked request. +// ChangeCursorByName sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { +func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), 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 - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} } -// 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 +// ChangeCursorByNameChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCursorByNameCookie.Check() +func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - return queryVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} } -// 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.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - 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 ChangeCursorByNameCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 +// Write request to wire for ChangeCursorByName +// changeCursorByNameRequest writes a ChangeCursorByName request to a byte slice. +func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 27 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ClientMajorVersion) + xgb.Put32(buf[b:], uint32(Src)) b += 4 - xgb.Put32(buf[b:], ClientMinorVersion) - b += 4 + xgb.Put16(buf[b:], Nbytes) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) return buf } @@ -523,103 +546,42 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window return buf } -// SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests. -type SelectSelectionInputCookie struct { - *xgb.Cookie -} - -// SelectSelectionInput sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) - return SelectSelectionInputCookie{cookie} -} - -// SelectSelectionInputChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectSelectionInputCookie.Check() -func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) - return SelectSelectionInputCookie{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 SelectSelectionInputCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SelectSelectionInput -// selectSelectionInputRequest writes a SelectSelectionInput request to a byte slice. -func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. -type SelectCursorInputCookie struct { +// CopyRegionCookie is a cookie used only for CopyRegion requests. +type CopyRegionCookie struct { *xgb.Cookie } -// SelectCursorInput sends an unchecked request. +// CopyRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { +func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) - return SelectCursorInputCookie{cookie} + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{cookie} } -// SelectCursorInputChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectCursorInputCookie.Check() -func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { +// CopyRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyRegionCookie.Check() +func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) - return SelectCursorInputCookie{cookie} + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{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 SelectCursorInputCookie) Check() error { +func (cook CopyRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SelectCursorInput -// selectCursorInputRequest writes a SelectCursorInput request to a byte slice. -func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { +// Write request to wire for CopyRegion +// copyRegionRequest writes a CopyRegion request to a byte slice. +func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -627,138 +589,18 @@ func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint3 buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 12 // 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:], EventMask) - b += 4 - - return buf -} - -// GetCursorImageCookie is a cookie used only for GetCursorImage requests. -type GetCursorImageCookie struct { - *xgb.Cookie -} - -// GetCursorImage sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCursorImageCookie.Reply() -func GetCursorImage(c *xgb.Conn) GetCursorImageCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCursorImageRequest(c), cookie) - return GetCursorImageCookie{cookie} -} - -// GetCursorImageUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getCursorImageRequest(c), cookie) - return GetCursorImageCookie{cookie} -} - -// GetCursorImageReply represents the data returned from a GetCursorImage request. -type GetCursorImageReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - // padding: 8 bytes - CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) -} - -// Reply blocks and returns the reply data for a GetCursorImage request. -func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCursorImageReply(buf), nil -} - -// getCursorImageReply reads a byte slice into a GetCursorImageReply value. -func getCursorImageReply(buf []byte) *GetCursorImageReply { - v := new(GetCursorImageReply) - 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 + xgb.Put32(buf[b:], uint32(Source)) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.Xhot = xgb.Get16(buf[b:]) - b += 2 - - v.Yhot = xgb.Get16(buf[b:]) - b += 2 - - v.CursorSerial = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - b += 8 // padding - - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetCursorImage -// getCursorImageRequest writes a GetCursorImage request to a byte slice. -func getCursorImageRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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 } @@ -877,69 +719,6 @@ func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pix return buf } -// CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests. -type CreateRegionFromWindowCookie struct { - *xgb.Cookie -} - -// CreateRegionFromWindow sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) - return CreateRegionFromWindowCookie{cookie} -} - -// CreateRegionFromWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRegionFromWindowCookie.Check() -func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) - return CreateRegionFromWindowCookie{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 CreateRegionFromWindowCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateRegionFromWindow -// createRegionFromWindowRequest writes a CreateRegionFromWindow request to a byte slice. -func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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:], uint32(Region)) - b += 4 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = byte(Kind) - b += 1 - - b += 3 // padding - - return buf -} - // CreateRegionFromGCCookie is a cookie used only for CreateRegionFromGC requests. type CreateRegionFromGCCookie struct { *xgb.Cookie @@ -1056,6 +835,69 @@ func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.P return buf } +// CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests. +type CreateRegionFromWindowCookie struct { + *xgb.Cookie +} + +// CreateRegionFromWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} +} + +// CreateRegionFromWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromWindowCookie.Check() +func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{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 CreateRegionFromWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromWindow +// createRegionFromWindowRequest writes a CreateRegionFromWindow request to a byte slice. +func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = byte(Kind) + b += 1 + + b += 3 // padding + + return buf +} + // DestroyRegionCookie is a cookie used only for DestroyRegion requests. type DestroyRegionCookie struct { *xgb.Cookie @@ -1111,473 +953,690 @@ func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { return buf } -// SetRegionCookie is a cookie used only for SetRegion requests. -type SetRegionCookie struct { +// ExpandRegionCookie is a cookie used only for ExpandRegion requests. +type ExpandRegionCookie struct { *xgb.Cookie } -// SetRegion sends an unchecked request. +// ExpandRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { +func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) - return SetRegionCookie{cookie} + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{cookie} } -// SetRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetRegionCookie.Check() -func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { +// ExpandRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using ExpandRegionCookie.Check() +func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) - return SetRegionCookie{cookie} + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{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 SetRegionCookie) Check() error { +func (cook ExpandRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetRegion -// setRegionRequest writes a SetRegion request to a byte slice. -func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +// Write request to wire for ExpandRegion +// expandRegionRequest writes a ExpandRegion request to a byte slice. +func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 28 // 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(Region)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - b += xproto.RectangleListBytes(buf[b:], Rectangles) + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + xgb.Put16(buf[b:], Left) + b += 2 + + xgb.Put16(buf[b:], Right) + b += 2 + + xgb.Put16(buf[b:], Top) + b += 2 + + xgb.Put16(buf[b:], Bottom) + b += 2 return buf } -// CopyRegionCookie is a cookie used only for CopyRegion requests. -type CopyRegionCookie struct { +// FetchRegionCookie is a cookie used only for FetchRegion requests. +type FetchRegionCookie struct { *xgb.Cookie } -// CopyRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { +// FetchRegion sends a checked request. +// If an error occurs, it will be returned with the reply by calling FetchRegionCookie.Reply() +func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) - return CopyRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{cookie} } -// CopyRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyRegionCookie.Check() -func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { +// FetchRegionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) - return CopyRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{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 CopyRegionCookie) Check() error { - return cook.Cookie.Check() +// FetchRegionReply represents the data returned from a FetchRegion request. +type FetchRegionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Extents xproto.Rectangle + // padding: 16 bytes + Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Write request to wire for CopyRegion -// copyRegionRequest writes a CopyRegion request to a byte slice. -func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { - size := 12 +// Reply blocks and returns the reply data for a FetchRegion request. +func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return fetchRegionReply(buf), nil +} + +// fetchRegionReply reads a byte slice into a FetchRegionReply value. +func fetchRegionReply(buf []byte) *FetchRegionReply { + v := new(FetchRegionReply) + 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.Extents = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Extents) + + b += 16 // padding + + v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for FetchRegion +// fetchRegionRequest writes a FetchRegion request to a byte slice. +func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 19 // 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(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf } -// UnionRegionCookie is a cookie used only for UnionRegion requests. -type UnionRegionCookie struct { +// GetCursorImageCookie is a cookie used only for GetCursorImage requests. +type GetCursorImageCookie struct { *xgb.Cookie } -// UnionRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { +// GetCursorImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCursorImageCookie.Reply() +func GetCursorImage(c *xgb.Conn) GetCursorImageCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) - return UnionRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{cookie} } -// UnionRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using UnionRegionCookie.Check() -func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { +// GetCursorImageUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) - return UnionRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{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 UnionRegionCookie) Check() error { - return cook.Cookie.Check() +// GetCursorImageReply represents the data returned from a GetCursorImage request. +type GetCursorImageReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + // padding: 8 bytes + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) } -// Write request to wire for UnionRegion -// unionRegionRequest writes a UnionRegion request to a byte slice. -func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { - size := 16 +// Reply blocks and returns the reply data for a GetCursorImage request. +func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageReply(buf), nil +} + +// getCursorImageReply reads a byte slice into a GetCursorImageReply value. +func getCursorImageReply(buf []byte) *GetCursorImageReply { + v := new(GetCursorImageReply) + 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.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + b += 2 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) + for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { + v.CursorImage[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCursorImage +// getCursorImageRequest writes a GetCursorImage request to a byte slice. +func getCursorImageRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 13 // request opcode + 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:], uint32(Source1)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - return buf } -// IntersectRegionCookie is a cookie used only for IntersectRegion requests. -type IntersectRegionCookie struct { +// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. +type GetCursorImageAndNameCookie struct { *xgb.Cookie } -// IntersectRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { +// GetCursorImageAndName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCursorImageAndNameCookie.Reply() +func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) - return IntersectRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{cookie} } -// IntersectRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using IntersectRegionCookie.Check() -func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { +// GetCursorImageAndNameUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) - return IntersectRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{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 IntersectRegionCookie) Check() error { - return cook.Cookie.Check() +// GetCursorImageAndNameReply represents the data returned from a GetCursorImageAndName request. +type GetCursorImageAndNameReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + CursorAtom xproto.Atom + Nbytes uint16 + // padding: 2 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) } -// Write request to wire for IntersectRegion -// intersectRegionRequest writes a IntersectRegion request to a byte slice. -func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { - size := 16 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetCursorImageAndName request. +func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageAndNameReply(buf), nil +} - buf[b] = c.Extensions["XFIXES"] - b += 1 +// getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value. +func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { + v := new(GetCursorImageAndNameReply) + b := 1 // skip reply determinant - buf[b] = 14 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Source1)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Source2)) + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + b += 2 + + v.CursorSerial = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(Destination)) + v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:])) b += 4 + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) + for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { + v.CursorImage[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCursorImageAndName +// getCursorImageAndNameRequest writes a GetCursorImageAndName request to a byte slice. +func getCursorImageAndNameRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + return buf } -// SubtractRegionCookie is a cookie used only for SubtractRegion requests. -type SubtractRegionCookie struct { +// GetCursorNameCookie is a cookie used only for GetCursorName requests. +type GetCursorNameCookie struct { *xgb.Cookie } -// SubtractRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { +// GetCursorName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCursorNameCookie.Reply() +func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) - return SubtractRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} } -// SubtractRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SubtractRegionCookie.Check() -func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { +// GetCursorNameUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) - return SubtractRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{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 SubtractRegionCookie) Check() error { - return cook.Cookie.Check() +// GetCursorNameReply represents the data returned from a GetCursorName request. +type GetCursorNameReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Atom xproto.Atom + Nbytes uint16 + // padding: 18 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) } -// Write request to wire for SubtractRegion -// subtractRegionRequest writes a SubtractRegion request to a byte slice. -func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { - size := 16 +// Reply blocks and returns the reply data for a GetCursorName request. +func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorNameReply(buf), nil +} + +// getCursorNameReply reads a byte slice into a GetCursorNameReply value. +func getCursorNameReply(buf []byte) *GetCursorNameReply { + v := new(GetCursorNameReply) + 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.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + return v +} + +// Write request to wire for GetCursorName +// getCursorNameRequest writes a GetCursorName request to a byte slice. +func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 15 // request opcode + buf[b] = 24 // 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(Source1)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 return buf } -// InvertRegionCookie is a cookie used only for InvertRegion requests. -type InvertRegionCookie struct { +// HideCursorCookie is a cookie used only for HideCursor requests. +type HideCursorCookie struct { *xgb.Cookie } -// InvertRegion sends an unchecked request. +// HideCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { +func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) - return InvertRegionCookie{cookie} + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{cookie} } -// InvertRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using InvertRegionCookie.Check() -func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { +// HideCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using HideCursorCookie.Check() +func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) - return InvertRegionCookie{cookie} + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{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 InvertRegionCookie) Check() error { +func (cook HideCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for InvertRegion -// invertRegionRequest writes a InvertRegion request to a byte slice. -func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { - size := 20 +// Write request to wire for HideCursor +// hideCursorRequest writes a HideCursor request to a byte slice. +func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 16 // request opcode + buf[b] = 29 // 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(Source)) - b += 4 - - { - structBytes := Bounds.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// TranslateRegionCookie is a cookie used only for TranslateRegion requests. -type TranslateRegionCookie struct { +// IntersectRegionCookie is a cookie used only for IntersectRegion requests. +type IntersectRegionCookie struct { *xgb.Cookie } -// TranslateRegion sends an unchecked request. +// IntersectRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { +func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) - return TranslateRegionCookie{cookie} + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{cookie} } -// TranslateRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using TranslateRegionCookie.Check() -func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { +// IntersectRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using IntersectRegionCookie.Check() +func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) - return TranslateRegionCookie{cookie} + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{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 TranslateRegionCookie) Check() error { +func (cook IntersectRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for TranslateRegion -// translateRegionRequest writes a TranslateRegion request to a byte slice. -func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { - size := 12 +// Write request to wire for IntersectRegion +// intersectRegionRequest writes a IntersectRegion request to a byte slice. +func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 17 // request opcode + buf[b] = 14 // 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(Region)) + xgb.Put32(buf[b:], uint32(Source1)) b += 4 - xgb.Put16(buf[b:], uint16(Dx)) - b += 2 + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 - xgb.Put16(buf[b:], uint16(Dy)) - b += 2 + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 return buf } -// RegionExtentsCookie is a cookie used only for RegionExtents requests. -type RegionExtentsCookie struct { +// InvertRegionCookie is a cookie used only for InvertRegion requests. +type InvertRegionCookie struct { *xgb.Cookie } -// RegionExtents sends an unchecked request. +// InvertRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { +func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) - return RegionExtentsCookie{cookie} + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{cookie} } -// RegionExtentsChecked sends a checked request. -// If an error occurs, it can be retrieved using RegionExtentsCookie.Check() -func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { +// InvertRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using InvertRegionCookie.Check() +func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) - return RegionExtentsCookie{cookie} + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{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 RegionExtentsCookie) Check() error { +func (cook InvertRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RegionExtents -// regionExtentsRequest writes a RegionExtents request to a byte slice. -func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { - size := 12 +// Write request to wire for InvertRegion +// invertRegionRequest writes a InvertRegion request to a byte slice. +func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1586,51 +1645,57 @@ func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte xgb.Put32(buf[b:], uint32(Source)) b += 4 + { + structBytes := Bounds.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } -// FetchRegionCookie is a cookie used only for FetchRegion requests. -type FetchRegionCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// FetchRegion sends a checked request. -// If an error occurs, it will be returned with the reply by calling FetchRegionCookie.Reply() -func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie { +// 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, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(fetchRegionRequest(c, Region), cookie) - return FetchRegionCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// FetchRegionUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(fetchRegionRequest(c, Region), cookie) - return FetchRegionCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// FetchRegionReply represents the data returned from a FetchRegion request. -type FetchRegionReply struct { +// 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 - Extents xproto.Rectangle + MajorVersion uint32 + MinorVersion uint32 // padding: 16 bytes - Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Reply blocks and returns the reply data for a FetchRegion request. -func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { +// 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 @@ -1638,12 +1703,12 @@ func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { if buf == nil { return nil, nil } - return fetchRegionReply(buf), nil + return queryVersionReply(buf), nil } -// fetchRegionReply reads a byte slice into a FetchRegionReply value. -func fetchRegionReply(buf []byte) *FetchRegionReply { - v := new(FetchRegionReply) +// 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 @@ -1654,208 +1719,194 @@ func fetchRegionReply(buf []byte) *FetchRegionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Extents = xproto.Rectangle{} - b += xproto.RectangleRead(buf[b:], &v.Extents) + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 - b += 16 // padding + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 - v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) - b += xproto.RectangleReadList(buf[b:], v.Rectangles) + b += 16 // padding return v } -// Write request to wire for FetchRegion -// fetchRegionRequest writes a FetchRegion request to a byte slice. -func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { - size := 8 +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 0 // 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(Region)) + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) b += 4 return buf } -// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests. -type SetGCClipRegionCookie struct { +// RegionExtentsCookie is a cookie used only for RegionExtents requests. +type RegionExtentsCookie struct { *xgb.Cookie } -// SetGCClipRegion sends an unchecked request. +// RegionExtents sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { +func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) - return SetGCClipRegionCookie{cookie} + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} } -// SetGCClipRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetGCClipRegionCookie.Check() -func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { +// RegionExtentsChecked sends a checked request. +// If an error occurs, it can be retrieved using RegionExtentsCookie.Check() +func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) - return SetGCClipRegionCookie{cookie} + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{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 SetGCClipRegionCookie) Check() error { +func (cook RegionExtentsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetGCClipRegion -// setGCClipRegionRequest writes a SetGCClipRegion request to a byte slice. -func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { - size := 16 +// Write request to wire for RegionExtents +// regionExtentsRequest writes a RegionExtents request to a byte slice. +func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 18 // 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(Gc)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - xgb.Put16(buf[b:], uint16(XOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOrigin)) - b += 2 - return buf } -// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests. -type SetWindowShapeRegionCookie struct { +// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. +type SelectCursorInputCookie struct { *xgb.Cookie } -// SetWindowShapeRegion sends an unchecked request. +// SelectCursorInput sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { +func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) - return SetWindowShapeRegionCookie{cookie} + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{cookie} } -// SetWindowShapeRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetWindowShapeRegionCookie.Check() -func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { +// SelectCursorInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectCursorInputCookie.Check() +func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) - return SetWindowShapeRegionCookie{cookie} + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{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 SetWindowShapeRegionCookie) Check() error { +func (cook SelectCursorInputCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetWindowShapeRegion -// setWindowShapeRegionRequest writes a SetWindowShapeRegion request to a byte slice. -func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { - size := 20 +// Write request to wire for SelectCursorInput +// selectCursorInputRequest writes a SelectCursorInput request to a byte slice. +func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 21 // request opcode + 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(Dest)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - buf[b] = byte(DestKind) - b += 1 - - b += 3 // padding - - xgb.Put16(buf[b:], uint16(XOffset)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOffset)) - b += 2 - - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], EventMask) b += 4 return buf } -// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests. -type SetPictureClipRegionCookie struct { +// SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests. +type SelectSelectionInputCookie struct { *xgb.Cookie } -// SetPictureClipRegion sends an unchecked request. +// SelectSelectionInput sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { +func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) - return SetPictureClipRegionCookie{cookie} + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{cookie} } -// SetPictureClipRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPictureClipRegionCookie.Check() -func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { +// SelectSelectionInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectSelectionInputCookie.Check() +func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) - return SetPictureClipRegionCookie{cookie} + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{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 SetPictureClipRegionCookie) Check() error { +func (cook SelectSelectionInputCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetPictureClipRegion -// setPictureClipRegionRequest writes a SetPictureClipRegion request to a byte slice. -func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { +// Write request to wire for SelectSelectionInput +// selectSelectionInputRequest writes a SelectSelectionInput request to a byte slice. +func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte { size := 16 b := 0 buf := make([]byte, size) @@ -1863,23 +1914,20 @@ func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Reg buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 22 // request opcode + 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(Picture)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 - xgb.Put16(buf[b:], uint16(XOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOrigin)) - b += 2 + xgb.Put32(buf[b:], EventMask) + b += 4 return buf } @@ -1947,541 +1995,493 @@ func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name return buf } -// GetCursorNameCookie is a cookie used only for GetCursorName requests. -type GetCursorNameCookie struct { +// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests. +type SetGCClipRegionCookie struct { *xgb.Cookie } -// GetCursorName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCursorNameCookie.Reply() -func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCursorNameRequest(c, Cursor), cookie) - return GetCursorNameCookie{cookie} -} - -// GetCursorNameUnchecked sends an unchecked request. +// SetGCClipRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { +func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getCursorNameRequest(c, Cursor), cookie) - return GetCursorNameCookie{cookie} -} - -// GetCursorNameReply represents the data returned from a GetCursorName request. -type GetCursorNameReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Atom xproto.Atom - Nbytes uint16 - // padding: 18 bytes - Name string // size: xgb.Pad((int(Nbytes) * 1)) + cookie := c.NewCookie(false, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} } -// Reply blocks and returns the reply data for a GetCursorName request. -func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SetGCClipRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetGCClipRegionCookie.Check() +func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - return getCursorNameReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} } -// getCursorNameReply reads a byte slice into a GetCursorNameReply value. -func getCursorNameReply(buf []byte) *GetCursorNameReply { - v := new(GetCursorNameReply) - 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.Atom = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 - - v.Nbytes = xgb.Get16(buf[b:]) - b += 2 - - b += 18 // padding - - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Nbytes)) - } - - 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 SetGCClipRegionCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetCursorName -// getCursorNameRequest writes a GetCursorName request to a byte slice. -func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { - size := 8 +// Write request to wire for SetGCClipRegion +// setGCClipRegionRequest writes a SetGCClipRegion request to a byte slice. +func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 24 // request opcode + buf[b] = 20 // 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(Cursor)) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) b += 4 + xgb.Put16(buf[b:], uint16(XOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + return buf } -// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. -type GetCursorImageAndNameCookie struct { +// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests. +type SetPictureClipRegionCookie struct { *xgb.Cookie } -// GetCursorImageAndName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCursorImageAndNameCookie.Reply() -func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie { +// SetPictureClipRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getCursorImageAndNameRequest(c), cookie) - return GetCursorImageAndNameCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} } -// GetCursorImageAndNameUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie { +// SetPictureClipRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureClipRegionCookie.Check() +func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getCursorImageAndNameRequest(c), cookie) - return GetCursorImageAndNameCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} } -// GetCursorImageAndNameReply represents the data returned from a GetCursorImageAndName request. -type GetCursorImageAndNameReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - CursorAtom xproto.Atom - Nbytes uint16 - // padding: 2 bytes - Name string // size: xgb.Pad((int(Nbytes) * 1)) - CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) +// 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 SetPictureClipRegionCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetCursorImageAndName request. -func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCursorImageAndNameReply(buf), nil -} +// Write request to wire for SetPictureClipRegion +// setPictureClipRegionRequest writes a SetPictureClipRegion request to a byte slice. +func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) -// getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value. -func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { - v := new(GetCursorImageAndNameReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XFIXES"] + b += 1 - b += 1 // padding + buf[b] = 22 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Region)) + b += 4 - v.Xhot = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(XOrigin)) b += 2 - v.Yhot = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(YOrigin)) b += 2 - v.CursorSerial = xgb.Get32(buf[b:]) - b += 4 - - v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 - - v.Nbytes = xgb.Get16(buf[b:]) - b += 2 + return buf +} - b += 2 // padding +// SetRegionCookie is a cookie used only for SetRegion requests. +type SetRegionCookie struct { + *xgb.Cookie +} - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Nbytes)) +// SetRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } + cookie := c.NewCookie(false, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = xgb.Get32(buf[b:]) - b += 4 +// SetRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetRegionCookie.Check() +func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} - 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 SetRegionCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetCursorImageAndName -// getCursorImageAndNameRequest writes a GetCursorImageAndName request to a byte slice. -func getCursorImageAndNameRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for SetRegion +// setRegionRequest writes a SetRegion request to a byte slice. +func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 25 // 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:], uint32(Region)) + b += 4 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + return buf } -// ChangeCursorCookie is a cookie used only for ChangeCursor requests. -type ChangeCursorCookie struct { +// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests. +type SetWindowShapeRegionCookie struct { *xgb.Cookie } -// ChangeCursor sends an unchecked request. +// SetWindowShapeRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { +func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) - return ChangeCursorCookie{cookie} + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{cookie} } -// ChangeCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeCursorCookie.Check() -func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { +// SetWindowShapeRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetWindowShapeRegionCookie.Check() +func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) - return ChangeCursorCookie{cookie} + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{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 ChangeCursorCookie) Check() error { +func (cook SetWindowShapeRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeCursor -// changeCursorRequest writes a ChangeCursor request to a byte slice. -func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { - size := 12 +// Write request to wire for SetWindowShapeRegion +// setWindowShapeRegionRequest writes a SetWindowShapeRegion request to a byte slice. +func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 21 // 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(Source)) + xgb.Put32(buf[b:], uint32(Dest)) b += 4 - xgb.Put32(buf[b:], uint32(Destination)) + buf[b] = byte(DestKind) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf } -// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests. -type ChangeCursorByNameCookie struct { +// ShowCursorCookie is a cookie used only for ShowCursor requests. +type ShowCursorCookie struct { *xgb.Cookie } -// ChangeCursorByName sends an unchecked request. +// ShowCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { +func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) - return ChangeCursorByNameCookie{cookie} + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{cookie} } -// ChangeCursorByNameChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeCursorByNameCookie.Check() -func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { +// ShowCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using ShowCursorCookie.Check() +func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) - return ChangeCursorByNameCookie{cookie} + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{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 ChangeCursorByNameCookie) Check() error { +func (cook ShowCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeCursorByName -// changeCursorByNameRequest writes a ChangeCursorByName request to a byte slice. -func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +// Write request to wire for ShowCursor +// showCursorRequest writes a ShowCursor request to a byte slice. +func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 27 // request opcode + buf[b] = 30 // 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(Src)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Nbytes) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:Nbytes]) - b += xgb.Pad(int(Nbytes)) - return buf } -// ExpandRegionCookie is a cookie used only for ExpandRegion requests. -type ExpandRegionCookie struct { +// SubtractRegionCookie is a cookie used only for SubtractRegion requests. +type SubtractRegionCookie struct { *xgb.Cookie } -// ExpandRegion sends an unchecked request. +// SubtractRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { +func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) - return ExpandRegionCookie{cookie} + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{cookie} } -// ExpandRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using ExpandRegionCookie.Check() -func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { +// SubtractRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SubtractRegionCookie.Check() +func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) - return ExpandRegionCookie{cookie} + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{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 ExpandRegionCookie) Check() error { +func (cook SubtractRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ExpandRegion -// expandRegionRequest writes a ExpandRegion request to a byte slice. -func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { - size := 20 +// Write request to wire for SubtractRegion +// subtractRegionRequest writes a SubtractRegion request to a byte slice. +func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 28 // request opcode + buf[b] = 15 // 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(Source)) + xgb.Put32(buf[b:], uint32(Source1)) b += 4 - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Source2)) b += 4 - xgb.Put16(buf[b:], Left) - b += 2 - - xgb.Put16(buf[b:], Right) - b += 2 - - xgb.Put16(buf[b:], Top) - b += 2 - - xgb.Put16(buf[b:], Bottom) - b += 2 + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 return buf } -// HideCursorCookie is a cookie used only for HideCursor requests. -type HideCursorCookie struct { +// TranslateRegionCookie is a cookie used only for TranslateRegion requests. +type TranslateRegionCookie struct { *xgb.Cookie } -// HideCursor sends an unchecked request. +// TranslateRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { +func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(hideCursorRequest(c, Window), cookie) - return HideCursorCookie{cookie} + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{cookie} } -// HideCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using HideCursorCookie.Check() -func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie { +// TranslateRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using TranslateRegionCookie.Check() +func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(hideCursorRequest(c, Window), cookie) - return HideCursorCookie{cookie} + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{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 HideCursorCookie) Check() error { +func (cook TranslateRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for HideCursor -// hideCursorRequest writes a HideCursor request to a byte slice. -func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for TranslateRegion +// translateRegionRequest writes a TranslateRegion request to a byte slice. +func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 29 // request opcode + buf[b] = 17 // 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)) + xgb.Put32(buf[b:], uint32(Region)) b += 4 + xgb.Put16(buf[b:], uint16(Dx)) + b += 2 + + xgb.Put16(buf[b:], uint16(Dy)) + b += 2 + return buf } -// ShowCursorCookie is a cookie used only for ShowCursor requests. -type ShowCursorCookie struct { +// UnionRegionCookie is a cookie used only for UnionRegion requests. +type UnionRegionCookie struct { *xgb.Cookie } -// ShowCursor sends an unchecked request. +// UnionRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { +func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(showCursorRequest(c, Window), cookie) - return ShowCursorCookie{cookie} + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{cookie} } -// ShowCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using ShowCursorCookie.Check() -func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { +// UnionRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using UnionRegionCookie.Check() +func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(showCursorRequest(c, Window), cookie) - return ShowCursorCookie{cookie} + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{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 ShowCursorCookie) Check() error { +func (cook UnionRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ShowCursor -// showCursorRequest writes a ShowCursor request to a byte slice. -func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for UnionRegion +// unionRegionRequest writes a UnionRegion request to a byte slice. +func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 30 // request opcode + buf[b] = 13 // 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)) + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf 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 +} diff --git a/nexgb/xinput/xinput.go b/nexgb/xinput/xinput.go index 0637653..c5a799d 100644 --- a/nexgb/xinput/xinput.go +++ b/nexgb/xinput/xinput.go @@ -2,7 +2,7 @@ package xinput /* - This file was generated by xinput.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xinput.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,143 +40,57 @@ func init() { xgb.NewExtErrorFuncs["XInputExtension"] = 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' - -// 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' - -const ( - ValuatorModeRelative = 0 - ValuatorModeAbsolute = 1 -) - -const ( - PropagateModeAddToList = 0 - PropagateModeDeleteFromList = 1 -) - -const ( - DeviceUseIsXPointer = 0 - DeviceUseIsXKeyboard = 1 - DeviceUseIsXExtensionDevice = 2 - DeviceUseIsXExtensionKeyboard = 3 - DeviceUseIsXExtensionPointer = 4 -) - -const ( - InputClassKey = 0 - InputClassButton = 1 - InputClassValuator = 2 - InputClassFeedback = 3 - InputClassProximity = 4 - InputClassFocus = 5 - InputClassOther = 6 -) - -const ( - DeviceInputModeAsyncThisDevice = 0 - DeviceInputModeSyncThisDevice = 1 - DeviceInputModeReplayThisDevice = 2 - DeviceInputModeAsyncOtherDevices = 3 - DeviceInputModeAsyncAll = 4 - DeviceInputModeSyncAll = 5 -) - -const ( - FeedbackClassKeyboard = 0 - FeedbackClassPointer = 1 - FeedbackClassString = 2 - FeedbackClassInteger = 3 - FeedbackClassLed = 4 - FeedbackClassBell = 5 -) - -type KeyCode byte - -type EventClass uint32 - -type DeviceInfo struct { - DeviceType xproto.Atom - DeviceId byte - NumClassInfo byte - DeviceUse byte - // padding: 1 bytes +type AxisInfo struct { + Resolution uint32 + Minimum int32 + Maximum int32 } -// DeviceInfoRead reads a byte slice into a DeviceInfo value. -func DeviceInfoRead(buf []byte, v *DeviceInfo) int { +// AxisInfoRead reads a byte slice into a AxisInfo value. +func AxisInfoRead(buf []byte, v *AxisInfo) int { b := 0 - v.DeviceType = xproto.Atom(xgb.Get32(buf[b:])) + v.Resolution = xgb.Get32(buf[b:]) b += 4 - v.DeviceId = buf[b] - b += 1 - - v.NumClassInfo = buf[b] - b += 1 - - v.DeviceUse = buf[b] - b += 1 + v.Minimum = int32(xgb.Get32(buf[b:])) + b += 4 - b += 1 // padding + v.Maximum = int32(xgb.Get32(buf[b:])) + b += 4 return b } -// DeviceInfoReadList reads a byte slice into a list of DeviceInfo values. -func DeviceInfoReadList(buf []byte, dest []DeviceInfo) int { +// AxisInfoReadList reads a byte slice into a list of AxisInfo values. +func AxisInfoReadList(buf []byte, dest []AxisInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceInfo{} - b += DeviceInfoRead(buf[b:], &dest[i]) + dest[i] = AxisInfo{} + b += AxisInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceInfo value to a byte slice. -func (v DeviceInfo) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a AxisInfo value to a byte slice. +func (v AxisInfo) Bytes() []byte { + buf := make([]byte, 12) b := 0 - xgb.Put32(buf[b:], uint32(v.DeviceType)) + xgb.Put32(buf[b:], v.Resolution) b += 4 - buf[b] = v.DeviceId - b += 1 - - buf[b] = v.NumClassInfo - b += 1 - - buf[b] = v.DeviceUse - b += 1 + xgb.Put32(buf[b:], uint32(v.Minimum)) + b += 4 - b += 1 // padding + xgb.Put32(buf[b:], uint32(v.Maximum)) + b += 4 return buf } -// DeviceInfoListBytes writes a list of DeviceInfo values to a byte slice. -func DeviceInfoListBytes(buf []byte, list []DeviceInfo) int { +// AxisInfoListBytes writes a list of AxisInfo values to a byte slice. +func AxisInfoListBytes(buf []byte, list []AxisInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -187,50 +101,83 @@ func DeviceInfoListBytes(buf []byte, list []DeviceInfo) int { return b } -type InputInfo struct { +type BellFeedbackCtl struct { ClassId byte - Len byte + Id byte + Len uint16 + Percent int8 + // padding: 3 bytes + Pitch int16 + Duration int16 } -// InputInfoRead reads a byte slice into a InputInfo value. -func InputInfoRead(buf []byte, v *InputInfo) int { +// BellFeedbackCtlRead reads a byte slice into a BellFeedbackCtl value. +func BellFeedbackCtlRead(buf []byte, v *BellFeedbackCtl) int { b := 0 v.ClassId = buf[b] b += 1 - v.Len = buf[b] + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Percent = int8(buf[b]) b += 1 + b += 3 // padding + + v.Pitch = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Duration = int16(xgb.Get16(buf[b:])) + b += 2 + return b } -// InputInfoReadList reads a byte slice into a list of InputInfo values. -func InputInfoReadList(buf []byte, dest []InputInfo) int { +// BellFeedbackCtlReadList reads a byte slice into a list of BellFeedbackCtl values. +func BellFeedbackCtlReadList(buf []byte, dest []BellFeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = InputInfo{} - b += InputInfoRead(buf[b:], &dest[i]) + dest[i] = BellFeedbackCtl{} + b += BellFeedbackCtlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a InputInfo value to a byte slice. -func (v InputInfo) Bytes() []byte { - buf := make([]byte, 2) +// Bytes writes a BellFeedbackCtl value to a byte slice. +func (v BellFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) b := 0 buf[b] = v.ClassId b += 1 - buf[b] = v.Len + buf[b] = v.Id b += 1 + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = byte(v.Percent) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(v.Pitch)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Duration)) + b += 2 + return buf } -// InputInfoListBytes writes a list of InputInfo values to a byte slice. -func InputInfoListBytes(buf []byte, list []InputInfo) int { +// BellFeedbackCtlListBytes writes a list of BellFeedbackCtl values to a byte slice. +func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { b := 0 var structBytes []byte for _, item := range list { @@ -241,76 +188,83 @@ func InputInfoListBytes(buf []byte, list []InputInfo) int { return b } -type KeyInfo struct { - ClassId byte - Len byte - MinKeycode KeyCode - MaxKeycode KeyCode - NumKeys uint16 - // padding: 2 bytes +type BellFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Percent byte + // padding: 3 bytes + Pitch uint16 + Duration uint16 } -// KeyInfoRead reads a byte slice into a KeyInfo value. -func KeyInfoRead(buf []byte, v *KeyInfo) int { +// BellFeedbackStateRead reads a byte slice into a BellFeedbackState value. +func BellFeedbackStateRead(buf []byte, v *BellFeedbackState) int { b := 0 v.ClassId = buf[b] b += 1 - v.Len = buf[b] + v.Id = buf[b] b += 1 - v.MinKeycode = KeyCode(buf[b]) - b += 1 + v.Len = xgb.Get16(buf[b:]) + b += 2 - v.MaxKeycode = KeyCode(buf[b]) + v.Percent = buf[b] b += 1 - v.NumKeys = xgb.Get16(buf[b:]) + b += 3 // padding + + v.Pitch = xgb.Get16(buf[b:]) b += 2 - b += 2 // padding + v.Duration = xgb.Get16(buf[b:]) + b += 2 return b } -// KeyInfoReadList reads a byte slice into a list of KeyInfo values. -func KeyInfoReadList(buf []byte, dest []KeyInfo) int { +// BellFeedbackStateReadList reads a byte slice into a list of BellFeedbackState values. +func BellFeedbackStateReadList(buf []byte, dest []BellFeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = KeyInfo{} - b += KeyInfoRead(buf[b:], &dest[i]) + dest[i] = BellFeedbackState{} + b += BellFeedbackStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a KeyInfo value to a byte slice. -func (v KeyInfo) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a BellFeedbackState value to a byte slice. +func (v BellFeedbackState) Bytes() []byte { + buf := make([]byte, 12) b := 0 buf[b] = v.ClassId b += 1 - buf[b] = v.Len + buf[b] = v.Id b += 1 - buf[b] = byte(v.MinKeycode) - b += 1 + xgb.Put16(buf[b:], v.Len) + b += 2 - buf[b] = byte(v.MaxKeycode) + buf[b] = v.Percent b += 1 - xgb.Put16(buf[b:], v.NumKeys) + b += 3 // padding + + xgb.Put16(buf[b:], v.Pitch) b += 2 - b += 2 // padding + xgb.Put16(buf[b:], v.Duration) + b += 2 return buf } -// KeyInfoListBytes writes a list of KeyInfo values to a byte slice. -func KeyInfoListBytes(buf []byte, list []KeyInfo) int { +// BellFeedbackStateListBytes writes a list of BellFeedbackState values to a byte slice. +func BellFeedbackStateListBytes(buf []byte, list []BellFeedbackState) int { b := 0 var structBytes []byte for _, item := range list { @@ -382,78 +336,16 @@ func ButtonInfoListBytes(buf []byte, list []ButtonInfo) int { return b } -type AxisInfo struct { - Resolution uint32 - Minimum int32 - Maximum int32 -} - -// AxisInfoRead reads a byte slice into a AxisInfo value. -func AxisInfoRead(buf []byte, v *AxisInfo) int { - b := 0 - - v.Resolution = xgb.Get32(buf[b:]) - b += 4 - - v.Minimum = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Maximum = int32(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// AxisInfoReadList reads a byte slice into a list of AxisInfo values. -func AxisInfoReadList(buf []byte, dest []AxisInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = AxisInfo{} - b += AxisInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a AxisInfo value to a byte slice. -func (v AxisInfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - xgb.Put32(buf[b:], v.Resolution) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Minimum)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Maximum)) - b += 4 - - return buf -} - -// AxisInfoListBytes writes a list of AxisInfo values to a byte slice. -func AxisInfoListBytes(buf []byte, list []AxisInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type ValuatorInfo struct { +type ButtonState struct { ClassId byte Len byte - AxesLen byte - Mode byte - MotionSize uint32 - Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) + NumButtons byte + // padding: 1 bytes + Buttons []byte // size: 32 } -// ValuatorInfoRead reads a byte slice into a ValuatorInfo value. -func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { +// ButtonStateRead reads a byte slice into a ButtonState value. +func ButtonStateRead(buf []byte, v *ButtonState) int { b := 0 v.ClassId = buf[b] @@ -462,34 +354,31 @@ func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { v.Len = buf[b] b += 1 - v.AxesLen = buf[b] - b += 1 - - v.Mode = buf[b] + v.NumButtons = buf[b] b += 1 - v.MotionSize = xgb.Get32(buf[b:]) - b += 4 + b += 1 // padding - v.Axes = make([]AxisInfo, v.AxesLen) - b += AxisInfoReadList(buf[b:], v.Axes) + v.Buttons = make([]byte, 32) + copy(v.Buttons[:32], buf[b:]) + b += xgb.Pad(int(32)) return b } -// ValuatorInfoReadList reads a byte slice into a list of ValuatorInfo values. -func ValuatorInfoReadList(buf []byte, dest []ValuatorInfo) int { +// ButtonStateReadList reads a byte slice into a list of ButtonState values. +func ButtonStateReadList(buf []byte, dest []ButtonState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = ValuatorInfo{} - b += ValuatorInfoRead(buf[b:], &dest[i]) + dest[i] = ButtonState{} + b += ButtonStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a ValuatorInfo value to a byte slice. -func (v ValuatorInfo) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.AxesLen) * 12)))) +// Bytes writes a ButtonState value to a byte slice. +func (v ButtonState) Bytes() []byte { + buf := make([]byte, 36) b := 0 buf[b] = v.ClassId @@ -498,22 +387,19 @@ func (v ValuatorInfo) Bytes() []byte { buf[b] = v.Len b += 1 - buf[b] = v.AxesLen - b += 1 - - buf[b] = v.Mode + buf[b] = v.NumButtons b += 1 - xgb.Put32(buf[b:], v.MotionSize) - b += 4 + b += 1 // padding - b += AxisInfoListBytes(buf[b:], v.Axes) + copy(buf[b:], v.Buttons[:32]) + b += xgb.Pad(int(32)) return buf } -// ValuatorInfoListBytes writes a list of ValuatorInfo values to a byte slice. -func ValuatorInfoListBytes(buf []byte, list []ValuatorInfo) int { +// ButtonStateListBytes writes a list of ButtonState values to a byte slice. +func ButtonStateListBytes(buf []byte, list []ButtonState) int { b := 0 var structBytes []byte for _, item := range list { @@ -524,298 +410,272 @@ func ValuatorInfoListBytes(buf []byte, list []ValuatorInfo) int { return b } -// ValuatorInfoListSize computes the size (bytes) of a list of ValuatorInfo values. -func ValuatorInfoListSize(list []ValuatorInfo) int { +// ButtonStateListSize computes the size (bytes) of a list of ButtonState values. +func ButtonStateListSize(list []ButtonState) int { size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.AxesLen) * 12))) + for _ = range list { + size += 36 } return size } -type InputClassInfo struct { - ClassId byte - EventTypeBase byte +// ChangeDeviceNotify is the event number for a ChangeDeviceNotifyEvent. +const ChangeDeviceNotify = 12 + +type ChangeDeviceNotifyEvent struct { + Sequence uint16 + DeviceId byte + Time xproto.Timestamp + Request byte + // padding: 23 bytes } -// InputClassInfoRead reads a byte slice into a InputClassInfo value. -func InputClassInfoRead(buf []byte, v *InputClassInfo) int { - b := 0 +// ChangeDeviceNotifyEventNew constructs a ChangeDeviceNotifyEvent value that implements xgb.Event from a byte slice. +func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { + v := ChangeDeviceNotifyEvent{} + b := 1 // don't read event number - v.ClassId = buf[b] + v.DeviceId = buf[b] b += 1 - v.EventTypeBase = buf[b] + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Request = buf[b] b += 1 - return b -} + b += 23 // padding -// InputClassInfoReadList reads a byte slice into a list of InputClassInfo values. -func InputClassInfoReadList(buf []byte, dest []InputClassInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = InputClassInfo{} - b += InputClassInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return v } -// Bytes writes a InputClassInfo value to a byte slice. -func (v InputClassInfo) Bytes() []byte { - buf := make([]byte, 2) +// Bytes writes a ChangeDeviceNotifyEvent value to a byte slice. +func (v ChangeDeviceNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ClassId + // write event number + buf[b] = 12 b += 1 - buf[b] = v.EventTypeBase + buf[b] = v.DeviceId b += 1 + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.Request + b += 1 + + b += 23 // padding + return buf } -// InputClassInfoListBytes writes a list of InputClassInfo values to a byte slice. -func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the ChangeDeviceNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ChangeDeviceNotifyEvent) SequenceId() uint16 { + return v.Sequence } -type DeviceTimeCoord struct { - Time xproto.Timestamp +// String is a rudimentary string representation of ChangeDeviceNotifyEvent. +func (v ChangeDeviceNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + return "ChangeDeviceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// DeviceTimeCoordRead reads a byte slice into a DeviceTimeCoord value. -func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { - b := 0 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew +} - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 +// BadClass is the error number for a BadClass. +const BadClass = 4 - return b +type ClassError struct { + Sequence uint16 + NiceName string } -// DeviceTimeCoordReadList reads a byte slice into a list of DeviceTimeCoord values. -func DeviceTimeCoordReadList(buf []byte, dest []DeviceTimeCoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DeviceTimeCoord{} - b += DeviceTimeCoordRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} +// ClassErrorNew constructs a ClassError value that implements xgb.Error from a byte slice. +func ClassErrorNew(buf []byte) xgb.Error { + v := ClassError{} + v.NiceName = "Class" -// Bytes writes a DeviceTimeCoord value to a byte slice. -func (v DeviceTimeCoord) Bytes() []byte { - buf := make([]byte, 4) - b := 0 + b := 1 // skip error determinant + b += 1 // don't read error number - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - return buf + return v } -// DeviceTimeCoordListBytes writes a list of DeviceTimeCoord values to a byte slice. -func DeviceTimeCoordListBytes(buf []byte, list []DeviceTimeCoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the BadClass error. +// This is mostly used internally. +func (err ClassError) SequenceId() uint16 { + return err.Sequence } -type FeedbackState struct { - ClassId byte - Id byte - Len uint16 +// BadId returns the 'BadValue' number if one exists for the BadClass error. If no bad value exists, 0 is returned. +func (err ClassError) BadId() uint32 { + return 0 } -// FeedbackStateRead reads a byte slice into a FeedbackState value. -func FeedbackStateRead(buf []byte, v *FeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 +// Error returns a rudimentary string representation of the BadClass error. - return b +func (err ClassError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadClass {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// FeedbackStateReadList reads a byte slice into a list of FeedbackState values. -func FeedbackStateReadList(buf []byte, dest []FeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = FeedbackState{} - b += FeedbackStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew } -// Bytes writes a FeedbackState value to a byte slice. -func (v FeedbackState) Bytes() []byte { - buf := make([]byte, 4) - b := 0 +// BadDevice is the error number for a BadDevice. +const BadDevice = 0 - buf[b] = v.ClassId - b += 1 +type DeviceError struct { + Sequence uint16 + NiceName string +} - buf[b] = v.Id - b += 1 +// DeviceErrorNew constructs a DeviceError value that implements xgb.Error from a byte slice. +func DeviceErrorNew(buf []byte) xgb.Error { + v := DeviceError{} + v.NiceName = "Device" - xgb.Put16(buf[b:], v.Len) + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - return buf + return v } -// FeedbackStateListBytes writes a list of FeedbackState values to a byte slice. -func FeedbackStateListBytes(buf []byte, list []FeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the BadDevice error. +// This is mostly used internally. +func (err DeviceError) SequenceId() uint16 { + return err.Sequence } -type KbdFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Pitch uint16 - Duration uint16 - LedMask uint32 - LedValues uint32 - GlobalAutoRepeat bool - Click byte - Percent byte - // padding: 1 bytes - AutoRepeats []byte // size: 32 +// BadId returns the 'BadValue' number if one exists for the BadDevice error. If no bad value exists, 0 is returned. +func (err DeviceError) BadId() uint32 { + return 0 } -// KbdFeedbackStateRead reads a byte slice into a KbdFeedbackState value. -func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { - b := 0 +// Error returns a rudimentary string representation of the BadDevice error. - v.ClassId = buf[b] - b += 1 +func (err DeviceError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadDevice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - v.Id = buf[b] - b += 1 +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew +} - v.Len = xgb.Get16(buf[b:]) - b += 2 +type DeviceAbsAreaCtrl struct { + ControlId uint16 + Len uint16 + OffsetX uint32 + OffsetY uint32 + Width int32 + Height int32 + Screen int32 + Following uint32 +} - v.Pitch = xgb.Get16(buf[b:]) +// DeviceAbsAreaCtrlRead reads a byte slice into a DeviceAbsAreaCtrl value. +func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) b += 2 - v.Duration = xgb.Get16(buf[b:]) + v.Len = xgb.Get16(buf[b:]) b += 2 - v.LedMask = xgb.Get32(buf[b:]) + v.OffsetX = xgb.Get32(buf[b:]) b += 4 - v.LedValues = xgb.Get32(buf[b:]) + v.OffsetY = xgb.Get32(buf[b:]) b += 4 - if buf[b] == 1 { - v.GlobalAutoRepeat = true - } else { - v.GlobalAutoRepeat = false - } - b += 1 - - v.Click = buf[b] - b += 1 + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 - v.Percent = buf[b] - b += 1 + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 - b += 1 // padding + v.Screen = int32(xgb.Get32(buf[b:])) + b += 4 - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += xgb.Pad(int(32)) + v.Following = xgb.Get32(buf[b:]) + b += 4 return b } -// KbdFeedbackStateReadList reads a byte slice into a list of KbdFeedbackState values. -func KbdFeedbackStateReadList(buf []byte, dest []KbdFeedbackState) int { +// DeviceAbsAreaCtrlReadList reads a byte slice into a list of DeviceAbsAreaCtrl values. +func DeviceAbsAreaCtrlReadList(buf []byte, dest []DeviceAbsAreaCtrl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = KbdFeedbackState{} - b += KbdFeedbackStateRead(buf[b:], &dest[i]) + dest[i] = DeviceAbsAreaCtrl{} + b += DeviceAbsAreaCtrlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a KbdFeedbackState value to a byte slice. -func (v KbdFeedbackState) Bytes() []byte { - buf := make([]byte, 52) +// Bytes writes a DeviceAbsAreaCtrl value to a byte slice. +func (v DeviceAbsAreaCtrl) Bytes() []byte { + buf := make([]byte, 28) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - xgb.Put16(buf[b:], v.Pitch) + xgb.Put16(buf[b:], v.ControlId) b += 2 - xgb.Put16(buf[b:], v.Duration) + xgb.Put16(buf[b:], v.Len) b += 2 - xgb.Put32(buf[b:], v.LedMask) + xgb.Put32(buf[b:], v.OffsetX) b += 4 - xgb.Put32(buf[b:], v.LedValues) + xgb.Put32(buf[b:], v.OffsetY) b += 4 - if v.GlobalAutoRepeat { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.Click - b += 1 + xgb.Put32(buf[b:], uint32(v.Width)) + b += 4 - buf[b] = v.Percent - b += 1 + xgb.Put32(buf[b:], uint32(v.Height)) + b += 4 - b += 1 // padding + xgb.Put32(buf[b:], uint32(v.Screen)) + b += 4 - copy(buf[b:], v.AutoRepeats[:32]) - b += xgb.Pad(int(32)) + xgb.Put32(buf[b:], v.Following) + b += 4 return buf } -// KbdFeedbackStateListBytes writes a list of KbdFeedbackState values to a byte slice. -func KbdFeedbackStateListBytes(buf []byte, list []KbdFeedbackState) int { +// DeviceAbsAreaCtrlListBytes writes a list of DeviceAbsAreaCtrl values to a byte slice. +func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { b := 0 var structBytes []byte for _, item := range list { @@ -826,92 +686,92 @@ func KbdFeedbackStateListBytes(buf []byte, list []KbdFeedbackState) int { return b } -// KbdFeedbackStateListSize computes the size (bytes) of a list of KbdFeedbackState values. -func KbdFeedbackStateListSize(list []KbdFeedbackState) int { - size := 0 - for _ = range list { - size += 52 - } - return size -} - -type PtrFeedbackState struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - AccelNum uint16 - AccelDenom uint16 - Threshold uint16 +type DeviceAbsAreaState struct { + ControlId uint16 + Len uint16 + OffsetX uint32 + OffsetY uint32 + Width uint32 + Height uint32 + Screen uint32 + Following uint32 } -// PtrFeedbackStateRead reads a byte slice into a PtrFeedbackState value. -func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) int { +// DeviceAbsAreaStateRead reads a byte slice into a DeviceAbsAreaState value. +func DeviceAbsAreaStateRead(buf []byte, v *DeviceAbsAreaState) int { b := 0 - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 + v.ControlId = xgb.Get16(buf[b:]) + b += 2 v.Len = xgb.Get16(buf[b:]) b += 2 - b += 2 // padding + v.OffsetX = xgb.Get32(buf[b:]) + b += 4 - v.AccelNum = xgb.Get16(buf[b:]) - b += 2 + v.OffsetY = xgb.Get32(buf[b:]) + b += 4 - v.AccelDenom = xgb.Get16(buf[b:]) - b += 2 + v.Width = xgb.Get32(buf[b:]) + b += 4 - v.Threshold = xgb.Get16(buf[b:]) - b += 2 + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Screen = xgb.Get32(buf[b:]) + b += 4 + + v.Following = xgb.Get32(buf[b:]) + b += 4 return b } -// PtrFeedbackStateReadList reads a byte slice into a list of PtrFeedbackState values. -func PtrFeedbackStateReadList(buf []byte, dest []PtrFeedbackState) int { +// DeviceAbsAreaStateReadList reads a byte slice into a list of DeviceAbsAreaState values. +func DeviceAbsAreaStateReadList(buf []byte, dest []DeviceAbsAreaState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = PtrFeedbackState{} - b += PtrFeedbackStateRead(buf[b:], &dest[i]) + dest[i] = DeviceAbsAreaState{} + b += DeviceAbsAreaStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a PtrFeedbackState value to a byte slice. -func (v PtrFeedbackState) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a DeviceAbsAreaState value to a byte slice. +func (v DeviceAbsAreaState) Bytes() []byte { + buf := make([]byte, 28) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 + xgb.Put16(buf[b:], v.ControlId) + b += 2 xgb.Put16(buf[b:], v.Len) b += 2 - b += 2 // padding + xgb.Put32(buf[b:], v.OffsetX) + b += 4 - xgb.Put16(buf[b:], v.AccelNum) - b += 2 + xgb.Put32(buf[b:], v.OffsetY) + b += 4 - xgb.Put16(buf[b:], v.AccelDenom) - b += 2 + xgb.Put32(buf[b:], v.Width) + b += 4 - xgb.Put16(buf[b:], v.Threshold) - b += 2 + xgb.Put32(buf[b:], v.Height) + b += 4 + + xgb.Put32(buf[b:], v.Screen) + b += 4 + + xgb.Put32(buf[b:], v.Following) + b += 4 return buf } -// PtrFeedbackStateListBytes writes a list of PtrFeedbackState values to a byte slice. -func PtrFeedbackStateListBytes(buf []byte, list []PtrFeedbackState) int { +// DeviceAbsAreaStateListBytes writes a list of DeviceAbsAreaState values to a byte slice. +func DeviceAbsAreaStateListBytes(buf []byte, list []DeviceAbsAreaState) int { b := 0 var structBytes []byte for _, item := range list { @@ -922,78 +782,106 @@ func PtrFeedbackStateListBytes(buf []byte, list []PtrFeedbackState) int { return b } -type IntegerFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Resolution uint32 - MinValue int32 - MaxValue int32 +type DeviceAbsCalibCtl struct { + ControlId uint16 + Len uint16 + MinX int32 + MaxX int32 + MinY int32 + MaxY int32 + FlipX uint32 + FlipY uint32 + Rotation uint32 + ButtonThreshold uint32 } -// IntegerFeedbackStateRead reads a byte slice into a IntegerFeedbackState value. -func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { +// DeviceAbsCalibCtlRead reads a byte slice into a DeviceAbsCalibCtl value. +func DeviceAbsCalibCtlRead(buf []byte, v *DeviceAbsCalibCtl) int { b := 0 - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 + v.ControlId = xgb.Get16(buf[b:]) + b += 2 v.Len = xgb.Get16(buf[b:]) b += 2 - v.Resolution = xgb.Get32(buf[b:]) + v.MinX = int32(xgb.Get32(buf[b:])) b += 4 - v.MinValue = int32(xgb.Get32(buf[b:])) + v.MaxX = int32(xgb.Get32(buf[b:])) b += 4 - v.MaxValue = int32(xgb.Get32(buf[b:])) + v.MinY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.FlipX = xgb.Get32(buf[b:]) + b += 4 + + v.FlipY = xgb.Get32(buf[b:]) + b += 4 + + v.Rotation = xgb.Get32(buf[b:]) + b += 4 + + v.ButtonThreshold = xgb.Get32(buf[b:]) b += 4 return b } -// IntegerFeedbackStateReadList reads a byte slice into a list of IntegerFeedbackState values. -func IntegerFeedbackStateReadList(buf []byte, dest []IntegerFeedbackState) int { +// DeviceAbsCalibCtlReadList reads a byte slice into a list of DeviceAbsCalibCtl values. +func DeviceAbsCalibCtlReadList(buf []byte, dest []DeviceAbsCalibCtl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = IntegerFeedbackState{} - b += IntegerFeedbackStateRead(buf[b:], &dest[i]) + dest[i] = DeviceAbsCalibCtl{} + b += DeviceAbsCalibCtlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a IntegerFeedbackState value to a byte slice. -func (v IntegerFeedbackState) Bytes() []byte { - buf := make([]byte, 16) +// Bytes writes a DeviceAbsCalibCtl value to a byte slice. +func (v DeviceAbsCalibCtl) Bytes() []byte { + buf := make([]byte, 36) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 + xgb.Put16(buf[b:], v.ControlId) + b += 2 xgb.Put16(buf[b:], v.Len) b += 2 - xgb.Put32(buf[b:], v.Resolution) + xgb.Put32(buf[b:], uint32(v.MinX)) b += 4 - xgb.Put32(buf[b:], uint32(v.MinValue)) + xgb.Put32(buf[b:], uint32(v.MaxX)) b += 4 - xgb.Put32(buf[b:], uint32(v.MaxValue)) + xgb.Put32(buf[b:], uint32(v.MinY)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxY)) + b += 4 + + xgb.Put32(buf[b:], v.FlipX) + b += 4 + + xgb.Put32(buf[b:], v.FlipY) + b += 4 + + xgb.Put32(buf[b:], v.Rotation) + b += 4 + + xgb.Put32(buf[b:], v.ButtonThreshold) b += 4 return buf } -// IntegerFeedbackStateListBytes writes a list of IntegerFeedbackState values to a byte slice. -func IntegerFeedbackStateListBytes(buf []byte, list []IntegerFeedbackState) int { +// DeviceAbsCalibCtlListBytes writes a list of DeviceAbsCalibCtl values to a byte slice. +func DeviceAbsCalibCtlListBytes(buf []byte, list []DeviceAbsCalibCtl) int { b := 0 var structBytes []byte for _, item := range list { @@ -1004,85 +892,106 @@ func IntegerFeedbackStateListBytes(buf []byte, list []IntegerFeedbackState) int return b } -type StringFeedbackState struct { - ClassId byte - Id byte - Len uint16 - MaxSymbols uint16 - NumKeysyms uint16 - Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +type DeviceAbsCalibState struct { + ControlId uint16 + Len uint16 + MinX int32 + MaxX int32 + MinY int32 + MaxY int32 + FlipX uint32 + FlipY uint32 + Rotation uint32 + ButtonThreshold uint32 } -// StringFeedbackStateRead reads a byte slice into a StringFeedbackState value. -func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { +// DeviceAbsCalibStateRead reads a byte slice into a DeviceAbsCalibState value. +func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { b := 0 - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 + v.ControlId = xgb.Get16(buf[b:]) + b += 2 v.Len = xgb.Get16(buf[b:]) b += 2 - v.MaxSymbols = xgb.Get16(buf[b:]) - b += 2 + v.MinX = int32(xgb.Get32(buf[b:])) + b += 4 - v.NumKeysyms = xgb.Get16(buf[b:]) - b += 2 + v.MaxX = int32(xgb.Get32(buf[b:])) + b += 4 - v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) - for i := 0; i < int(v.NumKeysyms); i++ { - v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + v.MinY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.FlipX = xgb.Get32(buf[b:]) + b += 4 + + v.FlipY = xgb.Get32(buf[b:]) + b += 4 + + v.Rotation = xgb.Get32(buf[b:]) + b += 4 + + v.ButtonThreshold = xgb.Get32(buf[b:]) + b += 4 return b } -// StringFeedbackStateReadList reads a byte slice into a list of StringFeedbackState values. -func StringFeedbackStateReadList(buf []byte, dest []StringFeedbackState) int { +// DeviceAbsCalibStateReadList reads a byte slice into a list of DeviceAbsCalibState values. +func DeviceAbsCalibStateReadList(buf []byte, dest []DeviceAbsCalibState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = StringFeedbackState{} - b += StringFeedbackStateRead(buf[b:], &dest[i]) + dest[i] = DeviceAbsCalibState{} + b += DeviceAbsCalibStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a StringFeedbackState value to a byte slice. -func (v StringFeedbackState) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) +// Bytes writes a DeviceAbsCalibState value to a byte slice. +func (v DeviceAbsCalibState) Bytes() []byte { + buf := make([]byte, 36) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 + xgb.Put16(buf[b:], v.ControlId) + b += 2 xgb.Put16(buf[b:], v.Len) b += 2 - xgb.Put16(buf[b:], v.MaxSymbols) - b += 2 + xgb.Put32(buf[b:], uint32(v.MinX)) + b += 4 - xgb.Put16(buf[b:], v.NumKeysyms) - b += 2 + xgb.Put32(buf[b:], uint32(v.MaxX)) + b += 4 - for i := 0; i < int(v.NumKeysyms); i++ { - xgb.Put32(buf[b:], uint32(v.Keysyms[i])) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(v.MinY)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxY)) + b += 4 + + xgb.Put32(buf[b:], v.FlipX) + b += 4 + + xgb.Put32(buf[b:], v.FlipY) + b += 4 + + xgb.Put32(buf[b:], v.Rotation) + b += 4 + + xgb.Put32(buf[b:], v.ButtonThreshold) + b += 4 return buf } -// StringFeedbackStateListBytes writes a list of StringFeedbackState values to a byte slice. -func StringFeedbackStateListBytes(buf []byte, list []StringFeedbackState) int { +// DeviceAbsCalibStateListBytes writes a list of DeviceAbsCalibState values to a byte slice. +func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) int { b := 0 var structBytes []byte for _, item := range list { @@ -1093,228 +1002,262 @@ func StringFeedbackStateListBytes(buf []byte, list []StringFeedbackState) int { return b } -// StringFeedbackStateListSize computes the size (bytes) of a list of StringFeedbackState values. -func StringFeedbackStateListSize(list []StringFeedbackState) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) - } - return size -} +// BadDeviceBusy is the error number for a BadDeviceBusy. +const BadDeviceBusy = 3 -type BellFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Percent byte - // padding: 3 bytes - Pitch uint16 - Duration uint16 +type DeviceBusyError struct { + Sequence uint16 + NiceName string } -// BellFeedbackStateRead reads a byte slice into a BellFeedbackState value. -func BellFeedbackStateRead(buf []byte, v *BellFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 +// DeviceBusyErrorNew constructs a DeviceBusyError value that implements xgb.Error from a byte slice. +func DeviceBusyErrorNew(buf []byte) xgb.Error { + v := DeviceBusyError{} + v.NiceName = "DeviceBusy" - v.Id = buf[b] - b += 1 + b := 1 // skip error determinant + b += 1 // don't read error number - v.Len = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Percent = buf[b] - b += 1 + return v +} - b += 3 // padding +// SequenceId returns the sequence id attached to the BadDeviceBusy error. +// This is mostly used internally. +func (err DeviceBusyError) SequenceId() uint16 { + return err.Sequence +} - v.Pitch = xgb.Get16(buf[b:]) - b += 2 +// BadId returns the 'BadValue' number if one exists for the BadDeviceBusy error. If no bad value exists, 0 is returned. +func (err DeviceBusyError) BadId() uint32 { + return 0 +} - v.Duration = xgb.Get16(buf[b:]) - b += 2 +// Error returns a rudimentary string representation of the BadDeviceBusy error. - return b +func (err DeviceBusyError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadDeviceBusy {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// BellFeedbackStateReadList reads a byte slice into a list of BellFeedbackState values. -func BellFeedbackStateReadList(buf []byte, dest []BellFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = BellFeedbackState{} - b += BellFeedbackStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew } -// Bytes writes a BellFeedbackState value to a byte slice. -func (v BellFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 +// DeviceButtonPress is the event number for a DeviceButtonPressEvent. +const DeviceButtonPress = 3 - buf[b] = v.ClassId - b += 1 +type DeviceButtonPressEvent DeviceKeyPressEvent - buf[b] = v.Id - b += 1 +// DeviceButtonPressEventNew constructs a DeviceButtonPressEvent value that implements xgb.Event from a byte slice. +func DeviceButtonPressEventNew(buf []byte) xgb.Event { + return DeviceButtonPressEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} - xgb.Put16(buf[b:], v.Len) - b += 2 +// Bytes writes a DeviceButtonPressEvent value to a byte slice. +func (v DeviceButtonPressEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} - buf[b] = v.Percent - b += 1 +// SequenceId returns the sequence id attached to the DeviceButtonPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceButtonPressEvent) SequenceId() uint16 { + return v.Sequence +} - b += 3 // padding +func (v DeviceButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - xgb.Put16(buf[b:], v.Pitch) - b += 2 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew +} - xgb.Put16(buf[b:], v.Duration) - b += 2 +// DeviceButtonRelease is the event number for a DeviceButtonReleaseEvent. +const DeviceButtonRelease = 4 - return buf +type DeviceButtonReleaseEvent DeviceKeyPressEvent + +// DeviceButtonReleaseEventNew constructs a DeviceButtonReleaseEvent value that implements xgb.Event from a byte slice. +func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { + return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } -// BellFeedbackStateListBytes writes a list of BellFeedbackState values to a byte slice. -func BellFeedbackStateListBytes(buf []byte, list []BellFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// Bytes writes a DeviceButtonReleaseEvent value to a byte slice. +func (v DeviceButtonReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() } -type LedFeedbackState struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 +// SequenceId returns the sequence id attached to the DeviceButtonRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceButtonReleaseEvent) SequenceId() uint16 { + return v.Sequence } -// LedFeedbackStateRead reads a byte slice into a LedFeedbackState value. -func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { - b := 0 +func (v DeviceButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - v.ClassId = buf[b] - b += 1 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew +} - v.Id = buf[b] - b += 1 +// DeviceButtonStateNotify is the event number for a DeviceButtonStateNotifyEvent. +const DeviceButtonStateNotify = 14 - v.Len = xgb.Get16(buf[b:]) - b += 2 +type DeviceButtonStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Buttons []byte // size: 28 +} - v.LedMask = xgb.Get32(buf[b:]) - b += 4 +// DeviceButtonStateNotifyEventNew constructs a DeviceButtonStateNotifyEvent value that implements xgb.Event from a byte slice. +func DeviceButtonStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceButtonStateNotifyEvent{} + b := 1 // don't read event number - v.LedValues = xgb.Get32(buf[b:]) - b += 4 + v.DeviceId = buf[b] + b += 1 - return b -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// LedFeedbackStateReadList reads a byte slice into a list of LedFeedbackState values. -func LedFeedbackStateReadList(buf []byte, dest []LedFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = LedFeedbackState{} - b += LedFeedbackStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + v.Buttons = make([]byte, 28) + copy(v.Buttons[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v } -// Bytes writes a LedFeedbackState value to a byte slice. -func (v LedFeedbackState) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a DeviceButtonStateNotifyEvent value to a byte slice. +func (v DeviceButtonStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ClassId + // write event number + buf[b] = 14 b += 1 - buf[b] = v.Id + buf[b] = v.DeviceId b += 1 - xgb.Put16(buf[b:], v.Len) - b += 2 - - xgb.Put32(buf[b:], v.LedMask) - b += 4 + b += 2 // skip sequence number - xgb.Put32(buf[b:], v.LedValues) - b += 4 + copy(buf[b:], v.Buttons[:28]) + b += xgb.Pad(int(28)) return buf } -// LedFeedbackStateListBytes writes a list of LedFeedbackState values to a byte slice. -func LedFeedbackStateListBytes(buf []byte, list []LedFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the DeviceButtonStateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceButtonStateNotifyEvent) SequenceId() uint16 { + return v.Sequence } -type FeedbackCtl struct { - ClassId byte - Id byte - Len uint16 +// String is a rudimentary string representation of DeviceButtonStateNotifyEvent. +func (v DeviceButtonStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// FeedbackCtlRead reads a byte slice into a FeedbackCtl value. -func FeedbackCtlRead(buf []byte, v *FeedbackCtl) int { - b := 0 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][14] = DeviceButtonStateNotifyEventNew +} - v.ClassId = buf[b] - b += 1 +type DeviceCoreCtrl struct { + ControlId uint16 + Len uint16 + Status byte + // padding: 3 bytes +} - v.Id = buf[b] - b += 1 +// DeviceCoreCtrlRead reads a byte slice into a DeviceCoreCtrl value. +func DeviceCoreCtrlRead(buf []byte, v *DeviceCoreCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 v.Len = xgb.Get16(buf[b:]) b += 2 + v.Status = buf[b] + b += 1 + + b += 3 // padding + return b } -// FeedbackCtlReadList reads a byte slice into a list of FeedbackCtl values. -func FeedbackCtlReadList(buf []byte, dest []FeedbackCtl) int { +// DeviceCoreCtrlReadList reads a byte slice into a list of DeviceCoreCtrl values. +func DeviceCoreCtrlReadList(buf []byte, dest []DeviceCoreCtrl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = FeedbackCtl{} - b += FeedbackCtlRead(buf[b:], &dest[i]) + dest[i] = DeviceCoreCtrl{} + b += DeviceCoreCtrlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a FeedbackCtl value to a byte slice. -func (v FeedbackCtl) Bytes() []byte { - buf := make([]byte, 4) +// Bytes writes a DeviceCoreCtrl value to a byte slice. +func (v DeviceCoreCtrl) Bytes() []byte { + buf := make([]byte, 8) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 + xgb.Put16(buf[b:], v.ControlId) + b += 2 xgb.Put16(buf[b:], v.Len) b += 2 + buf[b] = v.Status + b += 1 + + b += 3 // padding + return buf } -// FeedbackCtlListBytes writes a list of FeedbackCtl values to a byte slice. -func FeedbackCtlListBytes(buf []byte, list []FeedbackCtl) int { +// DeviceCoreCtrlListBytes writes a list of DeviceCoreCtrl values to a byte slice. +func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { b := 0 var structBytes []byte for _, item := range list { @@ -1325,113 +1268,69 @@ func FeedbackCtlListBytes(buf []byte, list []FeedbackCtl) int { return b } -type KbdFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - Key KeyCode - AutoRepeatMode byte - KeyClickPercent int8 - BellPercent int8 - BellPitch int16 - BellDuration int16 - LedMask uint32 - LedValues uint32 +type DeviceCoreState struct { + ControlId uint16 + Len uint16 + Status byte + Iscore byte + // padding: 2 bytes } -// KbdFeedbackCtlRead reads a byte slice into a KbdFeedbackCtl value. -func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { +// DeviceCoreStateRead reads a byte slice into a DeviceCoreState value. +func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) int { b := 0 - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 + v.ControlId = xgb.Get16(buf[b:]) + b += 2 v.Len = xgb.Get16(buf[b:]) b += 2 - v.Key = KeyCode(buf[b]) - b += 1 - - v.AutoRepeatMode = buf[b] - b += 1 - - v.KeyClickPercent = int8(buf[b]) + v.Status = buf[b] b += 1 - v.BellPercent = int8(buf[b]) + v.Iscore = buf[b] b += 1 - v.BellPitch = int16(xgb.Get16(buf[b:])) - b += 2 - - v.BellDuration = int16(xgb.Get16(buf[b:])) - b += 2 - - v.LedMask = xgb.Get32(buf[b:]) - b += 4 - - v.LedValues = xgb.Get32(buf[b:]) - b += 4 + b += 2 // padding return b } -// KbdFeedbackCtlReadList reads a byte slice into a list of KbdFeedbackCtl values. -func KbdFeedbackCtlReadList(buf []byte, dest []KbdFeedbackCtl) int { +// DeviceCoreStateReadList reads a byte slice into a list of DeviceCoreState values. +func DeviceCoreStateReadList(buf []byte, dest []DeviceCoreState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = KbdFeedbackCtl{} - b += KbdFeedbackCtlRead(buf[b:], &dest[i]) + dest[i] = DeviceCoreState{} + b += DeviceCoreStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a KbdFeedbackCtl value to a byte slice. -func (v KbdFeedbackCtl) Bytes() []byte { - buf := make([]byte, 20) +// Bytes writes a DeviceCoreState value to a byte slice. +func (v DeviceCoreState) Bytes() []byte { + buf := make([]byte, 8) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 + xgb.Put16(buf[b:], v.ControlId) + b += 2 xgb.Put16(buf[b:], v.Len) b += 2 - buf[b] = byte(v.Key) - b += 1 - - buf[b] = v.AutoRepeatMode - b += 1 - - buf[b] = byte(v.KeyClickPercent) + buf[b] = v.Status b += 1 - buf[b] = byte(v.BellPercent) + buf[b] = v.Iscore b += 1 - xgb.Put16(buf[b:], uint16(v.BellPitch)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.BellDuration)) - b += 2 - - xgb.Put32(buf[b:], v.LedMask) - b += 4 - - xgb.Put32(buf[b:], v.LedValues) - b += 4 + b += 2 // padding return buf } -// KbdFeedbackCtlListBytes writes a list of KbdFeedbackCtl values to a byte slice. -func KbdFeedbackCtlListBytes(buf []byte, list []KbdFeedbackCtl) int { +// DeviceCoreStateListBytes writes a list of DeviceCoreState values to a byte slice. +func DeviceCoreStateListBytes(buf []byte, list []DeviceCoreState) int { b := 0 var structBytes []byte for _, item := range list { @@ -1442,83 +1341,50 @@ func KbdFeedbackCtlListBytes(buf []byte, list []KbdFeedbackCtl) int { return b } -type PtrFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - Num int16 - Denom int16 - Threshold int16 +type DeviceCtl struct { + ControlId uint16 + Len uint16 } -// PtrFeedbackCtlRead reads a byte slice into a PtrFeedbackCtl value. -func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { +// DeviceCtlRead reads a byte slice into a DeviceCtl value. +func DeviceCtlRead(buf []byte, v *DeviceCtl) int { b := 0 - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Num = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Denom = int16(xgb.Get16(buf[b:])) + v.ControlId = xgb.Get16(buf[b:]) b += 2 - v.Threshold = int16(xgb.Get16(buf[b:])) + v.Len = xgb.Get16(buf[b:]) b += 2 return b } -// PtrFeedbackCtlReadList reads a byte slice into a list of PtrFeedbackCtl values. -func PtrFeedbackCtlReadList(buf []byte, dest []PtrFeedbackCtl) int { +// DeviceCtlReadList reads a byte slice into a list of DeviceCtl values. +func DeviceCtlReadList(buf []byte, dest []DeviceCtl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = PtrFeedbackCtl{} - b += PtrFeedbackCtlRead(buf[b:], &dest[i]) + dest[i] = DeviceCtl{} + b += DeviceCtlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a PtrFeedbackCtl value to a byte slice. -func (v PtrFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a DeviceCtl value to a byte slice. +func (v DeviceCtl) Bytes() []byte { + buf := make([]byte, 4) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - xgb.Put16(buf[b:], uint16(v.Num)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Denom)) + xgb.Put16(buf[b:], v.ControlId) b += 2 - xgb.Put16(buf[b:], uint16(v.Threshold)) + xgb.Put16(buf[b:], v.Len) b += 2 return buf } -// PtrFeedbackCtlListBytes writes a list of PtrFeedbackCtl values to a byte slice. -func PtrFeedbackCtlListBytes(buf []byte, list []PtrFeedbackCtl) int { +// DeviceCtlListBytes writes a list of DeviceCtl values to a byte slice. +func DeviceCtlListBytes(buf []byte, list []DeviceCtl) int { b := 0 var structBytes []byte for _, item := range list { @@ -1529,64 +1395,62 @@ func PtrFeedbackCtlListBytes(buf []byte, list []PtrFeedbackCtl) int { return b } -type IntegerFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - IntToDisplay int32 +type DeviceEnableCtrl struct { + ControlId uint16 + Len uint16 + Enable byte + // padding: 3 bytes } -// IntegerFeedbackCtlRead reads a byte slice into a IntegerFeedbackCtl value. -func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { +// DeviceEnableCtrlRead reads a byte slice into a DeviceEnableCtrl value. +func DeviceEnableCtrlRead(buf []byte, v *DeviceEnableCtrl) int { b := 0 - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 + v.ControlId = xgb.Get16(buf[b:]) + b += 2 v.Len = xgb.Get16(buf[b:]) b += 2 - v.IntToDisplay = int32(xgb.Get32(buf[b:])) - b += 4 + v.Enable = buf[b] + b += 1 + + b += 3 // padding return b } -// IntegerFeedbackCtlReadList reads a byte slice into a list of IntegerFeedbackCtl values. -func IntegerFeedbackCtlReadList(buf []byte, dest []IntegerFeedbackCtl) int { +// DeviceEnableCtrlReadList reads a byte slice into a list of DeviceEnableCtrl values. +func DeviceEnableCtrlReadList(buf []byte, dest []DeviceEnableCtrl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = IntegerFeedbackCtl{} - b += IntegerFeedbackCtlRead(buf[b:], &dest[i]) + dest[i] = DeviceEnableCtrl{} + b += DeviceEnableCtrlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a IntegerFeedbackCtl value to a byte slice. -func (v IntegerFeedbackCtl) Bytes() []byte { +// Bytes writes a DeviceEnableCtrl value to a byte slice. +func (v DeviceEnableCtrl) Bytes() []byte { buf := make([]byte, 8) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 + xgb.Put16(buf[b:], v.ControlId) + b += 2 xgb.Put16(buf[b:], v.Len) b += 2 - xgb.Put32(buf[b:], uint32(v.IntToDisplay)) - b += 4 + buf[b] = v.Enable + b += 1 + + b += 3 // padding return buf } -// IntegerFeedbackCtlListBytes writes a list of IntegerFeedbackCtl values to a byte slice. -func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { +// DeviceEnableCtrlListBytes writes a list of DeviceEnableCtrl values to a byte slice. +func DeviceEnableCtrlListBytes(buf []byte, list []DeviceEnableCtrl) int { b := 0 var structBytes []byte for _, item := range list { @@ -1597,83 +1461,62 @@ func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { return b } -type StringFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - NumKeysyms uint16 - Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +type DeviceEnableState struct { + ControlId uint16 + Len uint16 + Enable byte + // padding: 3 bytes } -// StringFeedbackCtlRead reads a byte slice into a StringFeedbackCtl value. -func StringFeedbackCtlRead(buf []byte, v *StringFeedbackCtl) int { +// DeviceEnableStateRead reads a byte slice into a DeviceEnableState value. +func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { b := 0 - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 + v.ControlId = xgb.Get16(buf[b:]) + b += 2 v.Len = xgb.Get16(buf[b:]) b += 2 - b += 2 // padding - - v.NumKeysyms = xgb.Get16(buf[b:]) - b += 2 + v.Enable = buf[b] + b += 1 - v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) - for i := 0; i < int(v.NumKeysyms); i++ { - v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + b += 3 // padding return b } -// StringFeedbackCtlReadList reads a byte slice into a list of StringFeedbackCtl values. -func StringFeedbackCtlReadList(buf []byte, dest []StringFeedbackCtl) int { +// DeviceEnableStateReadList reads a byte slice into a list of DeviceEnableState values. +func DeviceEnableStateReadList(buf []byte, dest []DeviceEnableState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = StringFeedbackCtl{} - b += StringFeedbackCtlRead(buf[b:], &dest[i]) + dest[i] = DeviceEnableState{} + b += DeviceEnableStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a StringFeedbackCtl value to a byte slice. -func (v StringFeedbackCtl) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) +// Bytes writes a DeviceEnableState value to a byte slice. +func (v DeviceEnableState) Bytes() []byte { + buf := make([]byte, 8) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 + xgb.Put16(buf[b:], v.ControlId) + b += 2 xgb.Put16(buf[b:], v.Len) b += 2 - b += 2 // padding - - xgb.Put16(buf[b:], v.NumKeysyms) - b += 2 + buf[b] = v.Enable + b += 1 - for i := 0; i < int(v.NumKeysyms); i++ { - xgb.Put32(buf[b:], uint32(v.Keysyms[i])) - b += 4 - } - b = xgb.Pad(b) + b += 3 // padding return buf } -// StringFeedbackCtlListBytes writes a list of StringFeedbackCtl values to a byte slice. -func StringFeedbackCtlListBytes(buf []byte, list []StringFeedbackCtl) int { +// DeviceEnableStateListBytes writes a list of DeviceEnableState values to a byte slice. +func DeviceEnableStateListBytes(buf []byte, list []DeviceEnableState) int { b := 0 var structBytes []byte for _, item := range list { @@ -1684,92 +1527,69 @@ func StringFeedbackCtlListBytes(buf []byte, list []StringFeedbackCtl) int { return b } -// StringFeedbackCtlListSize computes the size (bytes) of a list of StringFeedbackCtl values. -func StringFeedbackCtlListSize(list []StringFeedbackCtl) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) - } - return size -} - -type BellFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - Percent int8 - // padding: 3 bytes - Pitch int16 - Duration int16 +type DeviceInfo struct { + DeviceType xproto.Atom + DeviceId byte + NumClassInfo byte + DeviceUse byte + // padding: 1 bytes } -// BellFeedbackCtlRead reads a byte slice into a BellFeedbackCtl value. -func BellFeedbackCtlRead(buf []byte, v *BellFeedbackCtl) int { +// DeviceInfoRead reads a byte slice into a DeviceInfo value. +func DeviceInfoRead(buf []byte, v *DeviceInfo) int { b := 0 - v.ClassId = buf[b] - b += 1 + v.DeviceType = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 - v.Id = buf[b] + v.DeviceId = buf[b] b += 1 - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.Percent = int8(buf[b]) + v.NumClassInfo = buf[b] b += 1 - b += 3 // padding - - v.Pitch = int16(xgb.Get16(buf[b:])) - b += 2 + v.DeviceUse = buf[b] + b += 1 - v.Duration = int16(xgb.Get16(buf[b:])) - b += 2 + b += 1 // padding return b } -// BellFeedbackCtlReadList reads a byte slice into a list of BellFeedbackCtl values. -func BellFeedbackCtlReadList(buf []byte, dest []BellFeedbackCtl) int { +// DeviceInfoReadList reads a byte slice into a list of DeviceInfo values. +func DeviceInfoReadList(buf []byte, dest []DeviceInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = BellFeedbackCtl{} - b += BellFeedbackCtlRead(buf[b:], &dest[i]) + dest[i] = DeviceInfo{} + b += DeviceInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a BellFeedbackCtl value to a byte slice. -func (v BellFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a DeviceInfo value to a byte slice. +func (v DeviceInfo) Bytes() []byte { + buf := make([]byte, 8) b := 0 - buf[b] = v.ClassId - b += 1 + xgb.Put32(buf[b:], uint32(v.DeviceType)) + b += 4 - buf[b] = v.Id + buf[b] = v.DeviceId b += 1 - xgb.Put16(buf[b:], v.Len) - b += 2 - - buf[b] = byte(v.Percent) + buf[b] = v.NumClassInfo b += 1 - b += 3 // padding - - xgb.Put16(buf[b:], uint16(v.Pitch)) - b += 2 + buf[b] = v.DeviceUse + b += 1 - xgb.Put16(buf[b:], uint16(v.Duration)) - b += 2 + b += 1 // padding return buf } -// BellFeedbackCtlListBytes writes a list of BellFeedbackCtl values to a byte slice. -func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { +// DeviceInfoListBytes writes a list of DeviceInfo values to a byte slice. +func DeviceInfoListBytes(buf []byte, list []DeviceInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -1780,406 +1600,525 @@ func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { return b } -type LedFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 -} +const ( + DeviceInputModeAsyncThisDevice = 0 + DeviceInputModeSyncThisDevice = 1 + DeviceInputModeReplayThisDevice = 2 + DeviceInputModeAsyncOtherDevices = 3 + DeviceInputModeAsyncAll = 4 + DeviceInputModeSyncAll = 5 +) -// LedFeedbackCtlRead reads a byte slice into a LedFeedbackCtl value. -func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { - b := 0 +// DeviceKeyPress is the event number for a DeviceKeyPressEvent. +const DeviceKeyPress = 1 - v.ClassId = buf[b] - b += 1 +type DeviceKeyPressEvent struct { + Sequence uint16 + Detail byte + Time xproto.Timestamp + Root xproto.Window + Event xproto.Window + Child xproto.Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + DeviceId byte +} - v.Id = buf[b] +// DeviceKeyPressEventNew constructs a DeviceKeyPressEvent value that implements xgb.Event from a byte slice. +func DeviceKeyPressEventNew(buf []byte) xgb.Event { + v := DeviceKeyPressEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] b += 1 - v.Len = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.LedMask = xgb.Get32(buf[b:]) + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.LedValues = xgb.Get32(buf[b:]) + v.Root = xproto.Window(xgb.Get32(buf[b:])) b += 4 - return b -} + v.Event = xproto.Window(xgb.Get32(buf[b:])) + b += 4 -// LedFeedbackCtlReadList reads a byte slice into a list of LedFeedbackCtl values. -func LedFeedbackCtlReadList(buf []byte, dest []LedFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = LedFeedbackCtl{} - b += LedFeedbackCtlRead(buf[b:], &dest[i]) + v.Child = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false } - return xgb.Pad(b) + b += 1 + + v.DeviceId = buf[b] + b += 1 + + return v } -// Bytes writes a LedFeedbackCtl value to a byte slice. -func (v LedFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a DeviceKeyPressEvent value to a byte slice. +func (v DeviceKeyPressEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ClassId + // write event number + buf[b] = 1 b += 1 - buf[b] = v.Id + buf[b] = v.Detail b += 1 - xgb.Put16(buf[b:], v.Len) - b += 2 + b += 2 // skip sequence number - xgb.Put32(buf[b:], v.LedMask) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], v.LedValues) + xgb.Put32(buf[b:], uint32(v.Root)) b += 4 - return buf -} + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 -// LedFeedbackCtlListBytes writes a list of LedFeedbackCtl values to a byte slice. -func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 -type InputState struct { - ClassId byte - Len byte - NumItems byte -} + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 -// InputStateRead reads a byte slice into a InputState value. -func InputStateRead(buf []byte, v *InputState) int { - b := 0 + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 - v.ClassId = buf[b] - b += 1 + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 - v.Len = buf[b] + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - v.NumItems = buf[b] + buf[b] = v.DeviceId b += 1 - return b + return buf } -// InputStateReadList reads a byte slice into a list of InputState values. -func InputStateReadList(buf []byte, dest []InputState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = InputState{} - b += InputStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the DeviceKeyPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceKeyPressEvent) SequenceId() uint16 { + return v.Sequence } -// Bytes writes a InputState value to a byte slice. -func (v InputState) Bytes() []byte { - buf := make([]byte, 3) - b := 0 +// String is a rudimentary string representation of DeviceKeyPressEvent. +func (v DeviceKeyPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - buf[b] = v.ClassId - b += 1 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][1] = DeviceKeyPressEventNew +} - buf[b] = v.Len - b += 1 +// DeviceKeyRelease is the event number for a DeviceKeyReleaseEvent. +const DeviceKeyRelease = 2 - buf[b] = v.NumItems - b += 1 +type DeviceKeyReleaseEvent DeviceKeyPressEvent - return buf +// DeviceKeyReleaseEventNew constructs a DeviceKeyReleaseEvent value that implements xgb.Event from a byte slice. +func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { + return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } -// InputStateListBytes writes a list of InputState values to a byte slice. -func InputStateListBytes(buf []byte, list []InputState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// Bytes writes a DeviceKeyReleaseEvent value to a byte slice. +func (v DeviceKeyReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() } -type KeyState struct { - ClassId byte - Len byte - NumKeys byte - // padding: 1 bytes - Keys []byte // size: 32 +// SequenceId returns the sequence id attached to the DeviceKeyRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceKeyReleaseEvent) SequenceId() uint16 { + return v.Sequence } -// KeyStateRead reads a byte slice into a KeyState value. -func KeyStateRead(buf []byte, v *KeyState) int { - b := 0 +func (v DeviceKeyReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - v.ClassId = buf[b] - b += 1 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew +} - v.Len = buf[b] - b += 1 +// DeviceKeyStateNotify is the event number for a DeviceKeyStateNotifyEvent. +const DeviceKeyStateNotify = 13 - v.NumKeys = buf[b] - b += 1 +type DeviceKeyStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Keys []byte // size: 28 +} - b += 1 // padding +// DeviceKeyStateNotifyEventNew constructs a DeviceKeyStateNotifyEvent value that implements xgb.Event from a byte slice. +func DeviceKeyStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceKeyStateNotifyEvent{} + b := 1 // don't read event number - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += xgb.Pad(int(32)) + v.DeviceId = buf[b] + b += 1 - return b -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// KeyStateReadList reads a byte slice into a list of KeyState values. -func KeyStateReadList(buf []byte, dest []KeyState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = KeyState{} - b += KeyStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + v.Keys = make([]byte, 28) + copy(v.Keys[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v } -// Bytes writes a KeyState value to a byte slice. -func (v KeyState) Bytes() []byte { - buf := make([]byte, 36) +// Bytes writes a DeviceKeyStateNotifyEvent value to a byte slice. +func (v DeviceKeyStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len + // write event number + buf[b] = 13 b += 1 - buf[b] = v.NumKeys + buf[b] = v.DeviceId b += 1 - b += 1 // padding + b += 2 // skip sequence number - copy(buf[b:], v.Keys[:32]) - b += xgb.Pad(int(32)) + copy(buf[b:], v.Keys[:28]) + b += xgb.Pad(int(28)) return buf } -// KeyStateListBytes writes a list of KeyState values to a byte slice. -func KeyStateListBytes(buf []byte, list []KeyState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the DeviceKeyStateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceKeyStateNotifyEvent) SequenceId() uint16 { + return v.Sequence } -// KeyStateListSize computes the size (bytes) of a list of KeyState values. -func KeyStateListSize(list []KeyState) int { - size := 0 - for _ = range list { - size += 36 - } - return size +// String is a rudimentary string representation of DeviceKeyStateNotifyEvent. +func (v DeviceKeyStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type ButtonState struct { - ClassId byte - Len byte - NumButtons byte +func init() { + xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew +} + +// DeviceMappingNotify is the event number for a DeviceMappingNotifyEvent. +const DeviceMappingNotify = 11 + +type DeviceMappingNotifyEvent struct { + Sequence uint16 + DeviceId byte + Request byte + FirstKeycode KeyCode + Count byte // padding: 1 bytes - Buttons []byte // size: 32 + Time xproto.Timestamp + // padding: 20 bytes } -// ButtonStateRead reads a byte slice into a ButtonState value. -func ButtonStateRead(buf []byte, v *ButtonState) int { - b := 0 +// DeviceMappingNotifyEventNew constructs a DeviceMappingNotifyEvent value that implements xgb.Event from a byte slice. +func DeviceMappingNotifyEventNew(buf []byte) xgb.Event { + v := DeviceMappingNotifyEvent{} + b := 1 // don't read event number - v.ClassId = buf[b] + v.DeviceId = buf[b] b += 1 - v.Len = buf[b] + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Request = buf[b] b += 1 - v.NumButtons = buf[b] + v.FirstKeycode = KeyCode(buf[b]) + b += 1 + + v.Count = buf[b] b += 1 b += 1 // padding - v.Buttons = make([]byte, 32) - copy(v.Buttons[:32], buf[b:]) - b += xgb.Pad(int(32)) + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 - return b -} + b += 20 // padding -// ButtonStateReadList reads a byte slice into a list of ButtonState values. -func ButtonStateReadList(buf []byte, dest []ButtonState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ButtonState{} - b += ButtonStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return v } -// Bytes writes a ButtonState value to a byte slice. -func (v ButtonState) Bytes() []byte { - buf := make([]byte, 36) +// Bytes writes a DeviceMappingNotifyEvent value to a byte slice. +func (v DeviceMappingNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ClassId + // write event number + buf[b] = 11 b += 1 - buf[b] = v.Len + buf[b] = v.DeviceId b += 1 - buf[b] = v.NumButtons + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count b += 1 b += 1 // padding - copy(buf[b:], v.Buttons[:32]) - b += xgb.Pad(int(32)) + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + b += 20 // padding return buf } -// ButtonStateListBytes writes a list of ButtonState values to a byte slice. -func ButtonStateListBytes(buf []byte, list []ButtonState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the DeviceMappingNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceMappingNotifyEvent) SequenceId() uint16 { + return v.Sequence } -// ButtonStateListSize computes the size (bytes) of a list of ButtonState values. -func ButtonStateListSize(list []ButtonState) int { - size := 0 - for _ = range list { - size += 36 - } - return size +// String is a rudimentary string representation of DeviceMappingNotifyEvent. +func (v DeviceMappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + return "DeviceMappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type ValuatorState struct { - ClassId byte - Len byte - NumValuators byte - Mode byte - Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +func init() { + xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew } -// ValuatorStateRead reads a byte slice into a ValuatorState value. -func ValuatorStateRead(buf []byte, v *ValuatorState) int { - b := 0 +// DeviceMotionNotify is the event number for a DeviceMotionNotifyEvent. +const DeviceMotionNotify = 5 - v.ClassId = buf[b] - b += 1 +type DeviceMotionNotifyEvent DeviceKeyPressEvent - v.Len = buf[b] - b += 1 +// DeviceMotionNotifyEventNew constructs a DeviceMotionNotifyEvent value that implements xgb.Event from a byte slice. +func DeviceMotionNotifyEventNew(buf []byte) xgb.Event { + return DeviceMotionNotifyEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} - v.NumValuators = buf[b] +// Bytes writes a DeviceMotionNotifyEvent value to a byte slice. +func (v DeviceMotionNotifyEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +// SequenceId returns the sequence id attached to the DeviceMotionNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceMotionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceMotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceMotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][5] = DeviceMotionNotifyEventNew +} + +// DevicePresenceNotify is the event number for a DevicePresenceNotifyEvent. +const DevicePresenceNotify = 15 + +type DevicePresenceNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time xproto.Timestamp + Devchange byte + DeviceId byte + Control uint16 + // padding: 20 bytes +} + +// DevicePresenceNotifyEventNew constructs a DevicePresenceNotifyEvent value that implements xgb.Event from a byte slice. +func DevicePresenceNotifyEventNew(buf []byte) xgb.Event { + v := DevicePresenceNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Devchange = buf[b] b += 1 - v.Mode = buf[b] + v.DeviceId = buf[b] b += 1 - v.Valuators = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.Valuators[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Control = xgb.Get16(buf[b:]) + b += 2 - return b -} + b += 20 // padding -// ValuatorStateReadList reads a byte slice into a list of ValuatorState values. -func ValuatorStateReadList(buf []byte, dest []ValuatorState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ValuatorState{} - b += ValuatorStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return v } -// Bytes writes a ValuatorState value to a byte slice. -func (v ValuatorState) Bytes() []byte { - buf := make([]byte, (4 + xgb.Pad((int(v.NumValuators) * 4)))) +// Bytes writes a DevicePresenceNotifyEvent value to a byte slice. +func (v DevicePresenceNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ClassId + // write event number + buf[b] = 15 b += 1 - buf[b] = v.Len - b += 1 + b += 1 // padding - buf[b] = v.NumValuators + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.Devchange b += 1 - buf[b] = v.Mode + buf[b] = v.DeviceId b += 1 - for i := 0; i < int(v.NumValuators); i++ { - xgb.Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.Control) + b += 2 + + b += 20 // padding return buf } -// ValuatorStateListBytes writes a list of ValuatorState values to a byte slice. -func ValuatorStateListBytes(buf []byte, list []ValuatorState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the DevicePresenceNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DevicePresenceNotifyEvent) SequenceId() uint16 { + return v.Sequence } -// ValuatorStateListSize computes the size (bytes) of a list of ValuatorState values. -func ValuatorStateListSize(list []ValuatorState) int { - size := 0 - for _, item := range list { - size += (4 + xgb.Pad((int(item.NumValuators) * 4))) - } - return size +// String is a rudimentary string representation of DevicePresenceNotifyEvent. +func (v DevicePresenceNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Devchange: %d", v.Devchange)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Control: %d", v.Control)) + return "DevicePresenceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type DeviceState struct { - ControlId uint16 - Len uint16 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][15] = DevicePresenceNotifyEventNew } -// DeviceStateRead reads a byte slice into a DeviceState value. -func DeviceStateRead(buf []byte, v *DeviceState) int { +type DeviceResolutionCtl struct { + ControlId uint16 + Len uint16 + FirstValuator byte + NumValuators byte + ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// DeviceResolutionCtlRead reads a byte slice into a DeviceResolutionCtl value. +func DeviceResolutionCtlRead(buf []byte, v *DeviceResolutionCtl) int { b := 0 v.ControlId = xgb.Get16(buf[b:]) @@ -2188,22 +2127,35 @@ func DeviceStateRead(buf []byte, v *DeviceState) int { v.Len = xgb.Get16(buf[b:]) b += 2 + v.FirstValuator = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.ResolutionValues = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionValues[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + return b } -// DeviceStateReadList reads a byte slice into a list of DeviceState values. -func DeviceStateReadList(buf []byte, dest []DeviceState) int { +// DeviceResolutionCtlReadList reads a byte slice into a list of DeviceResolutionCtl values. +func DeviceResolutionCtlReadList(buf []byte, dest []DeviceResolutionCtl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceState{} - b += DeviceStateRead(buf[b:], &dest[i]) + dest[i] = DeviceResolutionCtl{} + b += DeviceResolutionCtlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceState value to a byte slice. -func (v DeviceState) Bytes() []byte { - buf := make([]byte, 4) +// Bytes writes a DeviceResolutionCtl value to a byte slice. +func (v DeviceResolutionCtl) Bytes() []byte { + buf := make([]byte, (6 + xgb.Pad((int(v.NumValuators) * 4)))) b := 0 xgb.Put16(buf[b:], v.ControlId) @@ -2212,11 +2164,23 @@ func (v DeviceState) Bytes() []byte { xgb.Put16(buf[b:], v.Len) b += 2 + buf[b] = v.FirstValuator + b += 1 + + buf[b] = v.NumValuators + b += 1 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionValues[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// DeviceStateListBytes writes a list of DeviceState values to a byte slice. -func DeviceStateListBytes(buf []byte, list []DeviceState) int { +// DeviceResolutionCtlListBytes writes a list of DeviceResolutionCtl values to a byte slice. +func DeviceResolutionCtlListBytes(buf []byte, list []DeviceResolutionCtl) int { b := 0 var structBytes []byte for _, item := range list { @@ -2227,6 +2191,15 @@ func DeviceStateListBytes(buf []byte, list []DeviceState) int { return b } +// DeviceResolutionCtlListSize computes the size (bytes) of a list of DeviceResolutionCtl values. +func DeviceResolutionCtlListSize(list []DeviceResolutionCtl) int { + size := 0 + for _, item := range list { + size += (6 + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + type DeviceResolutionState struct { ControlId uint16 Len uint16 @@ -2339,21 +2312,13 @@ func DeviceResolutionStateListSize(list []DeviceResolutionState) int { return size } -type DeviceAbsCalibState struct { - ControlId uint16 - Len uint16 - MinX int32 - MaxX int32 - MinY int32 - MaxY int32 - FlipX uint32 - FlipY uint32 - Rotation uint32 - ButtonThreshold uint32 +type DeviceState struct { + ControlId uint16 + Len uint16 } -// DeviceAbsCalibStateRead reads a byte slice into a DeviceAbsCalibState value. -func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { +// DeviceStateRead reads a byte slice into a DeviceState value. +func DeviceStateRead(buf []byte, v *DeviceState) int { b := 0 v.ControlId = xgb.Get16(buf[b:]) @@ -2362,46 +2327,22 @@ func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { v.Len = xgb.Get16(buf[b:]) b += 2 - v.MinX = int32(xgb.Get32(buf[b:])) - b += 4 - - v.MaxX = int32(xgb.Get32(buf[b:])) - b += 4 - - v.MinY = int32(xgb.Get32(buf[b:])) - b += 4 - - v.MaxY = int32(xgb.Get32(buf[b:])) - b += 4 - - v.FlipX = xgb.Get32(buf[b:]) - b += 4 - - v.FlipY = xgb.Get32(buf[b:]) - b += 4 - - v.Rotation = xgb.Get32(buf[b:]) - b += 4 - - v.ButtonThreshold = xgb.Get32(buf[b:]) - b += 4 - return b } -// DeviceAbsCalibStateReadList reads a byte slice into a list of DeviceAbsCalibState values. -func DeviceAbsCalibStateReadList(buf []byte, dest []DeviceAbsCalibState) int { +// DeviceStateReadList reads a byte slice into a list of DeviceState values. +func DeviceStateReadList(buf []byte, dest []DeviceState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceAbsCalibState{} - b += DeviceAbsCalibStateRead(buf[b:], &dest[i]) + dest[i] = DeviceState{} + b += DeviceStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceAbsCalibState value to a byte slice. -func (v DeviceAbsCalibState) Bytes() []byte { - buf := make([]byte, 36) +// Bytes writes a DeviceState value to a byte slice. +func (v DeviceState) Bytes() []byte { + buf := make([]byte, 4) b := 0 xgb.Put16(buf[b:], v.ControlId) @@ -2410,35 +2351,11 @@ func (v DeviceAbsCalibState) Bytes() []byte { xgb.Put16(buf[b:], v.Len) b += 2 - xgb.Put32(buf[b:], uint32(v.MinX)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.MaxX)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.MinY)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.MaxY)) - b += 4 - - xgb.Put32(buf[b:], v.FlipX) - b += 4 - - xgb.Put32(buf[b:], v.FlipY) - b += 4 - - xgb.Put32(buf[b:], v.Rotation) - b += 4 - - xgb.Put32(buf[b:], v.ButtonThreshold) - b += 4 - return buf } -// DeviceAbsCalibStateListBytes writes a list of DeviceAbsCalibState values to a byte slice. -func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) int { +// DeviceStateListBytes writes a list of DeviceState values to a byte slice. +func DeviceStateListBytes(buf []byte, list []DeviceState) int { b := 0 var structBytes []byte for _, item := range list { @@ -2449,165 +2366,171 @@ func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) int { return b } -type DeviceAbsAreaState struct { - ControlId uint16 - Len uint16 - OffsetX uint32 - OffsetY uint32 - Width uint32 - Height uint32 - Screen uint32 - Following uint32 +// DeviceStateNotify is the event number for a DeviceStateNotifyEvent. +const DeviceStateNotify = 10 + +type DeviceStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Time xproto.Timestamp + NumKeys byte + NumButtons byte + NumValuators byte + ClassesReported byte + Buttons []byte // size: 4 + Keys []byte // size: 4 + Valuators []uint32 // size: 12 } -// DeviceAbsAreaStateRead reads a byte slice into a DeviceAbsAreaState value. -func DeviceAbsAreaStateRead(buf []byte, v *DeviceAbsAreaState) int { - b := 0 +// DeviceStateNotifyEventNew constructs a DeviceStateNotifyEvent value that implements xgb.Event from a byte slice. +func DeviceStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceStateNotifyEvent{} + b := 1 // don't read event number - v.ControlId = xgb.Get16(buf[b:]) - b += 2 + v.DeviceId = buf[b] + b += 1 - v.Len = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.OffsetX = xgb.Get32(buf[b:]) + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.OffsetY = xgb.Get32(buf[b:]) - b += 4 + v.NumKeys = buf[b] + b += 1 - v.Width = xgb.Get32(buf[b:]) - b += 4 + v.NumButtons = buf[b] + b += 1 - v.Height = xgb.Get32(buf[b:]) - b += 4 + v.NumValuators = buf[b] + b += 1 - v.Screen = xgb.Get32(buf[b:]) - b += 4 + v.ClassesReported = buf[b] + b += 1 - v.Following = xgb.Get32(buf[b:]) - b += 4 + v.Buttons = make([]byte, 4) + copy(v.Buttons[:4], buf[b:]) + b += xgb.Pad(int(4)) - return b -} + v.Keys = make([]byte, 4) + copy(v.Keys[:4], buf[b:]) + b += xgb.Pad(int(4)) -// DeviceAbsAreaStateReadList reads a byte slice into a list of DeviceAbsAreaState values. -func DeviceAbsAreaStateReadList(buf []byte, dest []DeviceAbsAreaState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DeviceAbsAreaState{} - b += DeviceAbsAreaStateRead(buf[b:], &dest[i]) + v.Valuators = make([]uint32, 3) + for i := 0; i < int(3); i++ { + v.Valuators[i] = xgb.Get32(buf[b:]) + b += 4 } - return xgb.Pad(b) + b = xgb.Pad(b) + + return v } -// Bytes writes a DeviceAbsAreaState value to a byte slice. -func (v DeviceAbsAreaState) Bytes() []byte { - buf := make([]byte, 28) +// Bytes writes a DeviceStateNotifyEvent value to a byte slice. +func (v DeviceStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 + // write event number + buf[b] = 10 + b += 1 - xgb.Put16(buf[b:], v.Len) - b += 2 + buf[b] = v.DeviceId + b += 1 - xgb.Put32(buf[b:], v.OffsetX) - b += 4 + b += 2 // skip sequence number - xgb.Put32(buf[b:], v.OffsetY) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], v.Width) - b += 4 + buf[b] = v.NumKeys + b += 1 - xgb.Put32(buf[b:], v.Height) - b += 4 + buf[b] = v.NumButtons + b += 1 - xgb.Put32(buf[b:], v.Screen) - b += 4 + buf[b] = v.NumValuators + b += 1 - xgb.Put32(buf[b:], v.Following) - b += 4 + buf[b] = v.ClassesReported + b += 1 - return buf -} + copy(buf[b:], v.Buttons[:4]) + b += xgb.Pad(int(4)) -// DeviceAbsAreaStateListBytes writes a list of DeviceAbsAreaState values to a byte slice. -func DeviceAbsAreaStateListBytes(buf []byte, list []DeviceAbsAreaState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + copy(buf[b:], v.Keys[:4]) + b += xgb.Pad(int(4)) + + for i := 0; i < int(3); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 } - return b -} + b = xgb.Pad(b) -type DeviceCoreState struct { - ControlId uint16 - Len uint16 - Status byte - Iscore byte - // padding: 2 bytes + return buf } -// DeviceCoreStateRead reads a byte slice into a DeviceCoreState value. -func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) int { - b := 0 +// SequenceId returns the sequence id attached to the DeviceStateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceStateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} - v.ControlId = xgb.Get16(buf[b:]) - b += 2 +// String is a rudimentary string representation of DeviceStateNotifyEvent. +func (v DeviceStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 9) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("NumKeys: %d", v.NumKeys)) + fieldVals = append(fieldVals, xgb.Sprintf("NumButtons: %d", v.NumButtons)) + fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) + fieldVals = append(fieldVals, xgb.Sprintf("ClassesReported: %d", v.ClassesReported)) + return "DeviceStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - v.Len = xgb.Get16(buf[b:]) - b += 2 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][10] = DeviceStateNotifyEventNew +} - v.Status = buf[b] - b += 1 +type DeviceTimeCoord struct { + Time xproto.Timestamp +} - v.Iscore = buf[b] - b += 1 +// DeviceTimeCoordRead reads a byte slice into a DeviceTimeCoord value. +func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { + b := 0 - b += 2 // padding + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 return b } -// DeviceCoreStateReadList reads a byte slice into a list of DeviceCoreState values. -func DeviceCoreStateReadList(buf []byte, dest []DeviceCoreState) int { +// DeviceTimeCoordReadList reads a byte slice into a list of DeviceTimeCoord values. +func DeviceTimeCoordReadList(buf []byte, dest []DeviceTimeCoord) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceCoreState{} - b += DeviceCoreStateRead(buf[b:], &dest[i]) + dest[i] = DeviceTimeCoord{} + b += DeviceTimeCoordRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceCoreState value to a byte slice. -func (v DeviceCoreState) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a DeviceTimeCoord value to a byte slice. +func (v DeviceTimeCoord) Bytes() []byte { + buf := make([]byte, 4) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Status - b += 1 - - buf[b] = v.Iscore - b += 1 - - b += 2 // padding + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 return buf } -// DeviceCoreStateListBytes writes a list of DeviceCoreState values to a byte slice. -func DeviceCoreStateListBytes(buf []byte, list []DeviceCoreState) int { +// DeviceTimeCoordListBytes writes a list of DeviceTimeCoord values to a byte slice. +func DeviceTimeCoordListBytes(buf []byte, list []DeviceTimeCoord) int { b := 0 var structBytes []byte for _, item := range list { @@ -2618,107 +2541,209 @@ func DeviceCoreStateListBytes(buf []byte, list []DeviceCoreState) int { return b } -type DeviceEnableState struct { - ControlId uint16 - Len uint16 - Enable byte - // padding: 3 bytes +const ( + DeviceUseIsXPointer = 0 + DeviceUseIsXKeyboard = 1 + DeviceUseIsXExtensionDevice = 2 + DeviceUseIsXExtensionKeyboard = 3 + DeviceUseIsXExtensionPointer = 4 +) + +// DeviceValuator is the event number for a DeviceValuatorEvent. +const DeviceValuator = 0 + +type DeviceValuatorEvent struct { + Sequence uint16 + DeviceId byte + DeviceState uint16 + NumValuators byte + FirstValuator byte + Valuators []int32 // size: 24 } -// DeviceEnableStateRead reads a byte slice into a DeviceEnableState value. -func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { - b := 0 +// DeviceValuatorEventNew constructs a DeviceValuatorEvent value that implements xgb.Event from a byte slice. +func DeviceValuatorEventNew(buf []byte) xgb.Event { + v := DeviceValuatorEvent{} + b := 1 // don't read event number - v.ControlId = xgb.Get16(buf[b:]) + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Len = xgb.Get16(buf[b:]) + v.DeviceState = xgb.Get16(buf[b:]) b += 2 - v.Enable = buf[b] + v.NumValuators = buf[b] b += 1 - b += 3 // padding - - return b -} + v.FirstValuator = buf[b] + b += 1 -// DeviceEnableStateReadList reads a byte slice into a list of DeviceEnableState values. -func DeviceEnableStateReadList(buf []byte, dest []DeviceEnableState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DeviceEnableState{} - b += DeviceEnableStateRead(buf[b:], &dest[i]) + v.Valuators = make([]int32, 6) + for i := 0; i < int(6); i++ { + v.Valuators[i] = int32(xgb.Get32(buf[b:])) + b += 4 } - return xgb.Pad(b) + b = xgb.Pad(b) + + return v } -// Bytes writes a DeviceEnableState value to a byte slice. -func (v DeviceEnableState) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a DeviceValuatorEvent value to a byte slice. +func (v DeviceValuatorEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 + // write event number + buf[b] = 0 + b += 1 - xgb.Put16(buf[b:], v.Len) + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + xgb.Put16(buf[b:], v.DeviceState) b += 2 - buf[b] = v.Enable + buf[b] = v.NumValuators b += 1 - b += 3 // padding + buf[b] = v.FirstValuator + b += 1 + + for i := 0; i < int(6); i++ { + xgb.Put32(buf[b:], uint32(v.Valuators[i])) + b += 4 + } + b = xgb.Pad(b) return buf } -// DeviceEnableStateListBytes writes a list of DeviceEnableState values to a byte slice. -func DeviceEnableStateListBytes(buf []byte, list []DeviceEnableState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the DeviceValuator event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceValuatorEvent) SequenceId() uint16 { + return v.Sequence } -type DeviceCtl struct { - ControlId uint16 - Len uint16 +// String is a rudimentary string representation of DeviceValuatorEvent. +func (v DeviceValuatorEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceState: %d", v.DeviceState)) + fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstValuator: %d", v.FirstValuator)) + return "DeviceValuator {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// DeviceCtlRead reads a byte slice into a DeviceCtl value. -func DeviceCtlRead(buf []byte, v *DeviceCtl) int { - b := 0 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew +} - v.ControlId = xgb.Get16(buf[b:]) +// BadEvent is the error number for a BadEvent. +const BadEvent = 1 + +type EventError struct { + Sequence uint16 + NiceName string +} + +// EventErrorNew constructs a EventError value that implements xgb.Error from a byte slice. +func EventErrorNew(buf []byte) xgb.Error { + v := EventError{} + v.NiceName = "Event" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) b += 2 + return v +} + +// SequenceId returns the sequence id attached to the BadEvent error. +// This is mostly used internally. +func (err EventError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadEvent error. If no bad value exists, 0 is returned. +func (err EventError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadEvent error. + +func (err EventError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadEvent {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][1] = EventErrorNew +} + +type EventClass uint32 + +const ( + FeedbackClassKeyboard = 0 + FeedbackClassPointer = 1 + FeedbackClassString = 2 + FeedbackClassInteger = 3 + FeedbackClassLed = 4 + FeedbackClassBell = 5 +) + +type FeedbackCtl struct { + ClassId byte + Id byte + Len uint16 +} + +// FeedbackCtlRead reads a byte slice into a FeedbackCtl value. +func FeedbackCtlRead(buf []byte, v *FeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + v.Len = xgb.Get16(buf[b:]) b += 2 return b } -// DeviceCtlReadList reads a byte slice into a list of DeviceCtl values. -func DeviceCtlReadList(buf []byte, dest []DeviceCtl) int { +// FeedbackCtlReadList reads a byte slice into a list of FeedbackCtl values. +func FeedbackCtlReadList(buf []byte, dest []FeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceCtl{} - b += DeviceCtlRead(buf[b:], &dest[i]) + dest[i] = FeedbackCtl{} + b += FeedbackCtlRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceCtl value to a byte slice. -func (v DeviceCtl) Bytes() []byte { +// Bytes writes a FeedbackCtl value to a byte slice. +func (v FeedbackCtl) Bytes() []byte { buf := make([]byte, 4) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 xgb.Put16(buf[b:], v.Len) b += 2 @@ -2726,8 +2751,8 @@ func (v DeviceCtl) Bytes() []byte { return buf } -// DeviceCtlListBytes writes a list of DeviceCtl values to a byte slice. -func DeviceCtlListBytes(buf []byte, list []DeviceCtl) int { +// FeedbackCtlListBytes writes a list of FeedbackCtl values to a byte slice. +func FeedbackCtlListBytes(buf []byte, list []FeedbackCtl) int { b := 0 var structBytes []byte for _, item := range list { @@ -2738,78 +2763,57 @@ func DeviceCtlListBytes(buf []byte, list []DeviceCtl) int { return b } -type DeviceResolutionCtl struct { - ControlId uint16 - Len uint16 - FirstValuator byte - NumValuators byte - ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +type FeedbackState struct { + ClassId byte + Id byte + Len uint16 } -// DeviceResolutionCtlRead reads a byte slice into a DeviceResolutionCtl value. -func DeviceResolutionCtlRead(buf []byte, v *DeviceResolutionCtl) int { +// FeedbackStateRead reads a byte slice into a FeedbackState value. +func FeedbackStateRead(buf []byte, v *FeedbackState) int { b := 0 - v.ControlId = xgb.Get16(buf[b:]) - b += 2 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.FirstValuator = buf[b] + v.ClassId = buf[b] b += 1 - v.NumValuators = buf[b] + v.Id = buf[b] b += 1 - v.ResolutionValues = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionValues[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Len = xgb.Get16(buf[b:]) + b += 2 return b } -// DeviceResolutionCtlReadList reads a byte slice into a list of DeviceResolutionCtl values. -func DeviceResolutionCtlReadList(buf []byte, dest []DeviceResolutionCtl) int { +// FeedbackStateReadList reads a byte slice into a list of FeedbackState values. +func FeedbackStateReadList(buf []byte, dest []FeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceResolutionCtl{} - b += DeviceResolutionCtlRead(buf[b:], &dest[i]) + dest[i] = FeedbackState{} + b += FeedbackStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceResolutionCtl value to a byte slice. -func (v DeviceResolutionCtl) Bytes() []byte { - buf := make([]byte, (6 + xgb.Pad((int(v.NumValuators) * 4)))) +// Bytes writes a FeedbackState value to a byte slice. +func (v FeedbackState) Bytes() []byte { + buf := make([]byte, 4) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.FirstValuator + buf[b] = v.ClassId b += 1 - buf[b] = v.NumValuators + buf[b] = v.Id b += 1 - for i := 0; i < int(v.NumValuators); i++ { - xgb.Put32(buf[b:], v.ResolutionValues[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.Len) + b += 2 return buf } -// DeviceResolutionCtlListBytes writes a list of DeviceResolutionCtl values to a byte slice. -func DeviceResolutionCtlListBytes(buf []byte, list []DeviceResolutionCtl) int { +// FeedbackStateListBytes writes a list of FeedbackState values to a byte slice. +func FeedbackStateListBytes(buf []byte, list []FeedbackState) int { b := 0 var structBytes []byte for _, item := range list { @@ -2820,211 +2824,192 @@ func DeviceResolutionCtlListBytes(buf []byte, list []DeviceResolutionCtl) int { return b } -// DeviceResolutionCtlListSize computes the size (bytes) of a list of DeviceResolutionCtl values. -func DeviceResolutionCtlListSize(list []DeviceResolutionCtl) int { - size := 0 - for _, item := range list { - size += (6 + xgb.Pad((int(item.NumValuators) * 4))) - } - return size -} +// FocusIn is the event number for a FocusInEvent. +const FocusIn = 6 -type DeviceAbsCalibCtl struct { - ControlId uint16 - Len uint16 - MinX int32 - MaxX int32 - MinY int32 - MaxY int32 - FlipX uint32 - FlipY uint32 - Rotation uint32 - ButtonThreshold uint32 +type FocusInEvent struct { + Sequence uint16 + Detail byte + Time xproto.Timestamp + Window xproto.Window + Mode byte + DeviceId byte + // padding: 18 bytes } -// DeviceAbsCalibCtlRead reads a byte slice into a DeviceAbsCalibCtl value. -func DeviceAbsCalibCtlRead(buf []byte, v *DeviceAbsCalibCtl) int { - b := 0 +// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. +func FocusInEventNew(buf []byte) xgb.Event { + v := FocusInEvent{} + b := 1 // don't read event number - v.ControlId = xgb.Get16(buf[b:]) - b += 2 + v.Detail = buf[b] + b += 1 - v.Len = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.MinX = int32(xgb.Get32(buf[b:])) - b += 4 - - v.MaxX = int32(xgb.Get32(buf[b:])) - b += 4 - - v.MinY = int32(xgb.Get32(buf[b:])) - b += 4 - - v.MaxY = int32(xgb.Get32(buf[b:])) - b += 4 - - v.FlipX = xgb.Get32(buf[b:]) + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.FlipY = xgb.Get32(buf[b:]) + v.Window = xproto.Window(xgb.Get32(buf[b:])) b += 4 - v.Rotation = xgb.Get32(buf[b:]) - b += 4 + v.Mode = buf[b] + b += 1 - v.ButtonThreshold = xgb.Get32(buf[b:]) - b += 4 + v.DeviceId = buf[b] + b += 1 - return b -} + b += 18 // padding -// DeviceAbsCalibCtlReadList reads a byte slice into a list of DeviceAbsCalibCtl values. -func DeviceAbsCalibCtlReadList(buf []byte, dest []DeviceAbsCalibCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DeviceAbsCalibCtl{} - b += DeviceAbsCalibCtlRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return v } -// Bytes writes a DeviceAbsCalibCtl value to a byte slice. -func (v DeviceAbsCalibCtl) Bytes() []byte { - buf := make([]byte, 36) +// Bytes writes a FocusInEvent value to a byte slice. +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 + // write event number + buf[b] = 6 + b += 1 - xgb.Put16(buf[b:], v.Len) - b += 2 + buf[b] = v.Detail + b += 1 - xgb.Put32(buf[b:], uint32(v.MinX)) - b += 4 + b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.MaxX)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.MinY)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], uint32(v.MaxY)) - b += 4 + buf[b] = v.Mode + b += 1 - xgb.Put32(buf[b:], v.FlipX) - b += 4 + buf[b] = v.DeviceId + b += 1 - xgb.Put32(buf[b:], v.FlipY) - b += 4 + b += 18 // padding - xgb.Put32(buf[b:], v.Rotation) - b += 4 + return buf +} - xgb.Put32(buf[b:], v.ButtonThreshold) - b += 4 +// SequenceId returns the sequence id attached to the FocusIn event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v FocusInEvent) SequenceId() uint16 { + return v.Sequence +} - return buf +// String is a rudimentary string representation of FocusInEvent. +func (v FocusInEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// DeviceAbsCalibCtlListBytes writes a list of DeviceAbsCalibCtl values to a byte slice. -func DeviceAbsCalibCtlListBytes(buf []byte, list []DeviceAbsCalibCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +func init() { + xgb.NewExtEventFuncs["XInputExtension"][6] = FocusInEventNew } -type DeviceAbsAreaCtrl struct { - ControlId uint16 - Len uint16 - OffsetX uint32 - OffsetY uint32 - Width int32 - Height int32 - Screen int32 - Following uint32 +// FocusOut is the event number for a FocusOutEvent. +const FocusOut = 7 + +type FocusOutEvent FocusInEvent + +// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) } -// DeviceAbsAreaCtrlRead reads a byte slice into a DeviceAbsAreaCtrl value. -func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { - b := 0 +// Bytes writes a FocusOutEvent value to a byte slice. +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} - v.ControlId = xgb.Get16(buf[b:]) - b += 2 +// SequenceId returns the sequence id attached to the FocusOut event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v FocusOutEvent) SequenceId() uint16 { + return v.Sequence +} - v.Len = xgb.Get16(buf[b:]) - b += 2 +func (v FocusOutEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - v.OffsetX = xgb.Get32(buf[b:]) - b += 4 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew +} - v.OffsetY = xgb.Get32(buf[b:]) - b += 4 +const ( + InputClassKey = 0 + InputClassButton = 1 + InputClassValuator = 2 + InputClassFeedback = 3 + InputClassProximity = 4 + InputClassFocus = 5 + InputClassOther = 6 +) - v.Width = int32(xgb.Get32(buf[b:])) - b += 4 +type InputClassInfo struct { + ClassId byte + EventTypeBase byte +} - v.Height = int32(xgb.Get32(buf[b:])) - b += 4 +// InputClassInfoRead reads a byte slice into a InputClassInfo value. +func InputClassInfoRead(buf []byte, v *InputClassInfo) int { + b := 0 - v.Screen = int32(xgb.Get32(buf[b:])) - b += 4 + v.ClassId = buf[b] + b += 1 - v.Following = xgb.Get32(buf[b:]) - b += 4 + v.EventTypeBase = buf[b] + b += 1 return b } -// DeviceAbsAreaCtrlReadList reads a byte slice into a list of DeviceAbsAreaCtrl values. -func DeviceAbsAreaCtrlReadList(buf []byte, dest []DeviceAbsAreaCtrl) int { +// InputClassInfoReadList reads a byte slice into a list of InputClassInfo values. +func InputClassInfoReadList(buf []byte, dest []InputClassInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceAbsAreaCtrl{} - b += DeviceAbsAreaCtrlRead(buf[b:], &dest[i]) + dest[i] = InputClassInfo{} + b += InputClassInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceAbsAreaCtrl value to a byte slice. -func (v DeviceAbsAreaCtrl) Bytes() []byte { - buf := make([]byte, 28) +// Bytes writes a InputClassInfo value to a byte slice. +func (v InputClassInfo) Bytes() []byte { + buf := make([]byte, 2) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - xgb.Put32(buf[b:], v.OffsetX) - b += 4 - - xgb.Put32(buf[b:], v.OffsetY) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Width)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Height)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Screen)) - b += 4 + buf[b] = v.ClassId + b += 1 - xgb.Put32(buf[b:], v.Following) - b += 4 + buf[b] = v.EventTypeBase + b += 1 return buf } -// DeviceAbsAreaCtrlListBytes writes a list of DeviceAbsAreaCtrl values to a byte slice. -func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { +// InputClassInfoListBytes writes a list of InputClassInfo values to a byte slice. +func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -3035,62 +3020,50 @@ func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { return b } -type DeviceCoreCtrl struct { - ControlId uint16 - Len uint16 - Status byte - // padding: 3 bytes +type InputInfo struct { + ClassId byte + Len byte } -// DeviceCoreCtrlRead reads a byte slice into a DeviceCoreCtrl value. -func DeviceCoreCtrlRead(buf []byte, v *DeviceCoreCtrl) int { +// InputInfoRead reads a byte slice into a InputInfo value. +func InputInfoRead(buf []byte, v *InputInfo) int { b := 0 - v.ControlId = xgb.Get16(buf[b:]) - b += 2 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.Status = buf[b] + v.ClassId = buf[b] b += 1 - b += 3 // padding + v.Len = buf[b] + b += 1 return b } -// DeviceCoreCtrlReadList reads a byte slice into a list of DeviceCoreCtrl values. -func DeviceCoreCtrlReadList(buf []byte, dest []DeviceCoreCtrl) int { +// InputInfoReadList reads a byte slice into a list of InputInfo values. +func InputInfoReadList(buf []byte, dest []InputInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceCoreCtrl{} - b += DeviceCoreCtrlRead(buf[b:], &dest[i]) + dest[i] = InputInfo{} + b += InputInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceCoreCtrl value to a byte slice. -func (v DeviceCoreCtrl) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a InputInfo value to a byte slice. +func (v InputInfo) Bytes() []byte { + buf := make([]byte, 2) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Status + buf[b] = v.ClassId b += 1 - b += 3 // padding + buf[b] = v.Len + b += 1 return buf } -// DeviceCoreCtrlListBytes writes a list of DeviceCoreCtrl values to a byte slice. -func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { +// InputInfoListBytes writes a list of InputInfo values to a byte slice. +func InputInfoListBytes(buf []byte, list []InputInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -3101,62 +3074,57 @@ func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { return b } -type DeviceEnableCtrl struct { - ControlId uint16 - Len uint16 - Enable byte - // padding: 3 bytes +type InputState struct { + ClassId byte + Len byte + NumItems byte } -// DeviceEnableCtrlRead reads a byte slice into a DeviceEnableCtrl value. -func DeviceEnableCtrlRead(buf []byte, v *DeviceEnableCtrl) int { +// InputStateRead reads a byte slice into a InputState value. +func InputStateRead(buf []byte, v *InputState) int { b := 0 - v.ControlId = xgb.Get16(buf[b:]) - b += 2 - - v.Len = xgb.Get16(buf[b:]) - b += 2 + v.ClassId = buf[b] + b += 1 - v.Enable = buf[b] + v.Len = buf[b] b += 1 - b += 3 // padding + v.NumItems = buf[b] + b += 1 return b } -// DeviceEnableCtrlReadList reads a byte slice into a list of DeviceEnableCtrl values. -func DeviceEnableCtrlReadList(buf []byte, dest []DeviceEnableCtrl) int { +// InputStateReadList reads a byte slice into a list of InputState values. +func InputStateReadList(buf []byte, dest []InputState) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = DeviceEnableCtrl{} - b += DeviceEnableCtrlRead(buf[b:], &dest[i]) + dest[i] = InputState{} + b += InputStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a DeviceEnableCtrl value to a byte slice. -func (v DeviceEnableCtrl) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a InputState value to a byte slice. +func (v InputState) Bytes() []byte { + buf := make([]byte, 3) b := 0 - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 + buf[b] = v.ClassId + b += 1 - buf[b] = v.Enable + buf[b] = v.Len b += 1 - b += 3 // padding + buf[b] = v.NumItems + b += 1 return buf } -// DeviceEnableCtrlListBytes writes a list of DeviceEnableCtrl values to a byte slice. -func DeviceEnableCtrlListBytes(buf []byte, list []DeviceEnableCtrl) int { +// InputStateListBytes writes a list of InputState values to a byte slice. +func InputStateListBytes(buf []byte, list []InputState) int { b := 0 var structBytes []byte for _, item := range list { @@ -3167,1057 +3135,778 @@ func DeviceEnableCtrlListBytes(buf []byte, list []DeviceEnableCtrl) int { return b } -// DeviceValuator is the event number for a DeviceValuatorEvent. -const DeviceValuator = 0 - -type DeviceValuatorEvent struct { - Sequence uint16 - DeviceId byte - DeviceState uint16 - NumValuators byte - FirstValuator byte - Valuators []int32 // size: 24 +type IntegerFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + IntToDisplay int32 } -// DeviceValuatorEventNew constructs a DeviceValuatorEvent value that implements xgb.Event from a byte slice. -func DeviceValuatorEventNew(buf []byte) xgb.Event { - v := DeviceValuatorEvent{} - b := 1 // don't read event number +// IntegerFeedbackCtlRead reads a byte slice into a IntegerFeedbackCtl value. +func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { + b := 0 - v.DeviceId = buf[b] + v.ClassId = buf[b] b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.Id = buf[b] + b += 1 - v.DeviceState = xgb.Get16(buf[b:]) + v.Len = xgb.Get16(buf[b:]) b += 2 - v.NumValuators = buf[b] - b += 1 + v.IntToDisplay = int32(xgb.Get32(buf[b:])) + b += 4 - v.FirstValuator = buf[b] - b += 1 + return b +} - v.Valuators = make([]int32, 6) - for i := 0; i < int(6); i++ { - v.Valuators[i] = int32(xgb.Get32(buf[b:])) - b += 4 +// IntegerFeedbackCtlReadList reads a byte slice into a list of IntegerFeedbackCtl values. +func IntegerFeedbackCtlReadList(buf []byte, dest []IntegerFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = IntegerFeedbackCtl{} + b += IntegerFeedbackCtlRead(buf[b:], &dest[i]) } - b = xgb.Pad(b) - - return v + return xgb.Pad(b) } -// Bytes writes a DeviceValuatorEvent value to a byte slice. -func (v DeviceValuatorEvent) Bytes() []byte { - buf := make([]byte, 32) +// Bytes writes a IntegerFeedbackCtl value to a byte slice. +func (v IntegerFeedbackCtl) Bytes() []byte { + buf := make([]byte, 8) b := 0 - // write event number - buf[b] = 0 + buf[b] = v.ClassId b += 1 - buf[b] = v.DeviceId + buf[b] = v.Id b += 1 - b += 2 // skip sequence number - - xgb.Put16(buf[b:], v.DeviceState) + xgb.Put16(buf[b:], v.Len) b += 2 - buf[b] = v.NumValuators - b += 1 - - buf[b] = v.FirstValuator - b += 1 - - for i := 0; i < int(6); i++ { - xgb.Put32(buf[b:], uint32(v.Valuators[i])) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(v.IntToDisplay)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the DeviceValuator event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceValuatorEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of DeviceValuatorEvent. -func (v DeviceValuatorEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceState: %d", v.DeviceState)) - fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) - fieldVals = append(fieldVals, xgb.Sprintf("FirstValuator: %d", v.FirstValuator)) - return "DeviceValuator {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// IntegerFeedbackCtlListBytes writes a list of IntegerFeedbackCtl values to a byte slice. +func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew +type IntegerFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Resolution uint32 + MinValue int32 + MaxValue int32 } -// DeviceKeyPress is the event number for a DeviceKeyPressEvent. -const DeviceKeyPress = 1 - -type DeviceKeyPressEvent struct { - Sequence uint16 - Detail byte - Time xproto.Timestamp - Root xproto.Window - Event xproto.Window - Child xproto.Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - DeviceId byte -} +// IntegerFeedbackStateRead reads a byte slice into a IntegerFeedbackState value. +func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { + b := 0 -// DeviceKeyPressEventNew constructs a DeviceKeyPressEvent value that implements xgb.Event from a byte slice. -func DeviceKeyPressEventNew(buf []byte) xgb.Event { - v := DeviceKeyPressEvent{} - b := 1 // don't read event number + v.ClassId = buf[b] + b += 1 - v.Detail = buf[b] + v.Id = buf[b] b += 1 - v.Sequence = xgb.Get16(buf[b:]) + v.Len = xgb.Get16(buf[b:]) b += 2 - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Root = xproto.Window(xgb.Get32(buf[b:])) + v.Resolution = xgb.Get32(buf[b:]) b += 4 - v.Event = xproto.Window(xgb.Get32(buf[b:])) + v.MinValue = int32(xgb.Get32(buf[b:])) b += 4 - v.Child = xproto.Window(xgb.Get32(buf[b:])) + v.MaxValue = int32(xgb.Get32(buf[b:])) b += 4 - v.RootX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RootY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.State = xgb.Get16(buf[b:]) - b += 2 + return b +} - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false +// IntegerFeedbackStateReadList reads a byte slice into a list of IntegerFeedbackState values. +func IntegerFeedbackStateReadList(buf []byte, dest []IntegerFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = IntegerFeedbackState{} + b += IntegerFeedbackStateRead(buf[b:], &dest[i]) } - b += 1 - - v.DeviceId = buf[b] - b += 1 - - return v + return xgb.Pad(b) } -// Bytes writes a DeviceKeyPressEvent value to a byte slice. -func (v DeviceKeyPressEvent) Bytes() []byte { - buf := make([]byte, 32) +// Bytes writes a IntegerFeedbackState value to a byte slice. +func (v IntegerFeedbackState) Bytes() []byte { + buf := make([]byte, 16) b := 0 - // write event number - buf[b] = 1 + buf[b] = v.ClassId b += 1 - buf[b] = v.Detail + buf[b] = v.Id b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + xgb.Put16(buf[b:], v.Len) + b += 2 - xgb.Put32(buf[b:], uint32(v.Root)) + xgb.Put32(buf[b:], v.Resolution) b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.MinValue)) b += 4 - xgb.Put32(buf[b:], uint32(v.Child)) + xgb.Put32(buf[b:], uint32(v.MaxValue)) b += 4 - xgb.Put16(buf[b:], uint16(v.RootX)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.RootY)) - b += 2 + return buf +} - xgb.Put16(buf[b:], uint16(v.EventX)) - b += 2 +// IntegerFeedbackStateListBytes writes a list of IntegerFeedbackState values to a byte slice. +func IntegerFeedbackStateListBytes(buf []byte, list []IntegerFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} - xgb.Put16(buf[b:], uint16(v.EventY)) - b += 2 +type KbdFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + Key KeyCode + AutoRepeatMode byte + KeyClickPercent int8 + BellPercent int8 + BellPitch int16 + BellDuration int16 + LedMask uint32 + LedValues uint32 +} - xgb.Put16(buf[b:], v.State) - b += 2 +// KbdFeedbackCtlRead reads a byte slice into a KbdFeedbackCtl value. +func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { + b := 0 - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } + v.ClassId = buf[b] b += 1 - buf[b] = v.DeviceId + v.Id = buf[b] b += 1 - return buf -} - -// SequenceId returns the sequence id attached to the DeviceKeyPress event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceKeyPressEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of DeviceKeyPressEvent. -func (v DeviceKeyPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceKeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][1] = DeviceKeyPressEventNew -} + v.Len = xgb.Get16(buf[b:]) + b += 2 -// FocusIn is the event number for a FocusInEvent. -const FocusIn = 6 + v.Key = KeyCode(buf[b]) + b += 1 -type FocusInEvent struct { - Sequence uint16 - Detail byte - Time xproto.Timestamp - Window xproto.Window - Mode byte - DeviceId byte - // padding: 18 bytes -} + v.AutoRepeatMode = buf[b] + b += 1 -// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. -func FocusInEventNew(buf []byte) xgb.Event { - v := FocusInEvent{} - b := 1 // don't read event number + v.KeyClickPercent = int8(buf[b]) + b += 1 - v.Detail = buf[b] + v.BellPercent = int8(buf[b]) b += 1 - v.Sequence = xgb.Get16(buf[b:]) + v.BellPitch = int16(xgb.Get16(buf[b:])) b += 2 - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + v.BellDuration = int16(xgb.Get16(buf[b:])) + b += 2 - v.Window = xproto.Window(xgb.Get32(buf[b:])) + v.LedMask = xgb.Get32(buf[b:]) b += 4 - v.Mode = buf[b] - b += 1 - - v.DeviceId = buf[b] - b += 1 + v.LedValues = xgb.Get32(buf[b:]) + b += 4 - b += 18 // padding + return b +} - return v +// KbdFeedbackCtlReadList reads a byte slice into a list of KbdFeedbackCtl values. +func KbdFeedbackCtlReadList(buf []byte, dest []KbdFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KbdFeedbackCtl{} + b += KbdFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// Bytes writes a FocusInEvent value to a byte slice. -func (v FocusInEvent) Bytes() []byte { - buf := make([]byte, 32) +// Bytes writes a KbdFeedbackCtl value to a byte slice. +func (v KbdFeedbackCtl) Bytes() []byte { + buf := make([]byte, 20) b := 0 - // write event number - buf[b] = 6 + buf[b] = v.ClassId b += 1 - buf[b] = v.Detail + buf[b] = v.Id b += 1 - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.Len) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + buf[b] = byte(v.Key) + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + buf[b] = v.AutoRepeatMode + b += 1 - buf[b] = v.Mode + buf[b] = byte(v.KeyClickPercent) b += 1 - buf[b] = v.DeviceId + buf[b] = byte(v.BellPercent) b += 1 - b += 18 // padding + xgb.Put16(buf[b:], uint16(v.BellPitch)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.BellDuration)) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 return buf } -// SequenceId returns the sequence id attached to the FocusIn event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v FocusInEvent) SequenceId() uint16 { - return v.Sequence +// KbdFeedbackCtlListBytes writes a list of KbdFeedbackCtl values to a byte slice. +func KbdFeedbackCtlListBytes(buf []byte, list []KbdFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of FocusInEvent. -func (v FocusInEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +type KbdFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Pitch uint16 + Duration uint16 + LedMask uint32 + LedValues uint32 + GlobalAutoRepeat bool + Click byte + Percent byte + // padding: 1 bytes + AutoRepeats []byte // size: 32 } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][6] = FocusInEventNew -} +// KbdFeedbackStateRead reads a byte slice into a KbdFeedbackState value. +func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { + b := 0 -// DeviceStateNotify is the event number for a DeviceStateNotifyEvent. -const DeviceStateNotify = 10 + v.ClassId = buf[b] + b += 1 -type DeviceStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Time xproto.Timestamp - NumKeys byte - NumButtons byte - NumValuators byte - ClassesReported byte - Buttons []byte // size: 4 - Keys []byte // size: 4 - Valuators []uint32 // size: 12 -} + v.Id = buf[b] + b += 1 -// DeviceStateNotifyEventNew constructs a DeviceStateNotifyEvent value that implements xgb.Event from a byte slice. -func DeviceStateNotifyEventNew(buf []byte) xgb.Event { - v := DeviceStateNotifyEvent{} - b := 1 // don't read event number + v.Len = xgb.Get16(buf[b:]) + b += 2 - v.DeviceId = buf[b] - b += 1 + v.Pitch = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Duration = xgb.Get16(buf[b:]) b += 2 - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + v.LedMask = xgb.Get32(buf[b:]) b += 4 - v.NumKeys = buf[b] - b += 1 + v.LedValues = xgb.Get32(buf[b:]) + b += 4 - v.NumButtons = buf[b] + if buf[b] == 1 { + v.GlobalAutoRepeat = true + } else { + v.GlobalAutoRepeat = false + } b += 1 - v.NumValuators = buf[b] + v.Click = buf[b] b += 1 - v.ClassesReported = buf[b] + v.Percent = buf[b] b += 1 - v.Buttons = make([]byte, 4) - copy(v.Buttons[:4], buf[b:]) - b += xgb.Pad(int(4)) + b += 1 // padding - v.Keys = make([]byte, 4) - copy(v.Keys[:4], buf[b:]) - b += xgb.Pad(int(4)) + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) - v.Valuators = make([]uint32, 3) - for i := 0; i < int(3); i++ { - v.Valuators[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + return b +} - return v +// KbdFeedbackStateReadList reads a byte slice into a list of KbdFeedbackState values. +func KbdFeedbackStateReadList(buf []byte, dest []KbdFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KbdFeedbackState{} + b += KbdFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// Bytes writes a DeviceStateNotifyEvent value to a byte slice. -func (v DeviceStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// Bytes writes a KbdFeedbackState value to a byte slice. +func (v KbdFeedbackState) Bytes() []byte { + buf := make([]byte, 52) b := 0 - // write event number - buf[b] = 10 + buf[b] = v.ClassId b += 1 - buf[b] = v.DeviceId + buf[b] = v.Id b += 1 - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.Len) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) + xgb.Put16(buf[b:], v.Pitch) + b += 2 + + xgb.Put16(buf[b:], v.Duration) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) b += 4 - buf[b] = v.NumKeys - b += 1 + xgb.Put32(buf[b:], v.LedValues) + b += 4 - buf[b] = v.NumButtons + if v.GlobalAutoRepeat { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - buf[b] = v.NumValuators + buf[b] = v.Click b += 1 - buf[b] = v.ClassesReported + buf[b] = v.Percent b += 1 - copy(buf[b:], v.Buttons[:4]) - b += xgb.Pad(int(4)) - - copy(buf[b:], v.Keys[:4]) - b += xgb.Pad(int(4)) + b += 1 // padding - for i := 0; i < int(3); i++ { - xgb.Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = xgb.Pad(b) + copy(buf[b:], v.AutoRepeats[:32]) + b += xgb.Pad(int(32)) return buf } -// SequenceId returns the sequence id attached to the DeviceStateNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of DeviceStateNotifyEvent. -func (v DeviceStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 9) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("NumKeys: %d", v.NumKeys)) - fieldVals = append(fieldVals, xgb.Sprintf("NumButtons: %d", v.NumButtons)) - fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) - fieldVals = append(fieldVals, xgb.Sprintf("ClassesReported: %d", v.ClassesReported)) - return "DeviceStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// KbdFeedbackStateListBytes writes a list of KbdFeedbackState values to a byte slice. +func KbdFeedbackStateListBytes(buf []byte, list []KbdFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][10] = DeviceStateNotifyEventNew +// KbdFeedbackStateListSize computes the size (bytes) of a list of KbdFeedbackState values. +func KbdFeedbackStateListSize(list []KbdFeedbackState) int { + size := 0 + for _ = range list { + size += 52 + } + return size } -// DeviceMappingNotify is the event number for a DeviceMappingNotifyEvent. -const DeviceMappingNotify = 11 +type KeyCode byte -type DeviceMappingNotifyEvent struct { - Sequence uint16 - DeviceId byte - Request byte - FirstKeycode KeyCode - Count byte - // padding: 1 bytes - Time xproto.Timestamp - // padding: 20 bytes +type KeyInfo struct { + ClassId byte + Len byte + MinKeycode KeyCode + MaxKeycode KeyCode + NumKeys uint16 + // padding: 2 bytes } -// DeviceMappingNotifyEventNew constructs a DeviceMappingNotifyEvent value that implements xgb.Event from a byte slice. -func DeviceMappingNotifyEventNew(buf []byte) xgb.Event { - v := DeviceMappingNotifyEvent{} - b := 1 // don't read event number +// KeyInfoRead reads a byte slice into a KeyInfo value. +func KeyInfoRead(buf []byte, v *KeyInfo) int { + b := 0 - v.DeviceId = buf[b] + v.ClassId = buf[b] b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Request = buf[b] + v.Len = buf[b] b += 1 - v.FirstKeycode = KeyCode(buf[b]) + v.MinKeycode = KeyCode(buf[b]) b += 1 - v.Count = buf[b] + v.MaxKeycode = KeyCode(buf[b]) b += 1 - b += 1 // padding - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + v.NumKeys = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding + b += 2 // padding - return v + return b } -// Bytes writes a DeviceMappingNotifyEvent value to a byte slice. -func (v DeviceMappingNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// KeyInfoReadList reads a byte slice into a list of KeyInfo values. +func KeyInfoReadList(buf []byte, dest []KeyInfo) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KeyInfo{} + b += KeyInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 11 - b += 1 +// Bytes writes a KeyInfo value to a byte slice. +func (v KeyInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - buf[b] = v.DeviceId + buf[b] = v.ClassId b += 1 - b += 2 // skip sequence number - - buf[b] = v.Request + buf[b] = v.Len b += 1 - buf[b] = byte(v.FirstKeycode) + buf[b] = byte(v.MinKeycode) b += 1 - buf[b] = v.Count + buf[b] = byte(v.MaxKeycode) b += 1 - b += 1 // padding - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + xgb.Put16(buf[b:], v.NumKeys) + b += 2 - b += 20 // padding + b += 2 // padding return buf } -// SequenceId returns the sequence id attached to the DeviceMappingNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceMappingNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of DeviceMappingNotifyEvent. -func (v DeviceMappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) - fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - return "DeviceMappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew -} - -// ChangeDeviceNotify is the event number for a ChangeDeviceNotifyEvent. -const ChangeDeviceNotify = 12 - -type ChangeDeviceNotifyEvent struct { - Sequence uint16 - DeviceId byte - Time xproto.Timestamp - Request byte - // padding: 23 bytes +// KeyInfoListBytes writes a list of KeyInfo values to a byte slice. +func KeyInfoListBytes(buf []byte, list []KeyInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// ChangeDeviceNotifyEventNew constructs a ChangeDeviceNotifyEvent value that implements xgb.Event from a byte slice. -func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { - v := ChangeDeviceNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Request = buf[b] - b += 1 - - b += 23 // padding - - return v +type KeyState struct { + ClassId byte + Len byte + NumKeys byte + // padding: 1 bytes + Keys []byte // size: 32 } -// Bytes writes a ChangeDeviceNotifyEvent value to a byte slice. -func (v ChangeDeviceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// KeyStateRead reads a byte slice into a KeyState value. +func KeyStateRead(buf []byte, v *KeyState) int { b := 0 - // write event number - buf[b] = 12 + v.ClassId = buf[b] b += 1 - buf[b] = v.DeviceId + v.Len = buf[b] b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.Request + v.NumKeys = buf[b] b += 1 - b += 23 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the ChangeDeviceNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ChangeDeviceNotifyEvent) SequenceId() uint16 { - return v.Sequence -} + b += 1 // padding -// String is a rudimentary string representation of ChangeDeviceNotifyEvent. -func (v ChangeDeviceNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) - return "ChangeDeviceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) -func init() { - xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew + return b } -// DeviceKeyStateNotify is the event number for a DeviceKeyStateNotifyEvent. -const DeviceKeyStateNotify = 13 - -type DeviceKeyStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Keys []byte // size: 28 +// KeyStateReadList reads a byte slice into a list of KeyState values. +func KeyStateReadList(buf []byte, dest []KeyState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KeyState{} + b += KeyStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// DeviceKeyStateNotifyEventNew constructs a DeviceKeyStateNotifyEvent value that implements xgb.Event from a byte slice. -func DeviceKeyStateNotifyEventNew(buf []byte) xgb.Event { - v := DeviceKeyStateNotifyEvent{} - b := 1 // don't read event number +// Bytes writes a KeyState value to a byte slice. +func (v KeyState) Bytes() []byte { + buf := make([]byte, 36) + b := 0 - v.DeviceId = buf[b] + buf[b] = v.ClassId b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Keys = make([]byte, 28) - copy(v.Keys[:28], buf[b:]) - b += xgb.Pad(int(28)) - - return v -} - -// Bytes writes a DeviceKeyStateNotifyEvent value to a byte slice. -func (v DeviceKeyStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 13 + buf[b] = v.Len b += 1 - buf[b] = v.DeviceId + buf[b] = v.NumKeys b += 1 - b += 2 // skip sequence number + b += 1 // padding - copy(buf[b:], v.Keys[:28]) - b += xgb.Pad(int(28)) + copy(buf[b:], v.Keys[:32]) + b += xgb.Pad(int(32)) return buf } -// SequenceId returns the sequence id attached to the DeviceKeyStateNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceKeyStateNotifyEvent) SequenceId() uint16 { - return v.Sequence +// KeyStateListBytes writes a list of KeyState values to a byte slice. +func KeyStateListBytes(buf []byte, list []KeyState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of DeviceKeyStateNotifyEvent. -func (v DeviceKeyStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceKeyStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// KeyStateListSize computes the size (bytes) of a list of KeyState values. +func KeyStateListSize(list []KeyState) int { + size := 0 + for _ = range list { + size += 36 + } + return size } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew +type LedFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 } -// DeviceButtonStateNotify is the event number for a DeviceButtonStateNotifyEvent. -const DeviceButtonStateNotify = 14 - -type DeviceButtonStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Buttons []byte // size: 28 -} +// LedFeedbackCtlRead reads a byte slice into a LedFeedbackCtl value. +func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { + b := 0 -// DeviceButtonStateNotifyEventNew constructs a DeviceButtonStateNotifyEvent value that implements xgb.Event from a byte slice. -func DeviceButtonStateNotifyEventNew(buf []byte) xgb.Event { - v := DeviceButtonStateNotifyEvent{} - b := 1 // don't read event number + v.ClassId = buf[b] + b += 1 - v.DeviceId = buf[b] + v.Id = buf[b] b += 1 - v.Sequence = xgb.Get16(buf[b:]) + v.Len = xgb.Get16(buf[b:]) b += 2 - v.Buttons = make([]byte, 28) - copy(v.Buttons[:28], buf[b:]) - b += xgb.Pad(int(28)) + v.LedMask = xgb.Get32(buf[b:]) + b += 4 - return v + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b } -// Bytes writes a DeviceButtonStateNotifyEvent value to a byte slice. -func (v DeviceButtonStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// LedFeedbackCtlReadList reads a byte slice into a list of LedFeedbackCtl values. +func LedFeedbackCtlReadList(buf []byte, dest []LedFeedbackCtl) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = LedFeedbackCtl{} + b += LedFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 14 - b += 1 +// Bytes writes a LedFeedbackCtl value to a byte slice. +func (v LedFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 - buf[b] = v.DeviceId + buf[b] = v.ClassId b += 1 - b += 2 // skip sequence number + buf[b] = v.Id + b += 1 - copy(buf[b:], v.Buttons[:28]) - b += xgb.Pad(int(28)) + xgb.Put16(buf[b:], v.Len) + b += 2 - return buf -} + xgb.Put32(buf[b:], v.LedMask) + b += 4 -// SequenceId returns the sequence id attached to the DeviceButtonStateNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceButtonStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} + xgb.Put32(buf[b:], v.LedValues) + b += 4 -// String is a rudimentary string representation of DeviceButtonStateNotifyEvent. -func (v DeviceButtonStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceButtonStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return buf } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][14] = DeviceButtonStateNotifyEventNew +// LedFeedbackCtlListBytes writes a list of LedFeedbackCtl values to a byte slice. +func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// DevicePresenceNotify is the event number for a DevicePresenceNotifyEvent. -const DevicePresenceNotify = 15 - -type DevicePresenceNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time xproto.Timestamp - Devchange byte - DeviceId byte - Control uint16 - // padding: 20 bytes +type LedFeedbackState struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 } -// DevicePresenceNotifyEventNew constructs a DevicePresenceNotifyEvent value that implements xgb.Event from a byte slice. -func DevicePresenceNotifyEventNew(buf []byte) xgb.Event { - v := DevicePresenceNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 +// LedFeedbackStateRead reads a byte slice into a LedFeedbackState value. +func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { + b := 0 - v.Devchange = buf[b] + v.ClassId = buf[b] b += 1 - v.DeviceId = buf[b] + v.Id = buf[b] b += 1 - v.Control = xgb.Get16(buf[b:]) + v.Len = xgb.Get16(buf[b:]) b += 2 - b += 20 // padding + v.LedMask = xgb.Get32(buf[b:]) + b += 4 - return v + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b } -// Bytes writes a DevicePresenceNotifyEvent value to a byte slice. -func (v DevicePresenceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// LedFeedbackStateReadList reads a byte slice into a list of LedFeedbackState values. +func LedFeedbackStateReadList(buf []byte, dest []LedFeedbackState) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = LedFeedbackState{} + b += LedFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 15 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 +// Bytes writes a LedFeedbackState value to a byte slice. +func (v LedFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 - buf[b] = v.Devchange + buf[b] = v.ClassId b += 1 - buf[b] = v.DeviceId + buf[b] = v.Id b += 1 - xgb.Put16(buf[b:], v.Control) + xgb.Put16(buf[b:], v.Len) b += 2 - b += 20 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the DevicePresenceNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DevicePresenceNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of DevicePresenceNotifyEvent. -func (v DevicePresenceNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Devchange: %d", v.Devchange)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, xgb.Sprintf("Control: %d", v.Control)) - return "DevicePresenceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][15] = DevicePresenceNotifyEventNew -} - -// DeviceKeyRelease is the event number for a DeviceKeyReleaseEvent. -const DeviceKeyRelease = 2 - -type DeviceKeyReleaseEvent DeviceKeyPressEvent + xgb.Put32(buf[b:], v.LedMask) + b += 4 -// DeviceKeyReleaseEventNew constructs a DeviceKeyReleaseEvent value that implements xgb.Event from a byte slice. -func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { - return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) -} + xgb.Put32(buf[b:], v.LedValues) + b += 4 -// Bytes writes a DeviceKeyReleaseEvent value to a byte slice. -func (v DeviceKeyReleaseEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() + return buf } -// SequenceId returns the sequence id attached to the DeviceKeyRelease event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceKeyReleaseEvent) SequenceId() uint16 { - return v.Sequence +// LedFeedbackStateListBytes writes a list of LedFeedbackState values to a byte slice. +func LedFeedbackStateListBytes(buf []byte, list []LedFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -func (v DeviceKeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceKeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// BadMode is the error number for a BadMode. +const BadMode = 2 -func init() { - xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew +type ModeError struct { + Sequence uint16 + NiceName string } -// DeviceButtonPress is the event number for a DeviceButtonPressEvent. -const DeviceButtonPress = 3 +// ModeErrorNew constructs a ModeError value that implements xgb.Error from a byte slice. +func ModeErrorNew(buf []byte) xgb.Error { + v := ModeError{} + v.NiceName = "Mode" -type DeviceButtonPressEvent DeviceKeyPressEvent + b := 1 // skip error determinant + b += 1 // don't read error number -// DeviceButtonPressEventNew constructs a DeviceButtonPressEvent value that implements xgb.Event from a byte slice. -func DeviceButtonPressEventNew(buf []byte) xgb.Event { - return DeviceButtonPressEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Bytes writes a DeviceButtonPressEvent value to a byte slice. -func (v DeviceButtonPressEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() + return v } -// SequenceId returns the sequence id attached to the DeviceButtonPress event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadMode error. // This is mostly used internally. -func (v DeviceButtonPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v DeviceButtonPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew -} - -// DeviceButtonRelease is the event number for a DeviceButtonReleaseEvent. -const DeviceButtonRelease = 4 - -type DeviceButtonReleaseEvent DeviceKeyPressEvent - -// DeviceButtonReleaseEventNew constructs a DeviceButtonReleaseEvent value that implements xgb.Event from a byte slice. -func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { - return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +func (err ModeError) SequenceId() uint16 { + return err.Sequence } -// Bytes writes a DeviceButtonReleaseEvent value to a byte slice. -func (v DeviceButtonReleaseEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() +// BadId returns the 'BadValue' number if one exists for the BadMode error. If no bad value exists, 0 is returned. +func (err ModeError) BadId() uint32 { + return 0 } -// SequenceId returns the sequence id attached to the DeviceButtonRelease event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceButtonReleaseEvent) SequenceId() uint16 { - return v.Sequence -} +// Error returns a rudimentary string representation of the BadMode error. -func (v DeviceButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +func (err ModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew -} - -// DeviceMotionNotify is the event number for a DeviceMotionNotifyEvent. -const DeviceMotionNotify = 5 - -type DeviceMotionNotifyEvent DeviceKeyPressEvent - -// DeviceMotionNotifyEventNew constructs a DeviceMotionNotifyEvent value that implements xgb.Event from a byte slice. -func DeviceMotionNotifyEventNew(buf []byte) xgb.Event { - return DeviceMotionNotifyEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) -} - -// Bytes writes a DeviceMotionNotifyEvent value to a byte slice. -func (v DeviceMotionNotifyEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() -} - -// SequenceId returns the sequence id attached to the DeviceMotionNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceMotionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v DeviceMotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceMotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][5] = DeviceMotionNotifyEventNew -} +const ( + PropagateModeAddToList = 0 + PropagateModeDeleteFromList = 1 +) // ProximityIn is the event number for a ProximityInEvent. const ProximityIn = 8 @@ -4307,420 +3996,822 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][9] = ProximityOutEventNew } -// FocusOut is the event number for a FocusOutEvent. -const FocusOut = 7 +type PtrFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + Num int16 + Denom int16 + Threshold int16 +} -type FocusOutEvent FocusInEvent +// PtrFeedbackCtlRead reads a byte slice into a PtrFeedbackCtl value. +func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { + b := 0 -// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. -func FocusOutEventNew(buf []byte) xgb.Event { - return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) -} + v.ClassId = buf[b] + b += 1 -// Bytes writes a FocusOutEvent value to a byte slice. -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() -} + v.Id = buf[b] + b += 1 -// SequenceId returns the sequence id attached to the FocusOut event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v FocusOutEvent) SequenceId() uint16 { - return v.Sequence -} + v.Len = xgb.Get16(buf[b:]) + b += 2 -func (v FocusOutEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" + b += 2 // padding + + v.Num = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Denom = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Threshold = int16(xgb.Get16(buf[b:])) + b += 2 + + return b } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew +// PtrFeedbackCtlReadList reads a byte slice into a list of PtrFeedbackCtl values. +func PtrFeedbackCtlReadList(buf []byte, dest []PtrFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = PtrFeedbackCtl{} + b += PtrFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// BadDevice is the error number for a BadDevice. -const BadDevice = 0 +// Bytes writes a PtrFeedbackCtl value to a byte slice. +func (v PtrFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 -type DeviceError struct { - Sequence uint16 - NiceName string -} + buf[b] = v.ClassId + b += 1 -// DeviceErrorNew constructs a DeviceError value that implements xgb.Error from a byte slice. -func DeviceErrorNew(buf []byte) xgb.Error { - v := DeviceError{} - v.NiceName = "Device" + buf[b] = v.Id + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + xgb.Put16(buf[b:], v.Len) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + b += 2 // padding + + xgb.Put16(buf[b:], uint16(v.Num)) b += 2 - return v + xgb.Put16(buf[b:], uint16(v.Denom)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Threshold)) + b += 2 + + return buf } -// SequenceId returns the sequence id attached to the BadDevice error. -// This is mostly used internally. -func (err DeviceError) SequenceId() uint16 { - return err.Sequence +// PtrFeedbackCtlListBytes writes a list of PtrFeedbackCtl values to a byte slice. +func PtrFeedbackCtlListBytes(buf []byte, list []PtrFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// BadId returns the 'BadValue' number if one exists for the BadDevice error. If no bad value exists, 0 is returned. -func (err DeviceError) BadId() uint32 { - return 0 +type PtrFeedbackState struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + AccelNum uint16 + AccelDenom uint16 + Threshold uint16 } -// Error returns a rudimentary string representation of the BadDevice error. +// PtrFeedbackStateRead reads a byte slice into a PtrFeedbackState value. +func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) int { + b := 0 -func (err DeviceError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadDevice {" + xgb.StringsJoin(fieldVals, ", ") + "}" + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AccelNum = xgb.Get16(buf[b:]) + b += 2 + + v.AccelDenom = xgb.Get16(buf[b:]) + b += 2 + + v.Threshold = xgb.Get16(buf[b:]) + b += 2 + + return b } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew +// PtrFeedbackStateReadList reads a byte slice into a list of PtrFeedbackState values. +func PtrFeedbackStateReadList(buf []byte, dest []PtrFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = PtrFeedbackState{} + b += PtrFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// BadEvent is the error number for a BadEvent. -const BadEvent = 1 +// Bytes writes a PtrFeedbackState value to a byte slice. +func (v PtrFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 -type EventError struct { - Sequence uint16 - NiceName string -} + buf[b] = v.ClassId + b += 1 -// EventErrorNew constructs a EventError value that implements xgb.Error from a byte slice. -func EventErrorNew(buf []byte) xgb.Error { - v := EventError{} - v.NiceName = "Event" + buf[b] = v.Id + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + xgb.Put16(buf[b:], v.Len) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + b += 2 // padding + + xgb.Put16(buf[b:], v.AccelNum) b += 2 - return v + xgb.Put16(buf[b:], v.AccelDenom) + b += 2 + + xgb.Put16(buf[b:], v.Threshold) + b += 2 + + return buf } -// SequenceId returns the sequence id attached to the BadEvent error. -// This is mostly used internally. -func (err EventError) SequenceId() uint16 { - return err.Sequence +// PtrFeedbackStateListBytes writes a list of PtrFeedbackState values to a byte slice. +func PtrFeedbackStateListBytes(buf []byte, list []PtrFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// BadId returns the 'BadValue' number if one exists for the BadEvent error. If no bad value exists, 0 is returned. -func (err EventError) BadId() uint32 { - return 0 +type StringFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) } -// Error returns a rudimentary string representation of the BadEvent error. +// StringFeedbackCtlRead reads a byte slice into a StringFeedbackCtl value. +func StringFeedbackCtlRead(buf []byte, v *StringFeedbackCtl) int { + b := 0 -func (err EventError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadEvent {" + xgb.StringsJoin(fieldVals, ", ") + "}" + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.NumKeysyms = xgb.Get16(buf[b:]) + b += 2 + + v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) + for i := 0; i < int(v.NumKeysyms); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return b } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][1] = EventErrorNew +// StringFeedbackCtlReadList reads a byte slice into a list of StringFeedbackCtl values. +func StringFeedbackCtlReadList(buf []byte, dest []StringFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = StringFeedbackCtl{} + b += StringFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// BadMode is the error number for a BadMode. -const BadMode = 2 +// Bytes writes a StringFeedbackCtl value to a byte slice. +func (v StringFeedbackCtl) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) + b := 0 -type ModeError struct { - Sequence uint16 - NiceName string -} + buf[b] = v.ClassId + b += 1 -// ModeErrorNew constructs a ModeError value that implements xgb.Error from a byte slice. -func ModeErrorNew(buf []byte) xgb.Error { - v := ModeError{} - v.NiceName = "Mode" + buf[b] = v.Id + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + xgb.Put16(buf[b:], v.Len) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + b += 2 // padding + + xgb.Put16(buf[b:], v.NumKeysyms) b += 2 - return v + for i := 0; i < int(v.NumKeysyms); i++ { + xgb.Put32(buf[b:], uint32(v.Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf } -// SequenceId returns the sequence id attached to the BadMode error. -// This is mostly used internally. -func (err ModeError) SequenceId() uint16 { - return err.Sequence +// StringFeedbackCtlListBytes writes a list of StringFeedbackCtl values to a byte slice. +func StringFeedbackCtlListBytes(buf []byte, list []StringFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// BadId returns the 'BadValue' number if one exists for the BadMode error. If no bad value exists, 0 is returned. -func (err ModeError) BadId() uint32 { - return 0 +// StringFeedbackCtlListSize computes the size (bytes) of a list of StringFeedbackCtl values. +func StringFeedbackCtlListSize(list []StringFeedbackCtl) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) + } + return size } -// Error returns a rudimentary string representation of the BadMode error. +type StringFeedbackState struct { + ClassId byte + Id byte + Len uint16 + MaxSymbols uint16 + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +} -func (err ModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// StringFeedbackStateRead reads a byte slice into a StringFeedbackState value. +func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MaxSymbols = xgb.Get16(buf[b:]) + b += 2 + + v.NumKeysyms = xgb.Get16(buf[b:]) + b += 2 + + v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) + for i := 0; i < int(v.NumKeysyms); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return b } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew +// StringFeedbackStateReadList reads a byte slice into a list of StringFeedbackState values. +func StringFeedbackStateReadList(buf []byte, dest []StringFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = StringFeedbackState{} + b += StringFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// BadDeviceBusy is the error number for a BadDeviceBusy. -const BadDeviceBusy = 3 +// Bytes writes a StringFeedbackState value to a byte slice. +func (v StringFeedbackState) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) + b := 0 -type DeviceBusyError struct { - Sequence uint16 - NiceName string -} + buf[b] = v.ClassId + b += 1 -// DeviceBusyErrorNew constructs a DeviceBusyError value that implements xgb.Error from a byte slice. -func DeviceBusyErrorNew(buf []byte) xgb.Error { - v := DeviceBusyError{} - v.NiceName = "DeviceBusy" + buf[b] = v.Id + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + xgb.Put16(buf[b:], v.Len) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.MaxSymbols) b += 2 - return v + xgb.Put16(buf[b:], v.NumKeysyms) + b += 2 + + for i := 0; i < int(v.NumKeysyms); i++ { + xgb.Put32(buf[b:], uint32(v.Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf } -// SequenceId returns the sequence id attached to the BadDeviceBusy error. -// This is mostly used internally. -func (err DeviceBusyError) SequenceId() uint16 { - return err.Sequence +// StringFeedbackStateListBytes writes a list of StringFeedbackState values to a byte slice. +func StringFeedbackStateListBytes(buf []byte, list []StringFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// BadId returns the 'BadValue' number if one exists for the BadDeviceBusy error. If no bad value exists, 0 is returned. -func (err DeviceBusyError) BadId() uint32 { - return 0 +// StringFeedbackStateListSize computes the size (bytes) of a list of StringFeedbackState values. +func StringFeedbackStateListSize(list []StringFeedbackState) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) + } + return size } -// Error returns a rudimentary string representation of the BadDeviceBusy error. +type ValuatorInfo struct { + ClassId byte + Len byte + AxesLen byte + Mode byte + MotionSize uint32 + Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) +} -func (err DeviceBusyError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadDeviceBusy {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ValuatorInfoRead reads a byte slice into a ValuatorInfo value. +func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.AxesLen = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.MotionSize = xgb.Get32(buf[b:]) + b += 4 + + v.Axes = make([]AxisInfo, v.AxesLen) + b += AxisInfoReadList(buf[b:], v.Axes) + + return b } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew +// ValuatorInfoReadList reads a byte slice into a list of ValuatorInfo values. +func ValuatorInfoReadList(buf []byte, dest []ValuatorInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ValuatorInfo{} + b += ValuatorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// BadClass is the error number for a BadClass. -const BadClass = 4 +// Bytes writes a ValuatorInfo value to a byte slice. +func (v ValuatorInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.AxesLen) * 12)))) + b := 0 -type ClassError struct { - Sequence uint16 - NiceName string + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.AxesLen + b += 1 + + buf[b] = v.Mode + b += 1 + + xgb.Put32(buf[b:], v.MotionSize) + b += 4 + + b += AxisInfoListBytes(buf[b:], v.Axes) + + return buf } -// ClassErrorNew constructs a ClassError value that implements xgb.Error from a byte slice. -func ClassErrorNew(buf []byte) xgb.Error { - v := ClassError{} - v.NiceName = "Class" +// ValuatorInfoListBytes writes a list of ValuatorInfo values to a byte slice. +func ValuatorInfoListBytes(buf []byte, list []ValuatorInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} - b := 1 // skip error determinant - b += 1 // don't read error number +// ValuatorInfoListSize computes the size (bytes) of a list of ValuatorInfo values. +func ValuatorInfoListSize(list []ValuatorInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.AxesLen) * 12))) + } + return size +} - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +const ( + ValuatorModeRelative = 0 + ValuatorModeAbsolute = 1 +) - return v +type ValuatorState struct { + ClassId byte + Len byte + NumValuators byte + Mode byte + Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) } -// SequenceId returns the sequence id attached to the BadClass error. -// This is mostly used internally. -func (err ClassError) SequenceId() uint16 { - return err.Sequence +// ValuatorStateRead reads a byte slice into a ValuatorState value. +func ValuatorStateRead(buf []byte, v *ValuatorState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.Valuators = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.Valuators[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b } -// BadId returns the 'BadValue' number if one exists for the BadClass error. If no bad value exists, 0 is returned. -func (err ClassError) BadId() uint32 { - return 0 +// ValuatorStateReadList reads a byte slice into a list of ValuatorState values. +func ValuatorStateReadList(buf []byte, dest []ValuatorState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ValuatorState{} + b += ValuatorStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// Error returns a rudimentary string representation of the BadClass error. +// Bytes writes a ValuatorState value to a byte slice. +func (v ValuatorState) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 -func (err ClassError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadClass {" + xgb.StringsJoin(fieldVals, ", ") + "}" + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.Mode + b += 1 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew +// ValuatorStateListBytes writes a list of ValuatorState values to a byte slice. +func ValuatorStateListBytes(buf []byte, list []ValuatorState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// GetExtensionVersionCookie is a cookie used only for GetExtensionVersion requests. -type GetExtensionVersionCookie struct { +// ValuatorStateListSize computes the size (bytes) of a list of ValuatorState values. +func ValuatorStateListSize(list []ValuatorState) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// 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' + +// AllowDeviceEventsCookie is a cookie used only for AllowDeviceEvents requests. +type AllowDeviceEventsCookie struct { *xgb.Cookie } -// GetExtensionVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetExtensionVersionCookie.Reply() -func GetExtensionVersion(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { +// AllowDeviceEvents sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllowDeviceEvents(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetExtensionVersion' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'AllowDeviceEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) - return GetExtensionVersionCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} } -// GetExtensionVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetExtensionVersionUnchecked(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { +// AllowDeviceEventsChecked sends a checked request. +// If an error occurs, it can be retrieved using AllowDeviceEventsCookie.Check() +func AllowDeviceEventsChecked(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetExtensionVersion' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'AllowDeviceEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) - return GetExtensionVersionCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} } -// GetExtensionVersionReply represents the data returned from a GetExtensionVersion request. -type GetExtensionVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 - Present bool - // padding: 19 bytes +// 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 AllowDeviceEventsCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetExtensionVersion request. -func (cook GetExtensionVersionCookie) Reply() (*GetExtensionVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err +// Write request to wire for AllowDeviceEvents +// allowDeviceEventsRequest writes a AllowDeviceEvents request to a byte slice. +func allowDeviceEventsRequest(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 19 // 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(Time)) + b += 4 + + buf[b] = Mode + b += 1 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// ChangeDeviceDontPropagateListCookie is a cookie used only for ChangeDeviceDontPropagateList requests. +type ChangeDeviceDontPropagateListCookie struct { + *xgb.Cookie +} + +// ChangeDeviceDontPropagateList sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'ChangeDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - if buf == nil { - return nil, nil + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} +} + +// ChangeDeviceDontPropagateListChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeDeviceDontPropagateListCookie.Check() +func ChangeDeviceDontPropagateListChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'ChangeDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - return getExtensionVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} } -// getExtensionVersionReply reads a byte slice into a GetExtensionVersionReply value. -func getExtensionVersionReply(buf []byte) *GetExtensionVersionReply { - v := new(GetExtensionVersionReply) - b := 1 // skip reply determinant +// 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 ChangeDeviceDontPropagateListCookie) Check() error { + return cook.Cookie.Check() +} - b += 1 // padding +// Write request to wire for ChangeDeviceDontPropagateList +// changeDeviceDontPropagateListRequest writes a ChangeDeviceDontPropagateList request to a byte slice. +func changeDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Window)) b += 4 - v.ServerMajor = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], NumClasses) b += 2 - v.ServerMinor = xgb.Get16(buf[b:]) - b += 2 + buf[b] = Mode + b += 1 - if buf[b] == 1 { - v.Present = true - } else { - v.Present = false + b += 1 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 } - b += 1 + b = xgb.Pad(b) - b += 19 // padding + return buf +} - return v +// ChangeDeviceKeyMappingCookie is a cookie used only for ChangeDeviceKeyMapping requests. +type ChangeDeviceKeyMappingCookie struct { + *xgb.Cookie } -// Write request to wire for GetExtensionVersion -// getExtensionVersionRequest writes a GetExtensionVersion request to a byte slice. -func getExtensionVersionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// ChangeDeviceKeyMapping sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'ChangeDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) + return ChangeDeviceKeyMappingCookie{cookie} +} + +// ChangeDeviceKeyMappingChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeDeviceKeyMappingCookie.Check() +func ChangeDeviceKeyMappingChecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'ChangeDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) + return ChangeDeviceKeyMappingCookie{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 ChangeDeviceKeyMappingCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeDeviceKeyMapping +// changeDeviceKeyMappingRequest writes a ChangeDeviceKeyMapping request to a byte slice. +func changeDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) []byte { + size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 25 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], NameLen) - b += 2 + buf[b] = DeviceId + b += 1 - b += 2 // padding + buf[b] = byte(FirstKeycode) + b += 1 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + buf[b] = KeysymsPerKeycode + b += 1 + + buf[b] = KeycodeCount + b += 1 + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) return buf } -// ListInputDevicesCookie is a cookie used only for ListInputDevices requests. -type ListInputDevicesCookie struct { +// ChangeKeyboardDeviceCookie is a cookie used only for ChangeKeyboardDevice requests. +type ChangeKeyboardDeviceCookie struct { *xgb.Cookie } -// ListInputDevices sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListInputDevicesCookie.Reply() -func ListInputDevices(c *xgb.Conn) ListInputDevicesCookie { +// ChangeKeyboardDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling ChangeKeyboardDeviceCookie.Reply() +func ChangeKeyboardDevice(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeKeyboardDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listInputDevicesRequest(c), cookie) - return ListInputDevicesCookie{cookie} + c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} } -// ListInputDevicesUnchecked sends an unchecked request. +// ChangeKeyboardDeviceUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { +func ChangeKeyboardDeviceUnchecked(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeKeyboardDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listInputDevicesRequest(c), cookie) - return ListInputDevicesCookie{cookie} + c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} } -// ListInputDevicesReply represents the data returned from a ListInputDevices request. -type ListInputDevicesReply struct { +// ChangeKeyboardDeviceReply represents the data returned from a ChangeKeyboardDevice request. +type ChangeKeyboardDeviceReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - DevicesLen byte + Status byte // padding: 23 bytes - Devices []DeviceInfo // size: xgb.Pad((int(DevicesLen) * 8)) } -// Reply blocks and returns the reply data for a ListInputDevices request. -func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { +// Reply blocks and returns the reply data for a ChangeKeyboardDevice request. +func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4728,12 +4819,12 @@ func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { if buf == nil { return nil, nil } - return listInputDevicesReply(buf), nil + return changeKeyboardDeviceReply(buf), nil } -// listInputDevicesReply reads a byte slice into a ListInputDevicesReply value. -func listInputDevicesReply(buf []byte) *ListInputDevicesReply { - v := new(ListInputDevicesReply) +// changeKeyboardDeviceReply reads a byte slice into a ChangeKeyboardDeviceReply value. +func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { + v := new(ChangeKeyboardDeviceReply) b := 1 // skip reply determinant b += 1 // padding @@ -4744,75 +4835,76 @@ func listInputDevicesReply(buf []byte) *ListInputDevicesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.DevicesLen = buf[b] + v.Status = buf[b] b += 1 b += 23 // padding - v.Devices = make([]DeviceInfo, v.DevicesLen) - b += DeviceInfoReadList(buf[b:], v.Devices) - return v } -// Write request to wire for ListInputDevices -// listInputDevicesRequest writes a ListInputDevices request to a byte slice. -func listInputDevicesRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for ChangeKeyboardDevice +// changeKeyboardDeviceRequest writes a ChangeKeyboardDevice request to a byte slice. +func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 2 // 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 + buf[b] = DeviceId + b += 1 + + b += 3 // padding + return buf } -// OpenDeviceCookie is a cookie used only for OpenDevice requests. -type OpenDeviceCookie struct { +// ChangePointerDeviceCookie is a cookie used only for ChangePointerDevice requests. +type ChangePointerDeviceCookie struct { *xgb.Cookie } -// OpenDevice sends a checked request. -// If an error occurs, it will be returned with the reply by calling OpenDeviceCookie.Reply() -func OpenDevice(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { +// ChangePointerDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling ChangePointerDeviceCookie.Reply() +func ChangePointerDevice(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'OpenDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangePointerDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(openDeviceRequest(c, DeviceId), cookie) - return OpenDeviceCookie{cookie} + c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} } -// OpenDeviceUnchecked sends an unchecked request. +// ChangePointerDeviceUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { +func ChangePointerDeviceUnchecked(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'OpenDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangePointerDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(openDeviceRequest(c, DeviceId), cookie) - return OpenDeviceCookie{cookie} + c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} } -// OpenDeviceReply represents the data returned from a OpenDevice request. -type OpenDeviceReply struct { +// ChangePointerDeviceReply represents the data returned from a ChangePointerDevice request. +type ChangePointerDeviceReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumClasses byte + Status byte // padding: 23 bytes - ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) } -// Reply blocks and returns the reply data for a OpenDevice request. -func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { +// Reply blocks and returns the reply data for a ChangePointerDevice request. +func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4820,12 +4912,12 @@ func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { if buf == nil { return nil, nil } - return openDeviceReply(buf), nil + return changePointerDeviceReply(buf), nil } -// openDeviceReply reads a byte slice into a OpenDeviceReply value. -func openDeviceReply(buf []byte) *OpenDeviceReply { - v := new(OpenDeviceReply) +// changePointerDeviceReply reads a byte slice into a ChangePointerDeviceReply value. +func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { + v := new(ChangePointerDeviceReply) b := 1 // skip reply determinant b += 1 // padding @@ -4836,20 +4928,17 @@ func openDeviceReply(buf []byte) *OpenDeviceReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumClasses = buf[b] + v.Status = buf[b] b += 1 b += 23 // padding - v.ClassInfo = make([]InputClassInfo, v.NumClasses) - b += InputClassInfoReadList(buf[b:], v.ClassInfo) - return v } -// Write request to wire for OpenDevice -// openDeviceRequest writes a OpenDevice request to a byte slice. -func openDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { +// Write request to wire for ChangePointerDevice +// changePointerDeviceRequest writes a ChangePointerDevice request to a byte slice. +func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -4857,16 +4946,22 @@ func openDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + buf[b] = XAxis + b += 1 + + buf[b] = YAxis + b += 1 + buf[b] = DeviceId b += 1 - b += 3 // padding + b += 1 // padding return buf } @@ -4928,44 +5023,109 @@ func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// SetDeviceModeCookie is a cookie used only for SetDeviceMode requests. -type SetDeviceModeCookie struct { +// DeviceBellCookie is a cookie used only for DeviceBell requests. +type DeviceBellCookie struct { *xgb.Cookie } -// SetDeviceMode sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetDeviceModeCookie.Reply() -func SetDeviceMode(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { +// DeviceBell sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DeviceBell(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceMode' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'DeviceBell' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{cookie} +} + +// DeviceBellChecked sends a checked request. +// If an error occurs, it can be retrieved using DeviceBellCookie.Check() +func DeviceBellChecked(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'DeviceBell' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{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 DeviceBellCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeviceBell +// deviceBellRequest writes a DeviceBell request to a byte slice. +func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 32 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = FeedbackId + b += 1 + + buf[b] = FeedbackClass + b += 1 + + buf[b] = byte(Percent) + b += 1 + + return buf +} + +// GetDeviceButtonMappingCookie is a cookie used only for GetDeviceButtonMapping requests. +type GetDeviceButtonMappingCookie struct { + *xgb.Cookie +} + +// GetDeviceButtonMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceButtonMappingCookie.Reply() +func GetDeviceButtonMapping(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) - return SetDeviceModeCookie{cookie} + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} } -// SetDeviceModeUnchecked sends an unchecked request. +// GetDeviceButtonMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceModeUnchecked(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { +func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceMode' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) - return SetDeviceModeCookie{cookie} + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} } -// SetDeviceModeReply represents the data returned from a SetDeviceMode request. -type SetDeviceModeReply struct { +// GetDeviceButtonMappingReply represents the data returned from a GetDeviceButtonMapping request. +type GetDeviceButtonMappingReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Status byte + MapSize byte // padding: 23 bytes + Map []byte // size: xgb.Pad((int(MapSize) * 1)) } -// Reply blocks and returns the reply data for a SetDeviceMode request. -func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { +// Reply blocks and returns the reply data for a GetDeviceButtonMapping request. +func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4973,12 +5133,12 @@ func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { if buf == nil { return nil, nil } - return setDeviceModeReply(buf), nil + return getDeviceButtonMappingReply(buf), nil } -// setDeviceModeReply reads a byte slice into a SetDeviceModeReply value. -func setDeviceModeReply(buf []byte) *SetDeviceModeReply { - v := new(SetDeviceModeReply) +// getDeviceButtonMappingReply reads a byte slice into a GetDeviceButtonMappingReply value. +func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { + v := new(GetDeviceButtonMappingReply) b := 1 // skip reply determinant b += 1 // padding @@ -4989,17 +5149,21 @@ func setDeviceModeReply(buf []byte) *SetDeviceModeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = buf[b] + v.MapSize = buf[b] b += 1 b += 23 // padding + v.Map = make([]byte, v.MapSize) + copy(v.Map[:v.MapSize], buf[b:]) + b += xgb.Pad(int(v.MapSize)) + return v } -// Write request to wire for SetDeviceMode -// setDeviceModeRequest writes a SetDeviceMode request to a byte slice. -func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { +// Write request to wire for GetDeviceButtonMapping +// getDeviceButtonMappingRequest writes a GetDeviceButtonMapping request to a byte slice. +func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -5007,7 +5171,7 @@ func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 28 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5016,121 +5180,146 @@ func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { buf[b] = DeviceId b += 1 - buf[b] = Mode - b += 1 - - b += 2 // padding + b += 3 // padding return buf } -// SelectExtensionEventCookie is a cookie used only for SelectExtensionEvent requests. -type SelectExtensionEventCookie struct { +// GetDeviceControlCookie is a cookie used only for GetDeviceControl requests. +type GetDeviceControlCookie struct { *xgb.Cookie } -// SelectExtensionEvent sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectExtensionEvent(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { +// GetDeviceControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceControlCookie.Reply() +func GetDeviceControl(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SelectExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) - return SelectExtensionEventCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{cookie} } -// SelectExtensionEventChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectExtensionEventCookie.Check() -func SelectExtensionEventChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { +// GetDeviceControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceControlUnchecked(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SelectExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) - return SelectExtensionEventCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{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 SelectExtensionEventCookie) Check() error { - return cook.Cookie.Check() +// GetDeviceControlReply represents the data returned from a GetDeviceControl request. +type GetDeviceControlReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Status byte + // padding: 23 bytes } -// Write request to wire for SelectExtensionEvent -// selectExtensionEventRequest writes a SelectExtensionEvent request to a byte slice. -func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +// Reply blocks and returns the reply data for a GetDeviceControl request. +func (cook GetDeviceControlCookie) Reply() (*GetDeviceControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceControlReply(buf), nil +} + +// getDeviceControlReply reads a byte slice into a GetDeviceControlReply value. +func getDeviceControlReply(buf []byte) *GetDeviceControlReply { + v := new(GetDeviceControlReply) + 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.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for GetDeviceControl +// getDeviceControlRequest writes a GetDeviceControl request to a byte slice. +func getDeviceControlRequest(c *xgb.Conn, ControlId uint16, DeviceId byte) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 34 // 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.Put16(buf[b:], NumClasses) + xgb.Put16(buf[b:], ControlId) b += 2 - b += 2 // padding + buf[b] = DeviceId + b += 1 - for i := 0; i < int(NumClasses); i++ { - xgb.Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = xgb.Pad(b) + b += 1 // padding return buf } -// GetSelectedExtensionEventsCookie is a cookie used only for GetSelectedExtensionEvents requests. -type GetSelectedExtensionEventsCookie struct { +// GetDeviceDontPropagateListCookie is a cookie used only for GetDeviceDontPropagateList requests. +type GetDeviceDontPropagateListCookie struct { *xgb.Cookie } -// GetSelectedExtensionEvents sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectedExtensionEventsCookie.Reply() -func GetSelectedExtensionEvents(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { +// GetDeviceDontPropagateList sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceDontPropagateListCookie.Reply() +func GetDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) - return GetSelectedExtensionEventsCookie{cookie} + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} } -// GetSelectedExtensionEventsUnchecked sends an unchecked request. +// GetDeviceDontPropagateListUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { +func GetDeviceDontPropagateListUnchecked(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) - return GetSelectedExtensionEventsCookie{cookie} + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} } -// GetSelectedExtensionEventsReply represents the data returned from a GetSelectedExtensionEvents request. -type GetSelectedExtensionEventsReply struct { +// GetDeviceDontPropagateListReply represents the data returned from a GetDeviceDontPropagateList request. +type GetDeviceDontPropagateListReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumThisClasses uint16 - NumAllClasses uint16 - // padding: 20 bytes - ThisClasses []EventClass // size: xgb.Pad((int(NumThisClasses) * 4)) - AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) + NumClasses uint16 + // padding: 22 bytes + Classes []EventClass // size: xgb.Pad((int(NumClasses) * 4)) } -// Reply blocks and returns the reply data for a GetSelectedExtensionEvents request. -func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEventsReply, error) { +// Reply blocks and returns the reply data for a GetDeviceDontPropagateList request. +func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5138,12 +5327,12 @@ func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEvent if buf == nil { return nil, nil } - return getSelectedExtensionEventsReply(buf), nil + return getDeviceDontPropagateListReply(buf), nil } -// getSelectedExtensionEventsReply reads a byte slice into a GetSelectedExtensionEventsReply value. -func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { - v := new(GetSelectedExtensionEventsReply) +// getDeviceDontPropagateListReply reads a byte slice into a GetDeviceDontPropagateListReply value. +func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListReply { + v := new(GetDeviceDontPropagateListReply) b := 1 // skip reply determinant b += 1 // padding @@ -5154,24 +5343,14 @@ func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsRepl v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumThisClasses = xgb.Get16(buf[b:]) - b += 2 - - v.NumAllClasses = xgb.Get16(buf[b:]) + v.NumClasses = xgb.Get16(buf[b:]) b += 2 - b += 20 // padding - - v.ThisClasses = make([]EventClass, v.NumThisClasses) - for i := 0; i < int(v.NumThisClasses); i++ { - v.ThisClasses[i] = EventClass(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + b += 22 // padding - v.AllClasses = make([]EventClass, v.NumAllClasses) - for i := 0; i < int(v.NumAllClasses); i++ { - v.AllClasses[i] = EventClass(xgb.Get32(buf[b:])) + v.Classes = make([]EventClass, v.NumClasses) + for i := 0; i < int(v.NumClasses); i++ { + v.Classes[i] = EventClass(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) @@ -5179,9 +5358,9 @@ func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsRepl return v } -// Write request to wire for GetSelectedExtensionEvents -// getSelectedExtensionEventsRequest writes a GetSelectedExtensionEvents request to a byte slice. -func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetDeviceDontPropagateList +// getDeviceDontPropagateListRequest writes a GetDeviceDontPropagateList request to a byte slice. +func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -5189,7 +5368,7 @@ func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5201,114 +5380,251 @@ func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte return buf } -// ChangeDeviceDontPropagateListCookie is a cookie used only for ChangeDeviceDontPropagateList requests. -type ChangeDeviceDontPropagateListCookie struct { +// GetDeviceFocusCookie is a cookie used only for GetDeviceFocus requests. +type GetDeviceFocusCookie struct { *xgb.Cookie } -// ChangeDeviceDontPropagateList sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { +// GetDeviceFocus sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceFocusCookie.Reply() +func GetDeviceFocus(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangeDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) - return ChangeDeviceDontPropagateListCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{cookie} } -// ChangeDeviceDontPropagateListChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeDeviceDontPropagateListCookie.Check() -func ChangeDeviceDontPropagateListChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { +// GetDeviceFocusUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangeDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) - return ChangeDeviceDontPropagateListCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{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 ChangeDeviceDontPropagateListCookie) Check() error { - return cook.Cookie.Check() +// GetDeviceFocusReply represents the data returned from a GetDeviceFocus request. +type GetDeviceFocusReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Focus xproto.Window + Time xproto.Timestamp + RevertTo byte + // padding: 15 bytes } -// Write request to wire for ChangeDeviceDontPropagateList -// changeDeviceDontPropagateListRequest writes a ChangeDeviceDontPropagateList request to a byte slice. -func changeDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +// Reply blocks and returns the reply data for a GetDeviceFocus request. +func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceFocusReply(buf), nil +} + +// getDeviceFocusReply reads a byte slice into a GetDeviceFocusReply value. +func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { + v := new(GetDeviceFocusReply) + 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.Focus = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.RevertTo = buf[b] + b += 1 + + b += 15 // padding + + return v +} + +// Write request to wire for GetDeviceFocus +// getDeviceFocusRequest writes a GetDeviceFocus request to a byte slice. +func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 20 // 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 + buf[b] = DeviceId + b += 1 - xgb.Put16(buf[b:], NumClasses) + b += 3 // padding + + return buf +} + +// GetDeviceKeyMappingCookie is a cookie used only for GetDeviceKeyMapping requests. +type GetDeviceKeyMappingCookie struct { + *xgb.Cookie +} + +// GetDeviceKeyMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceKeyMappingCookie.Reply() +func GetDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +// GetDeviceKeyMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +// GetDeviceKeyMappingReply represents the data returned from a GetDeviceKeyMapping request. +type GetDeviceKeyMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + KeysymsPerKeycode byte + // padding: 23 bytes + Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) +} + +// Reply blocks and returns the reply data for a GetDeviceKeyMapping request. +func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceKeyMappingReply(buf), nil +} + +// getDeviceKeyMappingReply reads a byte slice into a GetDeviceKeyMappingReply value. +func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { + v := new(GetDeviceKeyMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - buf[b] = Mode + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.KeysymsPerKeycode = buf[b] b += 1 - b += 1 // padding + b += 23 // padding - for i := 0; i < int(NumClasses); i++ { - xgb.Put32(buf[b:], uint32(Classes[i])) + v.Keysyms = make([]xproto.Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) + return v +} + +// Write request to wire for GetDeviceKeyMapping +// getDeviceKeyMappingRequest writes a GetDeviceKeyMapping request to a byte slice. +func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + return buf } -// GetDeviceDontPropagateListCookie is a cookie used only for GetDeviceDontPropagateList requests. -type GetDeviceDontPropagateListCookie struct { +// GetDeviceModifierMappingCookie is a cookie used only for GetDeviceModifierMapping requests. +type GetDeviceModifierMappingCookie struct { *xgb.Cookie } -// GetDeviceDontPropagateList sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceDontPropagateListCookie.Reply() -func GetDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { +// GetDeviceModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceModifierMappingCookie.Reply() +func GetDeviceModifierMapping(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceModifierMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) - return GetDeviceDontPropagateListCookie{cookie} + c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} } -// GetDeviceDontPropagateListUnchecked sends an unchecked request. +// GetDeviceModifierMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceDontPropagateListUnchecked(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { +func GetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceModifierMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) - return GetDeviceDontPropagateListCookie{cookie} + c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} } -// GetDeviceDontPropagateListReply represents the data returned from a GetDeviceDontPropagateList request. -type GetDeviceDontPropagateListReply struct { +// GetDeviceModifierMappingReply represents the data returned from a GetDeviceModifierMapping request. +type GetDeviceModifierMappingReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumClasses uint16 - // padding: 22 bytes - Classes []EventClass // size: xgb.Pad((int(NumClasses) * 4)) + KeycodesPerModifier byte + // padding: 23 bytes + Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceDontPropagateList request. -func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateListReply, error) { +// Reply blocks and returns the reply data for a GetDeviceModifierMapping request. +func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5316,12 +5632,12 @@ func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateLis if buf == nil { return nil, nil } - return getDeviceDontPropagateListReply(buf), nil + return getDeviceModifierMappingReply(buf), nil } -// getDeviceDontPropagateListReply reads a byte slice into a GetDeviceDontPropagateListReply value. -func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListReply { - v := new(GetDeviceDontPropagateListReply) +// getDeviceModifierMappingReply reads a byte slice into a GetDeviceModifierMappingReply value. +func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { + v := new(GetDeviceModifierMappingReply) b := 1 // skip reply determinant b += 1 // padding @@ -5332,24 +5648,21 @@ func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListRepl v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumClasses = xgb.Get16(buf[b:]) - b += 2 + v.KeycodesPerModifier = buf[b] + b += 1 - b += 22 // padding + b += 23 // padding - v.Classes = make([]EventClass, v.NumClasses) - for i := 0; i < int(v.NumClasses); i++ { - v.Classes[i] = EventClass(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + v.Keymaps = make([]byte, (int(v.KeycodesPerModifier) * 8)) + copy(v.Keymaps[:(int(v.KeycodesPerModifier)*8)], buf[b:]) + b += xgb.Pad(int((int(v.KeycodesPerModifier) * 8))) return v } -// Write request to wire for GetDeviceDontPropagateList -// getDeviceDontPropagateListRequest writes a GetDeviceDontPropagateList request to a byte slice. -func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetDeviceModifierMapping +// getDeviceModifierMappingRequest writes a GetDeviceModifierMapping request to a byte slice. +func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -5357,14 +5670,16 @@ func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 26 // 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 + buf[b] = DeviceId + b += 1 + + b += 3 // padding return buf } @@ -5474,44 +5789,46 @@ func getDeviceMotionEventsRequest(c *xgb.Conn, Start xproto.Timestamp, Stop xpro return buf } -// ChangeKeyboardDeviceCookie is a cookie used only for ChangeKeyboardDevice requests. -type ChangeKeyboardDeviceCookie struct { +// GetExtensionVersionCookie is a cookie used only for GetExtensionVersion requests. +type GetExtensionVersionCookie struct { *xgb.Cookie } -// ChangeKeyboardDevice sends a checked request. -// If an error occurs, it will be returned with the reply by calling ChangeKeyboardDeviceCookie.Reply() -func ChangeKeyboardDevice(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { +// GetExtensionVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetExtensionVersionCookie.Reply() +func GetExtensionVersion(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangeKeyboardDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetExtensionVersion' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) - return ChangeKeyboardDeviceCookie{cookie} + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{cookie} } -// ChangeKeyboardDeviceUnchecked sends an unchecked request. +// GetExtensionVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeKeyboardDeviceUnchecked(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { +func GetExtensionVersionUnchecked(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangeKeyboardDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetExtensionVersion' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) - return ChangeKeyboardDeviceCookie{cookie} + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{cookie} } -// ChangeKeyboardDeviceReply represents the data returned from a ChangeKeyboardDevice request. -type ChangeKeyboardDeviceReply struct { +// GetExtensionVersionReply represents the data returned from a GetExtensionVersion request. +type GetExtensionVersionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Status byte - // padding: 23 bytes + ServerMajor uint16 + ServerMinor uint16 + Present bool + // padding: 19 bytes } -// Reply blocks and returns the reply data for a ChangeKeyboardDevice request. -func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, error) { +// Reply blocks and returns the reply data for a GetExtensionVersion request. +func (cook GetExtensionVersionCookie) Reply() (*GetExtensionVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5519,12 +5836,12 @@ func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, erro if buf == nil { return nil, nil } - return changeKeyboardDeviceReply(buf), nil + return getExtensionVersionReply(buf), nil } -// changeKeyboardDeviceReply reads a byte slice into a ChangeKeyboardDeviceReply value. -func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { - v := new(ChangeKeyboardDeviceReply) +// getExtensionVersionReply reads a byte slice into a GetExtensionVersionReply value. +func getExtensionVersionReply(buf []byte) *GetExtensionVersionReply { + v := new(GetExtensionVersionReply) b := 1 // skip reply determinant b += 1 // padding @@ -5535,76 +5852,89 @@ func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = buf[b] + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } b += 1 - b += 23 // padding + b += 19 // padding return v } -// Write request to wire for ChangeKeyboardDevice -// changeKeyboardDeviceRequest writes a ChangeKeyboardDevice request to a byte slice. -func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { - size := 8 +// Write request to wire for GetExtensionVersion +// getExtensionVersionRequest writes a GetExtensionVersion request to a byte slice. +func getExtensionVersionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] 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 b += 2 - buf[b] = DeviceId - b += 1 + xgb.Put16(buf[b:], NameLen) + b += 2 - b += 3 // padding + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// ChangePointerDeviceCookie is a cookie used only for ChangePointerDevice requests. -type ChangePointerDeviceCookie struct { +// GetFeedbackControlCookie is a cookie used only for GetFeedbackControl requests. +type GetFeedbackControlCookie struct { *xgb.Cookie } -// ChangePointerDevice sends a checked request. -// If an error occurs, it will be returned with the reply by calling ChangePointerDeviceCookie.Reply() -func ChangePointerDevice(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { +// GetFeedbackControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFeedbackControlCookie.Reply() +func GetFeedbackControl(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangePointerDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetFeedbackControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) - return ChangePointerDeviceCookie{cookie} + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{cookie} } -// ChangePointerDeviceUnchecked sends an unchecked request. +// GetFeedbackControlUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangePointerDeviceUnchecked(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { +func GetFeedbackControlUnchecked(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangePointerDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetFeedbackControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) - return ChangePointerDeviceCookie{cookie} + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{cookie} } -// ChangePointerDeviceReply represents the data returned from a ChangePointerDevice request. -type ChangePointerDeviceReply struct { +// GetFeedbackControlReply represents the data returned from a GetFeedbackControl request. +type GetFeedbackControlReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Status byte - // padding: 23 bytes + NumFeedback uint16 + // padding: 22 bytes } -// Reply blocks and returns the reply data for a ChangePointerDevice request. -func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) { +// Reply blocks and returns the reply data for a GetFeedbackControl request. +func (cook GetFeedbackControlCookie) Reply() (*GetFeedbackControlReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5612,12 +5942,12 @@ func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) if buf == nil { return nil, nil } - return changePointerDeviceReply(buf), nil + return getFeedbackControlReply(buf), nil } -// changePointerDeviceReply reads a byte slice into a ChangePointerDeviceReply value. -func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { - v := new(ChangePointerDeviceReply) +// getFeedbackControlReply reads a byte slice into a GetFeedbackControlReply value. +func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { + v := new(GetFeedbackControlReply) b := 1 // skip reply determinant b += 1 // padding @@ -5628,17 +5958,17 @@ func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = buf[b] - b += 1 + v.NumFeedback = xgb.Get16(buf[b:]) + b += 2 - b += 23 // padding + b += 22 // padding return v } -// Write request to wire for ChangePointerDevice -// changePointerDeviceRequest writes a ChangePointerDevice request to a byte slice. -func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) []byte { +// Write request to wire for GetFeedbackControl +// getFeedbackControlRequest writes a GetFeedbackControl request to a byte slice. +func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -5646,22 +5976,127 @@ func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId by buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 22 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = XAxis + buf[b] = DeviceId b += 1 - buf[b] = YAxis + b += 3 // padding + + return buf +} + +// GetSelectedExtensionEventsCookie is a cookie used only for GetSelectedExtensionEvents requests. +type GetSelectedExtensionEventsCookie struct { + *xgb.Cookie +} + +// GetSelectedExtensionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectedExtensionEventsCookie.Reply() +func GetSelectedExtensionEvents(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +// GetSelectedExtensionEventsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +// GetSelectedExtensionEventsReply represents the data returned from a GetSelectedExtensionEvents request. +type GetSelectedExtensionEventsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumThisClasses uint16 + NumAllClasses uint16 + // padding: 20 bytes + ThisClasses []EventClass // size: xgb.Pad((int(NumThisClasses) * 4)) + AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) +} + +// Reply blocks and returns the reply data for a GetSelectedExtensionEvents request. +func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectedExtensionEventsReply(buf), nil +} + +// getSelectedExtensionEventsReply reads a byte slice into a GetSelectedExtensionEventsReply value. +func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { + v := new(GetSelectedExtensionEventsReply) + 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.NumThisClasses = xgb.Get16(buf[b:]) + b += 2 + + v.NumAllClasses = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.ThisClasses = make([]EventClass, v.NumThisClasses) + for i := 0; i < int(v.NumThisClasses); i++ { + v.ThisClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.AllClasses = make([]EventClass, v.NumAllClasses) + for i := 0; i < int(v.NumAllClasses); i++ { + v.AllClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetSelectedExtensionEvents +// getSelectedExtensionEventsRequest writes a GetSelectedExtensionEvents request to a byte slice. +func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = DeviceId + buf[b] = 7 // request opcode b += 1 - b += 1 // padding + 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 } @@ -5787,61 +6222,90 @@ func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timest return buf } -// UngrabDeviceCookie is a cookie used only for UngrabDevice requests. -type UngrabDeviceCookie struct { +// GrabDeviceButtonCookie is a cookie used only for GrabDeviceButton requests. +type GrabDeviceButtonCookie struct { *xgb.Cookie } -// UngrabDevice sends an unchecked request. +// GrabDeviceButton sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabDevice(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { +func GrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) - return UngrabDeviceCookie{cookie} + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{cookie} } -// UngrabDeviceChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabDeviceCookie.Check() -func UngrabDeviceChecked(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { +// GrabDeviceButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabDeviceButtonCookie.Check() +func GrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) - return UngrabDeviceCookie{cookie} + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{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 UngrabDeviceCookie) Check() error { +func (cook GrabDeviceButtonCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UngrabDevice -// ungrabDeviceRequest writes a UngrabDevice request to a byte slice. -func ungrabDeviceRequest(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) []byte { - size := 12 +// Write request to wire for GrabDeviceButton +// grabDeviceButtonRequest writes a GrabDeviceButton request to a byte slice. +func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 17 // 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(Time)) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - buf[b] = DeviceId + buf[b] = GrabbedDevice + b += 1 + + buf[b] = ModifierDevice + b += 1 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ThisDeviceMode b += 1 + buf[b] = OtherDeviceMode + b += 1 + + buf[b] = Button + b += 1 + + buf[b] = OwnerEvents + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + return buf } @@ -5936,328 +6400,233 @@ func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint return buf } -// UngrabDeviceKeyCookie is a cookie used only for UngrabDeviceKey requests. -type UngrabDeviceKeyCookie struct { +// ListInputDevicesCookie is a cookie used only for ListInputDevices requests. +type ListInputDevicesCookie struct { *xgb.Cookie } -// UngrabDeviceKey sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { +// ListInputDevices sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListInputDevicesCookie.Reply() +func ListInputDevices(c *xgb.Conn) ListInputDevicesCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return UngrabDeviceKeyCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} } -// UngrabDeviceKeyChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabDeviceKeyCookie.Check() -func UngrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { +// ListInputDevicesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return UngrabDeviceKeyCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{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 UngrabDeviceKeyCookie) Check() error { - return cook.Cookie.Check() +// ListInputDevicesReply represents the data returned from a ListInputDevices request. +type ListInputDevicesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + DevicesLen byte + // padding: 23 bytes + Devices []DeviceInfo // size: xgb.Pad((int(DevicesLen) * 8)) } -// Write request to wire for UngrabDeviceKey -// ungrabDeviceKeyRequest writes a UngrabDeviceKey request to a byte slice. -func ungrabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a ListInputDevices request. +func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listInputDevicesReply(buf), nil +} - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 +// listInputDevicesReply reads a byte slice into a ListInputDevicesReply value. +func listInputDevicesReply(buf []byte) *ListInputDevicesReply { + v := new(ListInputDevicesReply) + b := 1 // skip reply determinant - buf[b] = 16 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Key - b += 1 - - buf[b] = GrabbedDevice + v.DevicesLen = buf[b] b += 1 - return buf -} - -// GrabDeviceButtonCookie is a cookie used only for GrabDeviceButton requests. -type GrabDeviceButtonCookie struct { - *xgb.Cookie -} - -// GrabDeviceButton sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return GrabDeviceButtonCookie{cookie} -} + b += 23 // padding -// GrabDeviceButtonChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabDeviceButtonCookie.Check() -func GrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return GrabDeviceButtonCookie{cookie} -} + v.Devices = make([]DeviceInfo, v.DevicesLen) + b += DeviceInfoReadList(buf[b:], v.Devices) -// 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 GrabDeviceButtonCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for GrabDeviceButton -// grabDeviceButtonRequest writes a GrabDeviceButton request to a byte slice. -func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) []byte { - size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +// Write request to wire for ListInputDevices +// listInputDevicesRequest writes a ListInputDevices request to a byte slice. +func listInputDevicesRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 17 // request opcode + 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(GrabWindow)) - b += 4 - - buf[b] = GrabbedDevice - b += 1 - - buf[b] = ModifierDevice - b += 1 - - xgb.Put16(buf[b:], NumClasses) - b += 2 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = OwnerEvents - b += 1 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - xgb.Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// UngrabDeviceButtonCookie is a cookie used only for UngrabDeviceButton requests. -type UngrabDeviceButtonCookie struct { +// OpenDeviceCookie is a cookie used only for OpenDevice requests. +type OpenDeviceCookie struct { *xgb.Cookie } -// UngrabDeviceButton sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { +// OpenDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling OpenDeviceCookie.Reply() +func OpenDevice(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'OpenDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return UngrabDeviceButtonCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{cookie} } -// UngrabDeviceButtonChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabDeviceButtonCookie.Check() -func UngrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { +// OpenDeviceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'OpenDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return UngrabDeviceButtonCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{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 UngrabDeviceButtonCookie) Check() error { - return cook.Cookie.Check() +// OpenDeviceReply represents the data returned from a OpenDevice request. +type OpenDeviceReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumClasses byte + // padding: 23 bytes + ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) } -// Write request to wire for UngrabDeviceButton -// ungrabDeviceButtonRequest writes a UngrabDeviceButton request to a byte slice. -func ungrabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a OpenDevice request. +func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return openDeviceReply(buf), nil +} - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 +// openDeviceReply reads a byte slice into a OpenDeviceReply value. +func openDeviceReply(buf []byte) *OpenDeviceReply { + v := new(OpenDeviceReply) + b := 1 // skip reply determinant - buf[b] = 18 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = GrabbedDevice + v.NumClasses = buf[b] b += 1 - return buf -} - -// AllowDeviceEventsCookie is a cookie used only for AllowDeviceEvents requests. -type AllowDeviceEventsCookie struct { - *xgb.Cookie -} - -// AllowDeviceEvents sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllowDeviceEvents(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'AllowDeviceEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) - return AllowDeviceEventsCookie{cookie} -} + b += 23 // padding -// AllowDeviceEventsChecked sends a checked request. -// If an error occurs, it can be retrieved using AllowDeviceEventsCookie.Check() -func AllowDeviceEventsChecked(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'AllowDeviceEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) - return AllowDeviceEventsCookie{cookie} -} + v.ClassInfo = make([]InputClassInfo, v.NumClasses) + b += InputClassInfoReadList(buf[b:], v.ClassInfo) -// 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 AllowDeviceEventsCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for AllowDeviceEvents -// allowDeviceEventsRequest writes a AllowDeviceEvents request to a byte slice. -func allowDeviceEventsRequest(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) []byte { - size := 12 +// Write request to wire for OpenDevice +// openDeviceRequest writes a OpenDevice request to a byte slice. +func openDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 19 // request opcode + 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(Time)) - b += 4 - - buf[b] = Mode - b += 1 - buf[b] = DeviceId b += 1 + b += 3 // padding + return buf } -// GetDeviceFocusCookie is a cookie used only for GetDeviceFocus requests. -type GetDeviceFocusCookie struct { +// QueryDeviceStateCookie is a cookie used only for QueryDeviceState requests. +type QueryDeviceStateCookie struct { *xgb.Cookie } -// GetDeviceFocus sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceFocusCookie.Reply() -func GetDeviceFocus(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { +// QueryDeviceState sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryDeviceStateCookie.Reply() +func QueryDeviceState(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDeviceState' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) - return GetDeviceFocusCookie{cookie} + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} } -// GetDeviceFocusUnchecked sends an unchecked request. +// QueryDeviceStateUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { +func QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDeviceState' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) - return GetDeviceFocusCookie{cookie} + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} } -// GetDeviceFocusReply represents the data returned from a GetDeviceFocus request. -type GetDeviceFocusReply struct { +// QueryDeviceStateReply represents the data returned from a QueryDeviceState request. +type QueryDeviceStateReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Focus xproto.Window - Time xproto.Timestamp - RevertTo byte - // padding: 15 bytes + NumClasses byte + // padding: 23 bytes } -// Reply blocks and returns the reply data for a GetDeviceFocus request. -func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { +// Reply blocks and returns the reply data for a QueryDeviceState request. +func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -6265,12 +6634,12 @@ func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { if buf == nil { return nil, nil } - return getDeviceFocusReply(buf), nil + return queryDeviceStateReply(buf), nil } -// getDeviceFocusReply reads a byte slice into a GetDeviceFocusReply value. -func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { - v := new(GetDeviceFocusReply) +// queryDeviceStateReply reads a byte slice into a QueryDeviceStateReply value. +func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { + v := new(QueryDeviceStateReply) b := 1 // skip reply determinant b += 1 // padding @@ -6281,23 +6650,17 @@ func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Focus = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.RevertTo = buf[b] + v.NumClasses = buf[b] b += 1 - b += 15 // padding + b += 23 // padding return v } -// Write request to wire for GetDeviceFocus -// getDeviceFocusRequest writes a GetDeviceFocus request to a byte slice. -func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { +// Write request to wire for QueryDeviceState +// queryDeviceStateRequest writes a QueryDeviceState request to a byte slice. +func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -6305,7 +6668,7 @@ func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6319,202 +6682,192 @@ func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// SetDeviceFocusCookie is a cookie used only for SetDeviceFocus requests. -type SetDeviceFocusCookie struct { +// SelectExtensionEventCookie is a cookie used only for SelectExtensionEvent requests. +type SelectExtensionEventCookie struct { *xgb.Cookie } -// SetDeviceFocus sends an unchecked request. +// SelectExtensionEvent sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceFocus(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { +func SelectExtensionEvent(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) - return SetDeviceFocusCookie{cookie} + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{cookie} } -// SetDeviceFocusChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDeviceFocusCookie.Check() -func SetDeviceFocusChecked(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { +// SelectExtensionEventChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectExtensionEventCookie.Check() +func SelectExtensionEventChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) - return SetDeviceFocusCookie{cookie} + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{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 SetDeviceFocusCookie) Check() error { +func (cook SelectExtensionEventCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetDeviceFocus -// setDeviceFocusRequest writes a SetDeviceFocus request to a byte slice. -func setDeviceFocusRequest(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) []byte { - size := 16 +// Write request to wire for SelectExtensionEvent +// selectExtensionEventRequest writes a SelectExtensionEvent request to a byte slice. +func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 21 // request opcode + 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:], uint32(Focus)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 + xgb.Put16(buf[b:], NumClasses) + b += 2 - buf[b] = RevertTo - b += 1 + b += 2 // padding - buf[b] = DeviceId - b += 1 + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) return buf } -// GetFeedbackControlCookie is a cookie used only for GetFeedbackControl requests. -type GetFeedbackControlCookie struct { +// SendExtensionEventCookie is a cookie used only for SendExtensionEvent requests. +type SendExtensionEventCookie struct { *xgb.Cookie } -// GetFeedbackControl sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetFeedbackControlCookie.Reply() -func GetFeedbackControl(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { +// SendExtensionEvent sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SendExtensionEvent(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetFeedbackControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SendExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) - return GetFeedbackControlCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) + return SendExtensionEventCookie{cookie} } -// GetFeedbackControlUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetFeedbackControlUnchecked(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { +// SendExtensionEventChecked sends a checked request. +// If an error occurs, it can be retrieved using SendExtensionEventCookie.Check() +func SendExtensionEventChecked(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetFeedbackControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SendExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) - return GetFeedbackControlCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) + return SendExtensionEventCookie{cookie} } -// GetFeedbackControlReply represents the data returned from a GetFeedbackControl request. -type GetFeedbackControlReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumFeedback uint16 - // padding: 22 bytes +// 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 SendExtensionEventCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetFeedbackControl request. -func (cook GetFeedbackControlCookie) Reply() (*GetFeedbackControlReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getFeedbackControlReply(buf), nil -} +// Write request to wire for SendExtensionEvent +// sendExtensionEventRequest writes a SendExtensionEvent request to a byte slice. +func sendExtensionEventRequest(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) []byte { + size := xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) -// getFeedbackControlReply reads a byte slice into a GetFeedbackControlReply value. -func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { - v := new(GetFeedbackControlReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 - b += 1 // padding + buf[b] = 31 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - v.NumFeedback = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -// Write request to wire for GetFeedbackControl -// getFeedbackControlRequest writes a GetFeedbackControl request to a byte slice. -func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] + buf[b] = DeviceId b += 1 - buf[b] = 22 // request opcode + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], NumClasses) b += 2 - buf[b] = DeviceId + buf[b] = NumEvents b += 1 b += 3 // padding + copy(buf[b:], Events[:(int(NumEvents)*32)]) + b += xgb.Pad(int((int(NumEvents) * 32))) + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + return buf } -// GetDeviceKeyMappingCookie is a cookie used only for GetDeviceKeyMapping requests. -type GetDeviceKeyMappingCookie struct { +// SetDeviceButtonMappingCookie is a cookie used only for SetDeviceButtonMapping requests. +type SetDeviceButtonMappingCookie struct { *xgb.Cookie } -// GetDeviceKeyMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceKeyMappingCookie.Reply() -func GetDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { +// SetDeviceButtonMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceButtonMappingCookie.Reply() +func SetDeviceButtonMapping(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) - return GetDeviceKeyMappingCookie{cookie} + c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) + return SetDeviceButtonMappingCookie{cookie} } -// GetDeviceKeyMappingUnchecked sends an unchecked request. +// SetDeviceButtonMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { +func SetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) - return GetDeviceKeyMappingCookie{cookie} + c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) + return SetDeviceButtonMappingCookie{cookie} } -// GetDeviceKeyMappingReply represents the data returned from a GetDeviceKeyMapping request. -type GetDeviceKeyMappingReply struct { +// SetDeviceButtonMappingReply represents the data returned from a SetDeviceButtonMapping request. +type SetDeviceButtonMappingReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - KeysymsPerKeycode byte + Status byte // padding: 23 bytes - Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a GetDeviceKeyMapping request. -func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { +// Reply blocks and returns the reply data for a SetDeviceButtonMapping request. +func (cook SetDeviceButtonMappingCookie) Reply() (*SetDeviceButtonMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -6522,12 +6875,12 @@ func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) if buf == nil { return nil, nil } - return getDeviceKeyMappingReply(buf), nil + return setDeviceButtonMappingReply(buf), nil } -// getDeviceKeyMappingReply reads a byte slice into a GetDeviceKeyMappingReply value. -func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { - v := new(GetDeviceKeyMappingReply) +// setDeviceButtonMappingReply reads a byte slice into a SetDeviceButtonMappingReply value. +func setDeviceButtonMappingReply(buf []byte) *SetDeviceButtonMappingReply { + v := new(SetDeviceButtonMappingReply) b := 1 // skip reply determinant b += 1 // padding @@ -6538,32 +6891,25 @@ func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.KeysymsPerKeycode = buf[b] + v.Status = buf[b] b += 1 b += 23 // padding - v.Keysyms = make([]xproto.Keysym, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - return v } -// Write request to wire for GetDeviceKeyMapping -// getDeviceKeyMappingRequest writes a GetDeviceKeyMapping request to a byte slice. -func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) []byte { - size := 8 +// Write request to wire for SetDeviceButtonMapping +// setDeviceButtonMappingRequest writes a SetDeviceButtonMapping request to a byte slice. +func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 24 // request opcode + buf[b] = 29 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6572,124 +6918,119 @@ func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode buf[b] = DeviceId b += 1 - buf[b] = byte(FirstKeycode) + buf[b] = MapSize b += 1 - buf[b] = Count - b += 1 + b += 2 // padding + + copy(buf[b:], Map[:MapSize]) + b += xgb.Pad(int(MapSize)) return buf } -// ChangeDeviceKeyMappingCookie is a cookie used only for ChangeDeviceKeyMapping requests. -type ChangeDeviceKeyMappingCookie struct { +// SetDeviceFocusCookie is a cookie used only for SetDeviceFocus requests. +type SetDeviceFocusCookie struct { *xgb.Cookie } -// ChangeDeviceKeyMapping sends an unchecked request. +// SetDeviceFocus sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { +func SetDeviceFocus(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangeDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) - return ChangeDeviceKeyMappingCookie{cookie} + c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) + return SetDeviceFocusCookie{cookie} } -// ChangeDeviceKeyMappingChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeDeviceKeyMappingCookie.Check() -func ChangeDeviceKeyMappingChecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { +// SetDeviceFocusChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceFocusCookie.Check() +func SetDeviceFocusChecked(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ChangeDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) - return ChangeDeviceKeyMappingCookie{cookie} + c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) + return SetDeviceFocusCookie{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 ChangeDeviceKeyMappingCookie) Check() error { +func (cook SetDeviceFocusCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeDeviceKeyMapping -// changeDeviceKeyMappingRequest writes a ChangeDeviceKeyMapping request to a byte slice. -func changeDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) []byte { - size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +// Write request to wire for SetDeviceFocus +// setDeviceFocusRequest writes a SetDeviceFocus request to a byte slice. +func setDeviceFocusRequest(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 25 // request opcode + buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = DeviceId - b += 1 + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 - buf[b] = byte(FirstKeycode) - b += 1 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 - buf[b] = KeysymsPerKeycode + buf[b] = RevertTo b += 1 - buf[b] = KeycodeCount + buf[b] = DeviceId b += 1 - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - xgb.Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// GetDeviceModifierMappingCookie is a cookie used only for GetDeviceModifierMapping requests. -type GetDeviceModifierMappingCookie struct { +// SetDeviceModeCookie is a cookie used only for SetDeviceMode requests. +type SetDeviceModeCookie struct { *xgb.Cookie } -// GetDeviceModifierMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceModifierMappingCookie.Reply() -func GetDeviceModifierMapping(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { +// SetDeviceMode sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceModeCookie.Reply() +func SetDeviceMode(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceModifierMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceMode' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) - return GetDeviceModifierMappingCookie{cookie} + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} } -// GetDeviceModifierMappingUnchecked sends an unchecked request. +// SetDeviceModeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { +func SetDeviceModeUnchecked(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceModifierMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceMode' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) - return GetDeviceModifierMappingCookie{cookie} + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} } -// GetDeviceModifierMappingReply represents the data returned from a GetDeviceModifierMapping request. -type GetDeviceModifierMappingReply struct { +// SetDeviceModeReply represents the data returned from a SetDeviceMode request. +type SetDeviceModeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - KeycodesPerModifier byte + Status byte // padding: 23 bytes - Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceModifierMapping request. -func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { +// Reply blocks and returns the reply data for a SetDeviceMode request. +func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -6697,12 +7038,12 @@ func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingRep if buf == nil { return nil, nil } - return getDeviceModifierMappingReply(buf), nil + return setDeviceModeReply(buf), nil } -// getDeviceModifierMappingReply reads a byte slice into a GetDeviceModifierMappingReply value. -func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { - v := new(GetDeviceModifierMappingReply) +// setDeviceModeReply reads a byte slice into a SetDeviceModeReply value. +func setDeviceModeReply(buf []byte) *SetDeviceModeReply { + v := new(SetDeviceModeReply) b := 1 // skip reply determinant b += 1 // padding @@ -6713,21 +7054,17 @@ func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.KeycodesPerModifier = buf[b] + v.Status = buf[b] b += 1 b += 23 // padding - v.Keymaps = make([]byte, (int(v.KeycodesPerModifier) * 8)) - copy(v.Keymaps[:(int(v.KeycodesPerModifier)*8)], buf[b:]) - b += xgb.Pad(int((int(v.KeycodesPerModifier) * 8))) - return v } -// Write request to wire for GetDeviceModifierMapping -// getDeviceModifierMappingRequest writes a GetDeviceModifierMapping request to a byte slice. -func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { +// Write request to wire for SetDeviceMode +// setDeviceModeRequest writes a SetDeviceMode request to a byte slice. +func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -6735,7 +7072,7 @@ func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6744,7 +7081,10 @@ func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = DeviceId b += 1 - b += 3 // padding + buf[b] = Mode + b += 1 + + b += 2 // padding return buf } @@ -6848,133 +7188,35 @@ func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModi return buf } -// GetDeviceButtonMappingCookie is a cookie used only for GetDeviceButtonMapping requests. -type GetDeviceButtonMappingCookie struct { - *xgb.Cookie -} - -// GetDeviceButtonMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceButtonMappingCookie.Reply() -func GetDeviceButtonMapping(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) - return GetDeviceButtonMappingCookie{cookie} -} - -// GetDeviceButtonMappingUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) - return GetDeviceButtonMappingCookie{cookie} -} - -// GetDeviceButtonMappingReply represents the data returned from a GetDeviceButtonMapping request. -type GetDeviceButtonMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MapSize byte - // padding: 23 bytes - Map []byte // size: xgb.Pad((int(MapSize) * 1)) -} - -// Reply blocks and returns the reply data for a GetDeviceButtonMapping request. -func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDeviceButtonMappingReply(buf), nil -} - -// getDeviceButtonMappingReply reads a byte slice into a GetDeviceButtonMappingReply value. -func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { - v := new(GetDeviceButtonMappingReply) - 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.MapSize = buf[b] - b += 1 - - b += 23 // padding - - v.Map = make([]byte, v.MapSize) - copy(v.Map[:v.MapSize], buf[b:]) - b += xgb.Pad(int(v.MapSize)) - - return v -} - -// Write request to wire for GetDeviceButtonMapping -// getDeviceButtonMappingRequest writes a GetDeviceButtonMapping request to a byte slice. -func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// SetDeviceButtonMappingCookie is a cookie used only for SetDeviceButtonMapping requests. -type SetDeviceButtonMappingCookie struct { +// SetDeviceValuatorsCookie is a cookie used only for SetDeviceValuators requests. +type SetDeviceValuatorsCookie struct { *xgb.Cookie } -// SetDeviceButtonMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetDeviceButtonMappingCookie.Reply() -func SetDeviceButtonMapping(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { +// SetDeviceValuators sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceValuatorsCookie.Reply() +func SetDeviceValuators(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceValuators' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) - return SetDeviceButtonMappingCookie{cookie} + c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) + return SetDeviceValuatorsCookie{cookie} } -// SetDeviceButtonMappingUnchecked sends an unchecked request. +// SetDeviceValuatorsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { +func SetDeviceValuatorsUnchecked(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceValuators' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) - return SetDeviceButtonMappingCookie{cookie} + c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) + return SetDeviceValuatorsCookie{cookie} } -// SetDeviceButtonMappingReply represents the data returned from a SetDeviceButtonMapping request. -type SetDeviceButtonMappingReply struct { +// SetDeviceValuatorsReply represents the data returned from a SetDeviceValuators request. +type SetDeviceValuatorsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -6982,8 +7224,8 @@ type SetDeviceButtonMappingReply struct { // padding: 23 bytes } -// Reply blocks and returns the reply data for a SetDeviceButtonMapping request. -func (cook SetDeviceButtonMappingCookie) Reply() (*SetDeviceButtonMappingReply, error) { +// Reply blocks and returns the reply data for a SetDeviceValuators request. +func (cook SetDeviceValuatorsCookie) Reply() (*SetDeviceValuatorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -6991,12 +7233,12 @@ func (cook SetDeviceButtonMappingCookie) Reply() (*SetDeviceButtonMappingReply, if buf == nil { return nil, nil } - return setDeviceButtonMappingReply(buf), nil + return setDeviceValuatorsReply(buf), nil } -// setDeviceButtonMappingReply reads a byte slice into a SetDeviceButtonMappingReply value. -func setDeviceButtonMappingReply(buf []byte) *SetDeviceButtonMappingReply { - v := new(SetDeviceButtonMappingReply) +// setDeviceValuatorsReply reads a byte slice into a SetDeviceValuatorsReply value. +func setDeviceValuatorsReply(buf []byte) *SetDeviceValuatorsReply { + v := new(SetDeviceValuatorsReply) b := 1 // skip reply determinant b += 1 // padding @@ -7015,17 +7257,17 @@ func setDeviceButtonMappingReply(buf []byte) *SetDeviceButtonMappingReply { return v } -// Write request to wire for SetDeviceButtonMapping -// setDeviceButtonMappingRequest writes a SetDeviceButtonMapping request to a byte slice. -func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) []byte { - size := xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) +// Write request to wire for SetDeviceValuators +// setDeviceValuatorsRequest writes a SetDeviceValuators request to a byte slice. +func setDeviceValuatorsRequest(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 29 // request opcode + buf[b] = 33 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7034,453 +7276,211 @@ func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map buf[b] = DeviceId b += 1 - buf[b] = MapSize - b += 1 - - b += 2 // padding - - copy(buf[b:], Map[:MapSize]) - b += xgb.Pad(int(MapSize)) - - return buf -} - -// QueryDeviceStateCookie is a cookie used only for QueryDeviceState requests. -type QueryDeviceStateCookie struct { - *xgb.Cookie -} - -// QueryDeviceState sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryDeviceStateCookie.Reply() -func QueryDeviceState(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'QueryDeviceState' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) - return QueryDeviceStateCookie{cookie} -} - -// QueryDeviceStateUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'QueryDeviceState' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) - return QueryDeviceStateCookie{cookie} -} - -// QueryDeviceStateReply represents the data returned from a QueryDeviceState request. -type QueryDeviceStateReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumClasses byte - // padding: 23 bytes -} - -// Reply blocks and returns the reply data for a QueryDeviceState request. -func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryDeviceStateReply(buf), nil -} - -// queryDeviceStateReply reads a byte slice into a QueryDeviceStateReply value. -func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { - v := new(QueryDeviceStateReply) - 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.NumClasses = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -// Write request to wire for QueryDeviceState -// queryDeviceStateRequest writes a QueryDeviceState request to a byte slice. -func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] + buf[b] = FirstValuator b += 1 - buf[b] = 30 // request opcode + buf[b] = NumValuators b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 + b += 1 // padding - b += 3 // padding + for i := 0; i < int(NumValuators); i++ { + xgb.Put32(buf[b:], uint32(Valuators[i])) + b += 4 + } + b = xgb.Pad(b) return buf } -// SendExtensionEventCookie is a cookie used only for SendExtensionEvent requests. -type SendExtensionEventCookie struct { +// UngrabDeviceCookie is a cookie used only for UngrabDevice requests. +type UngrabDeviceCookie struct { *xgb.Cookie } -// SendExtensionEvent sends an unchecked request. +// UngrabDevice sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SendExtensionEvent(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { +func UngrabDevice(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SendExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'UngrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) - return SendExtensionEventCookie{cookie} + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{cookie} } -// SendExtensionEventChecked sends a checked request. -// If an error occurs, it can be retrieved using SendExtensionEventCookie.Check() -func SendExtensionEventChecked(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { +// UngrabDeviceChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabDeviceCookie.Check() +func UngrabDeviceChecked(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SendExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'UngrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) - return SendExtensionEventCookie{cookie} + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{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 SendExtensionEventCookie) Check() error { +func (cook UngrabDeviceCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SendExtensionEvent -// sendExtensionEventRequest writes a SendExtensionEvent request to a byte slice. -func sendExtensionEventRequest(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) []byte { - size := xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) +// Write request to wire for UngrabDevice +// ungrabDeviceRequest writes a UngrabDevice request to a byte slice. +func ungrabDeviceRequest(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 31 // request opcode + buf[b] = 14 // 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(Destination)) + xgb.Put32(buf[b:], uint32(Time)) b += 4 buf[b] = DeviceId b += 1 - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = NumEvents - b += 1 - - b += 3 // padding - - copy(buf[b:], Events[:(int(NumEvents)*32)]) - b += xgb.Pad(int((int(NumEvents) * 32))) - - for i := 0; i < int(NumClasses); i++ { - xgb.Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// DeviceBellCookie is a cookie used only for DeviceBell requests. -type DeviceBellCookie struct { +// UngrabDeviceButtonCookie is a cookie used only for UngrabDeviceButton requests. +type UngrabDeviceButtonCookie struct { *xgb.Cookie } -// DeviceBell sends an unchecked request. +// UngrabDeviceButton sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeviceBell(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { +func UngrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'DeviceBell' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return DeviceBellCookie{cookie} + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{cookie} } -// DeviceBellChecked sends a checked request. -// If an error occurs, it can be retrieved using DeviceBellCookie.Check() -func DeviceBellChecked(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { +// UngrabDeviceButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabDeviceButtonCookie.Check() +func UngrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'DeviceBell' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return DeviceBellCookie{cookie} + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{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 DeviceBellCookie) Check() error { +func (cook UngrabDeviceButtonCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DeviceBell -// deviceBellRequest writes a DeviceBell request to a byte slice. -func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { - size := 8 +// Write request to wire for UngrabDeviceButton +// ungrabDeviceButtonRequest writes a UngrabDeviceButton request to a byte slice. +func ungrabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 32 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = DeviceId - b += 1 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 - buf[b] = FeedbackId + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice b += 1 - buf[b] = FeedbackClass + buf[b] = Button b += 1 - buf[b] = byte(Percent) + buf[b] = GrabbedDevice b += 1 return buf } -// SetDeviceValuatorsCookie is a cookie used only for SetDeviceValuators requests. -type SetDeviceValuatorsCookie struct { +// UngrabDeviceKeyCookie is a cookie used only for UngrabDeviceKey requests. +type UngrabDeviceKeyCookie struct { *xgb.Cookie } -// SetDeviceValuators sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetDeviceValuatorsCookie.Reply() -func SetDeviceValuators(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceValuators' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) - return SetDeviceValuatorsCookie{cookie} -} - -// SetDeviceValuatorsUnchecked sends an unchecked request. +// UngrabDeviceKey sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceValuatorsUnchecked(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { +func UngrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceValuators' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'UngrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) - return SetDeviceValuatorsCookie{cookie} -} - -// SetDeviceValuatorsReply represents the data returned from a SetDeviceValuators request. -type SetDeviceValuatorsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Status byte - // padding: 23 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) + return UngrabDeviceKeyCookie{cookie} } -// Reply blocks and returns the reply data for a SetDeviceValuators request. -func (cook SetDeviceValuatorsCookie) Reply() (*SetDeviceValuatorsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// UngrabDeviceKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabDeviceKeyCookie.Check() +func UngrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'UngrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - return setDeviceValuatorsReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) + return UngrabDeviceKeyCookie{cookie} } -// setDeviceValuatorsReply reads a byte slice into a SetDeviceValuatorsReply value. -func setDeviceValuatorsReply(buf []byte) *SetDeviceValuatorsReply { - v := new(SetDeviceValuatorsReply) - 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.Status = buf[b] - b += 1 - - b += 23 // padding - - 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 UngrabDeviceKeyCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for SetDeviceValuators -// setDeviceValuatorsRequest writes a SetDeviceValuators request to a byte slice. -func setDeviceValuatorsRequest(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) []byte { - size := xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) +// Write request to wire for UngrabDeviceKey +// ungrabDeviceKeyRequest writes a UngrabDeviceKey request to a byte slice. +func ungrabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 33 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = DeviceId - b += 1 - - buf[b] = FirstValuator - b += 1 - - buf[b] = NumValuators - b += 1 - - b += 1 // padding - - for i := 0; i < int(NumValuators); i++ { - xgb.Put32(buf[b:], uint32(Valuators[i])) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// GetDeviceControlCookie is a cookie used only for GetDeviceControl requests. -type GetDeviceControlCookie struct { - *xgb.Cookie -} - -// GetDeviceControl sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceControlCookie.Reply() -func GetDeviceControl(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) - return GetDeviceControlCookie{cookie} -} - -// GetDeviceControlUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceControlUnchecked(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) - return GetDeviceControlCookie{cookie} -} - -// GetDeviceControlReply represents the data returned from a GetDeviceControl request. -type GetDeviceControlReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Reply blocks and returns the reply data for a GetDeviceControl request. -func (cook GetDeviceControlCookie) Reply() (*GetDeviceControlReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDeviceControlReply(buf), nil -} - -// getDeviceControlReply reads a byte slice into a GetDeviceControlReply value. -func getDeviceControlReply(buf []byte) *GetDeviceControlReply { - v := new(GetDeviceControlReply) - 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 + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -// Write request to wire for GetDeviceControl -// getDeviceControlRequest writes a GetDeviceControl request to a byte slice. -func getDeviceControlRequest(c *xgb.Conn, ControlId uint16, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], Modifiers) + b += 2 - buf[b] = c.Extensions["XINPUTEXTENSION"] + buf[b] = ModifierDevice b += 1 - buf[b] = 34 // request opcode + buf[b] = Key b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], ControlId) - b += 2 - - buf[b] = DeviceId + buf[b] = GrabbedDevice b += 1 - b += 1 // padding - return buf } diff --git a/nexgb/xprint/xprint.go b/nexgb/xprint/xprint.go index 54fb065..8dfc660 100644 --- a/nexgb/xprint/xprint.go +++ b/nexgb/xprint/xprint.go @@ -2,7 +2,7 @@ package xprint /* - This file was generated by xprint.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xprint.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,50 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XpExtension"] = make(map[int]xgb.NewErrorFun) } -// 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' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -const ( - GetDocFinished = 0 - GetDocSecondConsumer = 1 -) - -const ( - EvMaskNoEventMask = 0 - EvMaskPrintMask = 1 - EvMaskAttributeMask = 2 -) - -const ( - DetailStartJobNotify = 1 - DetailEndJobNotify = 2 - DetailStartDocNotify = 3 - DetailEndDocNotify = 4 - DetailStartPageNotify = 5 - DetailEndPageNotify = 6 -) - const ( AttrJobAttr = 1 AttrDocAttr = 2 @@ -94,191 +50,6 @@ const ( AttrSpoolerAttr = 7 ) -type Pcontext uint32 - -func NewPcontextId(c *xgb.Conn) (Pcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pcontext(id), nil -} - -type String8 byte - -type Printer struct { - NameLen uint32 - Name []String8 // size: xgb.Pad((int(NameLen) * 1)) - DescLen uint32 - Description []String8 // size: xgb.Pad((int(DescLen) * 1)) -} - -// PrinterRead reads a byte slice into a Printer value. -func PrinterRead(buf []byte, v *Printer) int { - b := 0 - - v.NameLen = xgb.Get32(buf[b:]) - b += 4 - - v.Name = make([]String8, v.NameLen) - for i := 0; i < int(v.NameLen); i++ { - v.Name[i] = String8(buf[b]) - b += 1 - } - b = xgb.Pad(b) - - v.DescLen = xgb.Get32(buf[b:]) - b += 4 - - v.Description = make([]String8, v.DescLen) - for i := 0; i < int(v.DescLen); i++ { - v.Description[i] = String8(buf[b]) - b += 1 - } - b = xgb.Pad(b) - - return b -} - -// PrinterReadList reads a byte slice into a list of Printer values. -func PrinterReadList(buf []byte, dest []Printer) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Printer{} - b += PrinterRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Printer value to a byte slice. -func (v Printer) Bytes() []byte { - buf := make([]byte, (((4 + xgb.Pad((int(v.NameLen) * 1))) + 4) + xgb.Pad((int(v.DescLen) * 1)))) - b := 0 - - xgb.Put32(buf[b:], v.NameLen) - b += 4 - - for i := 0; i < int(v.NameLen); i++ { - buf[b] = byte(v.Name[i]) - b += 1 - } - b = xgb.Pad(b) - - xgb.Put32(buf[b:], v.DescLen) - b += 4 - - for i := 0; i < int(v.DescLen); i++ { - buf[b] = byte(v.Description[i]) - b += 1 - } - b = xgb.Pad(b) - - return buf -} - -// PrinterListBytes writes a list of Printer values to a byte slice. -func PrinterListBytes(buf []byte, list []Printer) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// PrinterListSize computes the size (bytes) of a list of Printer values. -func PrinterListSize(list []Printer) int { - size := 0 - for _, item := range list { - size += (((4 + xgb.Pad((int(item.NameLen) * 1))) + 4) + xgb.Pad((int(item.DescLen) * 1))) - } - return size -} - -// Notify is the event number for a NotifyEvent. -const Notify = 0 - -type NotifyEvent struct { - Sequence uint16 - Detail byte - Context Pcontext - Cancel bool -} - -// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. -func NotifyEventNew(buf []byte) xgb.Event { - v := NotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Context = Pcontext(xgb.Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.Cancel = true - } else { - v.Cancel = false - } - b += 1 - - return v -} - -// Bytes writes a NotifyEvent value to a byte slice. -func (v NotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Context)) - b += 4 - - if v.Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// SequenceId returns the sequence id attached to the Notify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v NotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of NotifyEvent. -func (v NotifyEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Context: %d", v.Context)) - fieldVals = append(fieldVals, xgb.Sprintf("Cancel: %t", v.Cancel)) - return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XpExtension"][0] = NotifyEventNew -} - // AttributNotify is the event number for a AttributNotifyEvent. const AttributNotify = 1 @@ -437,198 +208,181 @@ func init() { xgb.NewExtErrorFuncs["XpExtension"][1] = BadSequenceErrorNew } -// PrintQueryVersionCookie is a cookie used only for PrintQueryVersion requests. -type PrintQueryVersionCookie struct { - *xgb.Cookie -} +const ( + DetailStartJobNotify = 1 + DetailEndJobNotify = 2 + DetailStartDocNotify = 3 + DetailEndDocNotify = 4 + DetailStartPageNotify = 5 + DetailEndPageNotify = 6 +) -// PrintQueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintQueryVersionCookie.Reply() -func PrintQueryVersion(c *xgb.Conn) PrintQueryVersionCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintQueryVersion' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(printQueryVersionRequest(c), cookie) - return PrintQueryVersionCookie{cookie} -} +const ( + EvMaskNoEventMask = 0 + EvMaskPrintMask = 1 + EvMaskAttributeMask = 2 +) -// PrintQueryVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintQueryVersionUnchecked(c *xgb.Conn) PrintQueryVersionCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintQueryVersion' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(printQueryVersionRequest(c), cookie) - return PrintQueryVersionCookie{cookie} -} +const ( + GetDocFinished = 0 + GetDocSecondConsumer = 1 +) -// PrintQueryVersionReply represents the data returned from a PrintQueryVersion request. -type PrintQueryVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} +// Notify is the event number for a NotifyEvent. +const Notify = 0 -// Reply blocks and returns the reply data for a PrintQueryVersion request. -func (cook PrintQueryVersionCookie) Reply() (*PrintQueryVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return printQueryVersionReply(buf), nil +type NotifyEvent struct { + Sequence uint16 + Detail byte + Context Pcontext + Cancel bool } -// printQueryVersionReply reads a byte slice into a PrintQueryVersionReply value. -func printQueryVersionReply(buf []byte) *PrintQueryVersionReply { - v := new(PrintQueryVersionReply) - b := 1 // skip reply determinant +// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number - b += 1 // padding + v.Detail = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + v.Context = Pcontext(xgb.Get32(buf[b:])) b += 4 - v.MajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 + if buf[b] == 1 { + v.Cancel = true + } else { + v.Cancel = false + } + b += 1 return v } -// Write request to wire for PrintQueryVersion -// printQueryVersionRequest writes a PrintQueryVersion request to a byte slice. -func printQueryVersionRequest(c *xgb.Conn) []byte { - size := 4 +// Bytes writes a NotifyEvent value to a byte slice. +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf := make([]byte, size) - buf[b] = c.Extensions["XPEXTENSION"] + // write event number + buf[b] = 0 b += 1 - buf[b] = 0 // request opcode + buf[b] = v.Detail b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Context)) + b += 4 + + if v.Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 return buf } -// PrintGetPrinterListCookie is a cookie used only for PrintGetPrinterList requests. -type PrintGetPrinterListCookie struct { - *xgb.Cookie +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence } -// PrintGetPrinterList sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetPrinterListCookie.Reply() -func PrintGetPrinterList(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return PrintGetPrinterListCookie{cookie} +// String is a rudimentary string representation of NotifyEvent. +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Context: %d", v.Context)) + fieldVals = append(fieldVals, xgb.Sprintf("Cancel: %t", v.Cancel)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// PrintGetPrinterListUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetPrinterListUnchecked(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return PrintGetPrinterListCookie{cookie} +func init() { + xgb.NewExtEventFuncs["XpExtension"][0] = NotifyEventNew } -// PrintGetPrinterListReply represents the data returned from a PrintGetPrinterList request. -type PrintGetPrinterListReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ListCount uint32 - // padding: 20 bytes - Printers []Printer // size: PrinterListSize(Printers) -} +type Pcontext uint32 -// Reply blocks and returns the reply data for a PrintGetPrinterList request. -func (cook PrintGetPrinterListCookie) Reply() (*PrintGetPrinterListReply, error) { - buf, err := cook.Cookie.Reply() +func NewPcontextId(c *xgb.Conn) (Pcontext, error) { + id, err := c.NewId() if err != nil { - return nil, err - } - if buf == nil { - return nil, nil + return 0, err } - return printGetPrinterListReply(buf), nil + return Pcontext(id), nil } -// printGetPrinterListReply reads a byte slice into a PrintGetPrinterListReply value. -func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { - v := new(PrintGetPrinterListReply) - b := 1 // skip reply determinant - - b += 1 // padding +type Printer struct { + NameLen uint32 + Name []String8 // size: xgb.Pad((int(NameLen) * 1)) + DescLen uint32 + Description []String8 // size: xgb.Pad((int(DescLen) * 1)) +} - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// PrinterRead reads a byte slice into a Printer value. +func PrinterRead(buf []byte, v *Printer) int { + b := 0 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + v.NameLen = xgb.Get32(buf[b:]) b += 4 - v.ListCount = xgb.Get32(buf[b:]) - b += 4 + v.Name = make([]String8, v.NameLen) + for i := 0; i < int(v.NameLen); i++ { + v.Name[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) - b += 20 // padding + v.DescLen = xgb.Get32(buf[b:]) + b += 4 - v.Printers = make([]Printer, v.ListCount) - b += PrinterReadList(buf[b:], v.Printers) + v.Description = make([]String8, v.DescLen) + for i := 0; i < int(v.DescLen); i++ { + v.Description[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) - return v + return b } -// Write request to wire for PrintGetPrinterList -// printGetPrinterListRequest writes a PrintGetPrinterList request to a byte slice. -func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { - size := xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +// PrinterReadList reads a byte slice into a list of Printer values. +func PrinterReadList(buf []byte, dest []Printer) int { b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - 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 + for i := 0; i < len(dest); i++ { + dest[i] = Printer{} + b += PrinterRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - xgb.Put32(buf[b:], PrinterNameLen) - b += 4 +// Bytes writes a Printer value to a byte slice. +func (v Printer) Bytes() []byte { + buf := make([]byte, (((4 + xgb.Pad((int(v.NameLen) * 1))) + 4) + xgb.Pad((int(v.DescLen) * 1)))) + b := 0 - xgb.Put32(buf[b:], LocaleLen) + xgb.Put32(buf[b:], v.NameLen) b += 4 - for i := 0; i < int(PrinterNameLen); i++ { - buf[b] = byte(PrinterName[i]) + for i := 0; i < int(v.NameLen); i++ { + buf[b] = byte(v.Name[i]) b += 1 } b = xgb.Pad(b) - for i := 0; i < int(LocaleLen); i++ { - buf[b] = byte(Locale[i]) + xgb.Put32(buf[b:], v.DescLen) + b += 4 + + for i := 0; i < int(v.DescLen); i++ { + buf[b] = byte(v.Description[i]) b += 1 } b = xgb.Pad(b) @@ -636,57 +390,52 @@ func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen ui return buf } -// PrintRehashPrinterListCookie is a cookie used only for PrintRehashPrinterList requests. -type PrintRehashPrinterListCookie struct { - *xgb.Cookie -} - -// PrintRehashPrinterList sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintRehashPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") +// PrinterListBytes writes a list of Printer values to a byte slice. +func PrinterListBytes(buf []byte, list []Printer) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } - cookie := c.NewCookie(false, false) - c.NewRequest(printRehashPrinterListRequest(c), cookie) - return PrintRehashPrinterListCookie{cookie} + return b } -// PrintRehashPrinterListChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintRehashPrinterListCookie.Check() -func PrintRehashPrinterListChecked(c *xgb.Conn) PrintRehashPrinterListCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintRehashPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") +// PrinterListSize computes the size (bytes) of a list of Printer values. +func PrinterListSize(list []Printer) int { + size := 0 + for _, item := range list { + size += (((4 + xgb.Pad((int(item.NameLen) * 1))) + 4) + xgb.Pad((int(item.DescLen) * 1))) } - cookie := c.NewCookie(true, false) - c.NewRequest(printRehashPrinterListRequest(c), cookie) - return PrintRehashPrinterListCookie{cookie} + return size } -// 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 PrintRehashPrinterListCookie) Check() error { - return cook.Cookie.Check() -} +type String8 byte -// Write request to wire for PrintRehashPrinterList -// printRehashPrinterListRequest writes a PrintRehashPrinterList request to a byte slice. -func printRehashPrinterListRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Bool' - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 +// Skipping definition for base type 'Byte' - buf[b] = 20 // request opcode - b += 1 +// Skipping definition for base type 'Card8' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Char' - return buf -} +// 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' // CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { @@ -761,146 +510,6 @@ func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, return buf } -// PrintSetContextCookie is a cookie used only for PrintSetContext requests. -type PrintSetContextCookie struct { - *xgb.Cookie -} - -// PrintSetContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintSetContext(c *xgb.Conn, Context uint32) PrintSetContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(printSetContextRequest(c, Context), cookie) - return PrintSetContextCookie{cookie} -} - -// PrintSetContextChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintSetContextCookie.Check() -func PrintSetContextChecked(c *xgb.Conn, Context uint32) PrintSetContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(printSetContextRequest(c, Context), cookie) - return PrintSetContextCookie{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 PrintSetContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for PrintSetContext -// printSetContextRequest writes a PrintSetContext request to a byte slice. -func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - 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:], Context) - b += 4 - - return buf -} - -// PrintGetContextCookie is a cookie used only for PrintGetContext requests. -type PrintGetContextCookie struct { - *xgb.Cookie -} - -// PrintGetContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetContextCookie.Reply() -func PrintGetContext(c *xgb.Conn) PrintGetContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(printGetContextRequest(c), cookie) - return PrintGetContextCookie{cookie} -} - -// PrintGetContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetContextUnchecked(c *xgb.Conn) PrintGetContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(printGetContextRequest(c), cookie) - return PrintGetContextCookie{cookie} -} - -// PrintGetContextReply represents the data returned from a PrintGetContext request. -type PrintGetContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Context uint32 -} - -// Reply blocks and returns the reply data for a PrintGetContext request. -func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return printGetContextReply(buf), nil -} - -// printGetContextReply reads a byte slice into a PrintGetContextReply value. -func printGetContextReply(buf []byte) *PrintGetContextReply { - v := new(PrintGetContextReply) - 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.Context = xgb.Get32(buf[b:]) - b += 4 - - return v -} - -// Write request to wire for PrintGetContext -// printGetContextRequest writes a PrintGetContext request to a byte slice. -func printGetContextRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - 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 -} - // PrintDestroyContextCookie is a cookie used only for PrintDestroyContext requests. type PrintDestroyContextCookie struct { *xgb.Cookie @@ -956,127 +565,42 @@ func printDestroyContextRequest(c *xgb.Conn, Context uint32) []byte { return buf } -// PrintGetScreenOfContextCookie is a cookie used only for PrintGetScreenOfContext requests. -type PrintGetScreenOfContextCookie struct { - *xgb.Cookie -} - -// PrintGetScreenOfContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetScreenOfContextCookie.Reply() -func PrintGetScreenOfContext(c *xgb.Conn) PrintGetScreenOfContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(printGetScreenOfContextRequest(c), cookie) - return PrintGetScreenOfContextCookie{cookie} -} - -// PrintGetScreenOfContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetScreenOfContextUnchecked(c *xgb.Conn) PrintGetScreenOfContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(printGetScreenOfContextRequest(c), cookie) - return PrintGetScreenOfContextCookie{cookie} -} - -// PrintGetScreenOfContextReply represents the data returned from a PrintGetScreenOfContext request. -type PrintGetScreenOfContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Root xproto.Window -} - -// Reply blocks and returns the reply data for a PrintGetScreenOfContext request. -func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return printGetScreenOfContextReply(buf), nil -} - -// printGetScreenOfContextReply reads a byte slice into a PrintGetScreenOfContextReply value. -func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { - v := new(PrintGetScreenOfContextReply) - 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.Root = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for PrintGetScreenOfContext -// printGetScreenOfContextRequest writes a PrintGetScreenOfContext request to a byte slice. -func printGetScreenOfContextRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - 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 - - return buf -} - -// PrintStartJobCookie is a cookie used only for PrintStartJob requests. -type PrintStartJobCookie struct { +// PrintEndDocCookie is a cookie used only for PrintEndDoc requests. +type PrintEndDocCookie struct { *xgb.Cookie } -// PrintStartJob sends an unchecked request. +// PrintEndDoc sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintStartJob(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { +func PrintEndDoc(c *xgb.Conn, Cancel bool) PrintEndDocCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintEndDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(printStartJobRequest(c, OutputMode), cookie) - return PrintStartJobCookie{cookie} + c.NewRequest(printEndDocRequest(c, Cancel), cookie) + return PrintEndDocCookie{cookie} } -// PrintStartJobChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintStartJobCookie.Check() -func PrintStartJobChecked(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { +// PrintEndDocChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintEndDocCookie.Check() +func PrintEndDocChecked(c *xgb.Conn, Cancel bool) PrintEndDocCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintEndDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(printStartJobRequest(c, OutputMode), cookie) - return PrintStartJobCookie{cookie} + c.NewRequest(printEndDocRequest(c, Cancel), cookie) + return PrintEndDocCookie{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 PrintStartJobCookie) Check() error { +func (cook PrintEndDocCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PrintStartJob -// printStartJobRequest writes a PrintStartJob request to a byte slice. -func printStartJobRequest(c *xgb.Conn, OutputMode byte) []byte { +// Write request to wire for PrintEndDoc +// printEndDocRequest writes a PrintEndDoc request to a byte slice. +func printEndDocRequest(c *xgb.Conn, Cancel bool) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1084,13 +608,17 @@ func printStartJobRequest(c *xgb.Conn, OutputMode byte) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = OutputMode + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 return buf @@ -1155,42 +683,42 @@ func printEndJobRequest(c *xgb.Conn, Cancel bool) []byte { return buf } -// PrintStartDocCookie is a cookie used only for PrintStartDoc requests. -type PrintStartDocCookie struct { +// PrintEndPageCookie is a cookie used only for PrintEndPage requests. +type PrintEndPageCookie struct { *xgb.Cookie } -// PrintStartDoc sends an unchecked request. +// PrintEndPage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintStartDoc(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { +func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintEndPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(printStartDocRequest(c, DriverMode), cookie) - return PrintStartDocCookie{cookie} + c.NewRequest(printEndPageRequest(c, Cancel), cookie) + return PrintEndPageCookie{cookie} } -// PrintStartDocChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintStartDocCookie.Check() -func PrintStartDocChecked(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { +// PrintEndPageChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintEndPageCookie.Check() +func PrintEndPageChecked(c *xgb.Conn, Cancel bool) PrintEndPageCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintEndPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(printStartDocRequest(c, DriverMode), cookie) - return PrintStartDocCookie{cookie} + c.NewRequest(printEndPageRequest(c, Cancel), cookie) + return PrintEndPageCookie{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 PrintStartDocCookie) Check() error { +func (cook PrintEndPageCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PrintStartDoc -// printStartDocRequest writes a PrintStartDoc request to a byte slice. -func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { +// Write request to wire for PrintEndPage +// printEndPageRequest writes a PrintEndPage request to a byte slice. +func printEndPageRequest(c *xgb.Conn, Cancel bool) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1198,152 +726,205 @@ func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = DriverMode + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 + b += 3 // padding + return buf } -// PrintEndDocCookie is a cookie used only for PrintEndDoc requests. -type PrintEndDocCookie struct { +// PrintGetAttributesCookie is a cookie used only for PrintGetAttributes requests. +type PrintGetAttributesCookie struct { *xgb.Cookie } -// PrintEndDoc sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintEndDoc(c *xgb.Conn, Cancel bool) PrintEndDocCookie { +// PrintGetAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetAttributesCookie.Reply() +func PrintGetAttributes(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(printEndDocRequest(c, Cancel), cookie) - return PrintEndDocCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{cookie} } -// PrintEndDocChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintEndDocCookie.Check() -func PrintEndDocChecked(c *xgb.Conn, Cancel bool) PrintEndDocCookie { +// PrintGetAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(printEndDocRequest(c, Cancel), cookie) - return PrintEndDocCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{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 PrintEndDocCookie) Check() error { - return cook.Cookie.Check() +// PrintGetAttributesReply represents the data returned from a PrintGetAttributes request. +type PrintGetAttributesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + StringLen uint32 + // padding: 20 bytes + Attributes String8 } -// Write request to wire for PrintEndDoc -// printEndDocRequest writes a PrintEndDoc request to a byte slice. -func printEndDocRequest(c *xgb.Conn, Cancel bool) []byte { - size := 8 +// Reply blocks and returns the reply data for a PrintGetAttributes request. +func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetAttributesReply(buf), nil +} + +// printGetAttributesReply reads a byte slice into a PrintGetAttributesReply value. +func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { + v := new(PrintGetAttributesReply) + 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.StringLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attributes = String8(buf[b]) + b += 1 + + return v +} + +// Write request to wire for PrintGetAttributes +// printGetAttributesRequest writes a PrintGetAttributes request to a byte slice. +func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + buf[b] = Pool b += 1 + b += 3 // padding + return buf } -// PrintPutDocumentDataCookie is a cookie used only for PrintPutDocumentData requests. -type PrintPutDocumentDataCookie struct { +// PrintGetContextCookie is a cookie used only for PrintGetContext requests. +type PrintGetContextCookie struct { *xgb.Cookie } -// PrintPutDocumentData sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintPutDocumentData(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { +// PrintGetContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetContextCookie.Reply() +func PrintGetContext(c *xgb.Conn) PrintGetContextCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintPutDocumentData' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return PrintPutDocumentDataCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{cookie} } -// PrintPutDocumentDataChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintPutDocumentDataCookie.Check() -func PrintPutDocumentDataChecked(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { +// PrintGetContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetContextUnchecked(c *xgb.Conn) PrintGetContextCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintPutDocumentData' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return PrintPutDocumentDataCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{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 PrintPutDocumentDataCookie) Check() error { - return cook.Cookie.Check() +// PrintGetContextReply represents the data returned from a PrintGetContext request. +type PrintGetContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Context uint32 } -// Write request to wire for PrintPutDocumentData -// printPutDocumentDataRequest writes a PrintPutDocumentData request to a byte slice. -func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) []byte { - size := xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a PrintGetContext request. +func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetContextReply(buf), nil +} - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 +// printGetContextReply reads a byte slice into a PrintGetContextReply value. +func printGetContextReply(buf []byte) *PrintGetContextReply { + v := new(PrintGetContextReply) + b := 1 // skip reply determinant - buf[b] = 11 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], LenData) + v.Context = xgb.Get32(buf[b:]) b += 4 - xgb.Put16(buf[b:], LenFmt) - b += 2 + return v +} - xgb.Put16(buf[b:], LenOptions) - b += 2 +// Write request to wire for PrintGetContext +// printGetContextRequest writes a PrintGetContext request to a byte slice. +func printGetContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) - copy(buf[b:], Data[:LenData]) - b += xgb.Pad(int(LenData)) + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 - for i := 0; i < int(len(DocFormat)); i++ { - buf[b] = byte(DocFormat[i]) - b += 1 - } - b = xgb.Pad(b) + buf[b] = 4 // request opcode + b += 1 - for i := 0; i < int(len(Options)); i++ { - buf[b] = byte(Options[i]) - b += 1 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 return buf } @@ -1455,42 +1036,75 @@ func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) return buf } -// PrintStartPageCookie is a cookie used only for PrintStartPage requests. -type PrintStartPageCookie struct { +// PrintGetImageResolutionCookie is a cookie used only for PrintGetImageResolution requests. +type PrintGetImageResolutionCookie struct { *xgb.Cookie } -// PrintStartPage sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintStartPage(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { +// PrintGetImageResolution sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetImageResolutionCookie.Reply() +func PrintGetImageResolution(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetImageResolution' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(printStartPageRequest(c, Window), cookie) - return PrintStartPageCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{cookie} } -// PrintStartPageChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintStartPageCookie.Check() -func PrintStartPageChecked(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { +// PrintGetImageResolutionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetImageResolution' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(printStartPageRequest(c, Window), cookie) - return PrintStartPageCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{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 PrintStartPageCookie) Check() error { - return cook.Cookie.Check() +// PrintGetImageResolutionReply represents the data returned from a PrintGetImageResolution request. +type PrintGetImageResolutionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ImageResolution uint16 } -// Write request to wire for PrintStartPage -// printStartPageRequest writes a PrintStartPage request to a byte slice. -func printStartPageRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Reply blocks and returns the reply data for a PrintGetImageResolution request. +func (cook PrintGetImageResolutionCookie) Reply() (*PrintGetImageResolutionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetImageResolutionReply(buf), nil +} + +// printGetImageResolutionReply reads a byte slice into a PrintGetImageResolutionReply value. +func printGetImageResolutionReply(buf []byte) *PrintGetImageResolutionReply { + v := new(PrintGetImageResolutionReply) + 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.ImageResolution = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintGetImageResolution +// printGetImageResolutionRequest writes a PrintGetImageResolution request to a byte slice. +func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1498,123 +1112,228 @@ func printStartPageRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 24 // 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)) + xgb.Put32(buf[b:], uint32(Context)) b += 4 return buf } -// PrintEndPageCookie is a cookie used only for PrintEndPage requests. -type PrintEndPageCookie struct { +// PrintGetOneAttributesCookie is a cookie used only for PrintGetOneAttributes requests. +type PrintGetOneAttributesCookie struct { *xgb.Cookie } -// PrintEndPage sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { +// PrintGetOneAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetOneAttributesCookie.Reply() +func PrintGetOneAttributes(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetOneAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(printEndPageRequest(c, Cancel), cookie) - return PrintEndPageCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) + return PrintGetOneAttributesCookie{cookie} } -// PrintEndPageChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintEndPageCookie.Check() -func PrintEndPageChecked(c *xgb.Conn, Cancel bool) PrintEndPageCookie { +// PrintGetOneAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetOneAttributesUnchecked(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetOneAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(printEndPageRequest(c, Cancel), cookie) - return PrintEndPageCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) + return PrintGetOneAttributesCookie{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 PrintEndPageCookie) Check() error { - return cook.Cookie.Check() +// PrintGetOneAttributesReply represents the data returned from a PrintGetOneAttributes request. +type PrintGetOneAttributesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ValueLen uint32 + // padding: 20 bytes + Value []String8 // size: xgb.Pad((int(ValueLen) * 1)) } -// Write request to wire for PrintEndPage -// printEndPageRequest writes a PrintEndPage request to a byte slice. -func printEndPageRequest(c *xgb.Conn, Cancel bool) []byte { - size := 8 +// Reply blocks and returns the reply data for a PrintGetOneAttributes request. +func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetOneAttributesReply(buf), nil +} + +// printGetOneAttributesReply reads a byte slice into a PrintGetOneAttributesReply value. +func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { + v := new(PrintGetOneAttributesReply) + 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.ValueLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Value = make([]String8, v.ValueLen) + for i := 0; i < int(v.ValueLen); i++ { + v.Value[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintGetOneAttributes +// printGetOneAttributesRequest writes a PrintGetOneAttributes request to a byte slice. +func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) []byte { + size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], NameLen) + b += 4 + + buf[b] = Pool b += 1 b += 3 // padding + for i := 0; i < int(NameLen); i++ { + buf[b] = byte(Name[i]) + b += 1 + } + b = xgb.Pad(b) + return buf } -// PrintSelectInputCookie is a cookie used only for PrintSelectInput requests. -type PrintSelectInputCookie struct { +// PrintGetPageDimensionsCookie is a cookie used only for PrintGetPageDimensions requests. +type PrintGetPageDimensionsCookie struct { *xgb.Cookie } -// PrintSelectInput sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { +// PrintGetPageDimensions sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetPageDimensionsCookie.Reply() +func PrintGetPageDimensions(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetPageDimensions' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) - return PrintSelectInputCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{cookie} } -// PrintSelectInputChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintSelectInputCookie.Check() -func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { +// PrintGetPageDimensionsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetPageDimensionsUnchecked(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetPageDimensions' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) - return PrintSelectInputCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{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 PrintSelectInputCookie) Check() error { - return cook.Cookie.Check() +// PrintGetPageDimensionsReply represents the data returned from a PrintGetPageDimensions request. +type PrintGetPageDimensionsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Width uint16 + Height uint16 + OffsetX uint16 + OffsetY uint16 + ReproducibleWidth uint16 + ReproducibleHeight uint16 } -// Write request to wire for PrintSelectInput -// printSelectInputRequest writes a PrintSelectInput request to a byte slice. -func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) +// Reply blocks and returns the reply data for a PrintGetPageDimensions request. +func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetPageDimensionsReply(buf), nil +} + +// printGetPageDimensionsReply reads a byte slice into a PrintGetPageDimensionsReply value. +func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { + v := new(PrintGetPageDimensionsReply) + 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.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetX = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetY = xgb.Get16(buf[b:]) + b += 2 + + v.ReproducibleWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ReproducibleHeight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintGetPageDimensions +// printGetPageDimensionsRequest writes a PrintGetPageDimensions request to a byte slice. +func printGetPageDimensionsRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 15 // request opcode + buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1623,57 +1342,48 @@ func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, Ev xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], EventMask) - b += 4 - for i := 0; i < xgb.PopCount(int(EventMask)); i++ { - xgb.Put32(buf[b:], EventList[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// PrintInputSelectedCookie is a cookie used only for PrintInputSelected requests. -type PrintInputSelectedCookie struct { +// PrintGetPrinterListCookie is a cookie used only for PrintGetPrinterList requests. +type PrintGetPrinterListCookie struct { *xgb.Cookie } -// PrintInputSelected sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintInputSelectedCookie.Reply() -func PrintInputSelected(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { +// PrintGetPrinterList sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetPrinterListCookie.Reply() +func PrintGetPrinterList(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(printInputSelectedRequest(c, Context), cookie) - return PrintInputSelectedCookie{cookie} + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{cookie} } -// PrintInputSelectedUnchecked sends an unchecked request. +// PrintGetPrinterListUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintInputSelectedUnchecked(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { +func PrintGetPrinterListUnchecked(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(printInputSelectedRequest(c, Context), cookie) - return PrintInputSelectedCookie{cookie} + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{cookie} } -// PrintInputSelectedReply represents the data returned from a PrintInputSelected request. -type PrintInputSelectedReply struct { +// PrintGetPrinterListReply represents the data returned from a PrintGetPrinterList request. +type PrintGetPrinterListReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - EventMask uint32 - EventList []uint32 - AllEventsMask uint32 - AllEventsList []uint32 + ListCount uint32 + // padding: 20 bytes + Printers []Printer // size: PrinterListSize(Printers) } -// Reply blocks and returns the reply data for a PrintInputSelected request. -func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { +// Reply blocks and returns the reply data for a PrintGetPrinterList request. +func (cook PrintGetPrinterListCookie) Reply() (*PrintGetPrinterListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1681,12 +1391,12 @@ func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { if buf == nil { return nil, nil } - return printInputSelectedReply(buf), nil + return printGetPrinterListReply(buf), nil } -// printInputSelectedReply reads a byte slice into a PrintInputSelectedReply value. -func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { - v := new(PrintInputSelectedReply) +// printGetPrinterListReply reads a byte slice into a PrintGetPrinterListReply value. +func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { + v := new(PrintGetPrinterListReply) b := 1 // skip reply determinant b += 1 // padding @@ -1697,90 +1407,91 @@ func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.EventMask = xgb.Get32(buf[b:]) + v.ListCount = xgb.Get32(buf[b:]) b += 4 - v.EventList = make([]uint32, xgb.PopCount(int(v.EventMask))) - for i := 0; i < xgb.PopCount(int(v.EventMask)); i++ { - v.EventList[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - v.AllEventsMask = xgb.Get32(buf[b:]) - b += 4 + b += 20 // padding - v.AllEventsList = make([]uint32, xgb.PopCount(int(v.AllEventsMask))) - for i := 0; i < xgb.PopCount(int(v.AllEventsMask)); i++ { - v.AllEventsList[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Printers = make([]Printer, v.ListCount) + b += PrinterReadList(buf[b:], v.Printers) return v } -// Write request to wire for PrintInputSelected -// printInputSelectedRequest writes a PrintInputSelected request to a byte slice. -func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { - size := 8 +// Write request to wire for PrintGetPrinterList +// printGetPrinterListRequest writes a PrintGetPrinterList request to a byte slice. +func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { + size := xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 16 // request opcode + 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(Context)) + xgb.Put32(buf[b:], PrinterNameLen) + b += 4 + + xgb.Put32(buf[b:], LocaleLen) b += 4 + for i := 0; i < int(PrinterNameLen); i++ { + buf[b] = byte(PrinterName[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(LocaleLen); i++ { + buf[b] = byte(Locale[i]) + b += 1 + } + b = xgb.Pad(b) + return buf } -// PrintGetAttributesCookie is a cookie used only for PrintGetAttributes requests. -type PrintGetAttributesCookie struct { +// PrintGetScreenOfContextCookie is a cookie used only for PrintGetScreenOfContext requests. +type PrintGetScreenOfContextCookie struct { *xgb.Cookie } -// PrintGetAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetAttributesCookie.Reply() -func PrintGetAttributes(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { +// PrintGetScreenOfContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetScreenOfContextCookie.Reply() +func PrintGetScreenOfContext(c *xgb.Conn) PrintGetScreenOfContextCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) - return PrintGetAttributesCookie{cookie} + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} } -// PrintGetAttributesUnchecked sends an unchecked request. +// PrintGetScreenOfContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { +func PrintGetScreenOfContextUnchecked(c *xgb.Conn) PrintGetScreenOfContextCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) - return PrintGetAttributesCookie{cookie} + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} } -// PrintGetAttributesReply represents the data returned from a PrintGetAttributes request. -type PrintGetAttributesReply struct { +// PrintGetScreenOfContextReply represents the data returned from a PrintGetScreenOfContext request. +type PrintGetScreenOfContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - StringLen uint32 - // padding: 20 bytes - Attributes String8 + Root xproto.Window } -// Reply blocks and returns the reply data for a PrintGetAttributes request. -func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { +// Reply blocks and returns the reply data for a PrintGetScreenOfContext request. +func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1788,12 +1499,12 @@ func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { if buf == nil { return nil, nil } - return printGetAttributesReply(buf), nil + return printGetScreenOfContextReply(buf), nil } -// printGetAttributesReply reads a byte slice into a PrintGetAttributesReply value. -func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { - v := new(PrintGetAttributesReply) +// printGetScreenOfContextReply reads a byte slice into a PrintGetScreenOfContextReply value. +func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { + v := new(PrintGetScreenOfContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1804,83 +1515,71 @@ func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.StringLen = xgb.Get32(buf[b:]) + v.Root = xproto.Window(xgb.Get32(buf[b:])) b += 4 - b += 20 // padding - - v.Attributes = String8(buf[b]) - b += 1 - return v } -// Write request to wire for PrintGetAttributes -// printGetAttributesRequest writes a PrintGetAttributes request to a byte slice. -func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte { - size := 12 +// Write request to wire for PrintGetScreenOfContext +// printGetScreenOfContextRequest writes a PrintGetScreenOfContext request to a byte slice. +func printGetScreenOfContextRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 17 // request opcode + 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:], uint32(Context)) - b += 4 - - buf[b] = Pool - b += 1 - - b += 3 // padding - return buf } -// PrintGetOneAttributesCookie is a cookie used only for PrintGetOneAttributes requests. -type PrintGetOneAttributesCookie struct { +// PrintInputSelectedCookie is a cookie used only for PrintInputSelected requests. +type PrintInputSelectedCookie struct { *xgb.Cookie } -// PrintGetOneAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetOneAttributesCookie.Reply() -func PrintGetOneAttributes(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { +// PrintInputSelected sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintInputSelectedCookie.Reply() +func PrintInputSelected(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetOneAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) - return PrintGetOneAttributesCookie{cookie} + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} } -// PrintGetOneAttributesUnchecked sends an unchecked request. +// PrintInputSelectedUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetOneAttributesUnchecked(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { +func PrintInputSelectedUnchecked(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetOneAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) - return PrintGetOneAttributesCookie{cookie} + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} } -// PrintGetOneAttributesReply represents the data returned from a PrintGetOneAttributes request. -type PrintGetOneAttributesReply struct { +// PrintInputSelectedReply represents the data returned from a PrintInputSelected request. +type PrintInputSelectedReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ValueLen uint32 - // padding: 20 bytes - Value []String8 // size: xgb.Pad((int(ValueLen) * 1)) + EventMask uint32 + EventList []uint32 + AllEventsMask uint32 + AllEventsList []uint32 } -// Reply blocks and returns the reply data for a PrintGetOneAttributes request. -func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, error) { +// Reply blocks and returns the reply data for a PrintInputSelected request. +func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1888,12 +1587,12 @@ func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, er if buf == nil { return nil, nil } - return printGetOneAttributesReply(buf), nil + return printInputSelectedReply(buf), nil } -// printGetOneAttributesReply reads a byte slice into a PrintGetOneAttributesReply value. -func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { - v := new(PrintGetOneAttributesReply) +// printInputSelectedReply reads a byte slice into a PrintInputSelectedReply value. +func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { + v := new(PrintInputSelectedReply) b := 1 // skip reply determinant b += 1 // padding @@ -1904,32 +1603,40 @@ func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ValueLen = xgb.Get32(buf[b:]) + v.EventMask = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding + v.EventList = make([]uint32, xgb.PopCount(int(v.EventMask))) + for i := 0; i < xgb.PopCount(int(v.EventMask)); i++ { + v.EventList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) - v.Value = make([]String8, v.ValueLen) - for i := 0; i < int(v.ValueLen); i++ { - v.Value[i] = String8(buf[b]) - b += 1 + v.AllEventsMask = xgb.Get32(buf[b:]) + b += 4 + + v.AllEventsList = make([]uint32, xgb.PopCount(int(v.AllEventsMask))) + for i := 0; i < xgb.PopCount(int(v.AllEventsMask)); i++ { + v.AllEventsList[i] = xgb.Get32(buf[b:]) + b += 4 } b = xgb.Pad(b) return v } -// Write request to wire for PrintGetOneAttributes -// printGetOneAttributesRequest writes a PrintGetOneAttributes request to a byte slice. -func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) []byte { - size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for PrintInputSelected +// printInputSelectedRequest writes a PrintInputSelected request to a byte slice. +func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1938,88 +1645,81 @@ func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], NameLen) - b += 4 - - buf[b] = Pool - b += 1 - - b += 3 // padding - - for i := 0; i < int(NameLen); i++ { - buf[b] = byte(Name[i]) - b += 1 - } - b = xgb.Pad(b) - return buf } -// PrintSetAttributesCookie is a cookie used only for PrintSetAttributes requests. -type PrintSetAttributesCookie struct { +// PrintPutDocumentDataCookie is a cookie used only for PrintPutDocumentData requests. +type PrintPutDocumentDataCookie struct { *xgb.Cookie } -// PrintSetAttributes sends an unchecked request. +// PrintPutDocumentData sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintSetAttributes(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { +func PrintPutDocumentData(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintPutDocumentData' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) - return PrintSetAttributesCookie{cookie} + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} } -// PrintSetAttributesChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintSetAttributesCookie.Check() -func PrintSetAttributesChecked(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { +// PrintPutDocumentDataChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintPutDocumentDataCookie.Check() +func PrintPutDocumentDataChecked(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintPutDocumentData' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) - return PrintSetAttributesCookie{cookie} + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{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 PrintSetAttributesCookie) Check() error { +func (cook PrintPutDocumentDataCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PrintSetAttributes -// printSetAttributesRequest writes a PrintSetAttributes request to a byte slice. -func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) +// Write request to wire for PrintPutDocumentData +// printPutDocumentDataRequest writes a PrintPutDocumentData request to a byte slice. +func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) []byte { + size := xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 18 // 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:], uint32(Context)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], StringLen) + xgb.Put32(buf[b:], LenData) b += 4 - buf[b] = Pool - b += 1 + xgb.Put16(buf[b:], LenFmt) + b += 2 - buf[b] = Rule - b += 1 + xgb.Put16(buf[b:], LenOptions) + b += 2 - b += 2 // padding + copy(buf[b:], Data[:LenData]) + b += xgb.Pad(int(LenData)) - for i := 0; i < int(len(Attributes)); i++ { - buf[b] = byte(Attributes[i]) + for i := 0; i < int(len(DocFormat)); i++ { + buf[b] = byte(DocFormat[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(len(Options)); i++ { + buf[b] = byte(Options[i]) b += 1 } b = xgb.Pad(b) @@ -2027,48 +1727,45 @@ func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, return buf } -// PrintGetPageDimensionsCookie is a cookie used only for PrintGetPageDimensions requests. -type PrintGetPageDimensionsCookie struct { +// PrintQueryScreensCookie is a cookie used only for PrintQueryScreens requests. +type PrintQueryScreensCookie struct { *xgb.Cookie } -// PrintGetPageDimensions sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetPageDimensionsCookie.Reply() -func PrintGetPageDimensions(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { +// PrintQueryScreens sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintQueryScreensCookie.Reply() +func PrintQueryScreens(c *xgb.Conn) PrintQueryScreensCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetPageDimensions' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintQueryScreens' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) - return PrintGetPageDimensionsCookie{cookie} + c.NewRequest(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} } -// PrintGetPageDimensionsUnchecked sends an unchecked request. +// PrintQueryScreensUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetPageDimensionsUnchecked(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { +func PrintQueryScreensUnchecked(c *xgb.Conn) PrintQueryScreensCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetPageDimensions' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintQueryScreens' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) - return PrintGetPageDimensionsCookie{cookie} + c.NewRequest(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} } -// PrintGetPageDimensionsReply represents the data returned from a PrintGetPageDimensions request. -type PrintGetPageDimensionsReply struct { +// PrintQueryScreensReply represents the data returned from a PrintQueryScreens request. +type PrintQueryScreensReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Width uint16 - Height uint16 - OffsetX uint16 - OffsetY uint16 - ReproducibleWidth uint16 - ReproducibleHeight uint16 + ListCount uint32 + // padding: 20 bytes + Roots []xproto.Window // size: xgb.Pad((int(ListCount) * 4)) } -// Reply blocks and returns the reply data for a PrintGetPageDimensions request. -func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, error) { +// Reply blocks and returns the reply data for a PrintQueryScreens request. +func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2076,12 +1773,12 @@ func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, if buf == nil { return nil, nil } - return printGetPageDimensionsReply(buf), nil + return printQueryScreensReply(buf), nil } -// printGetPageDimensionsReply reads a byte slice into a PrintGetPageDimensionsReply value. -func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { - v := new(PrintGetPageDimensionsReply) +// printQueryScreensReply reads a byte slice into a PrintQueryScreensReply value. +func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { + v := new(PrintQueryScreensReply) b := 1 // skip reply determinant b += 1 // padding @@ -2092,88 +1789,78 @@ func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.OffsetX = xgb.Get16(buf[b:]) - b += 2 - - v.OffsetY = xgb.Get16(buf[b:]) - b += 2 + v.ListCount = xgb.Get32(buf[b:]) + b += 4 - v.ReproducibleWidth = xgb.Get16(buf[b:]) - b += 2 + b += 20 // padding - v.ReproducibleHeight = xgb.Get16(buf[b:]) - b += 2 + v.Roots = make([]xproto.Window, v.ListCount) + for i := 0; i < int(v.ListCount); i++ { + v.Roots[i] = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for PrintGetPageDimensions -// printGetPageDimensionsRequest writes a PrintGetPageDimensions request to a byte slice. -func printGetPageDimensionsRequest(c *xgb.Conn, Context Pcontext) []byte { - size := 8 +// Write request to wire for PrintQueryScreens +// printQueryScreensRequest writes a PrintQueryScreens request to a byte slice. +func printQueryScreensRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 21 // request opcode + buf[b] = 22 // 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(Context)) - b += 4 - return buf } -// PrintQueryScreensCookie is a cookie used only for PrintQueryScreens requests. -type PrintQueryScreensCookie struct { +// PrintQueryVersionCookie is a cookie used only for PrintQueryVersion requests. +type PrintQueryVersionCookie struct { *xgb.Cookie } -// PrintQueryScreens sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintQueryScreensCookie.Reply() -func PrintQueryScreens(c *xgb.Conn) PrintQueryScreensCookie { +// PrintQueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintQueryVersionCookie.Reply() +func PrintQueryVersion(c *xgb.Conn) PrintQueryVersionCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintQueryScreens' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintQueryVersion' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(printQueryScreensRequest(c), cookie) - return PrintQueryScreensCookie{cookie} + c.NewRequest(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} } -// PrintQueryScreensUnchecked sends an unchecked request. +// PrintQueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintQueryScreensUnchecked(c *xgb.Conn) PrintQueryScreensCookie { +func PrintQueryVersionUnchecked(c *xgb.Conn) PrintQueryVersionCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintQueryScreens' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintQueryVersion' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(printQueryScreensRequest(c), cookie) - return PrintQueryScreensCookie{cookie} + c.NewRequest(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} } -// PrintQueryScreensReply represents the data returned from a PrintQueryScreens request. -type PrintQueryScreensReply struct { +// PrintQueryVersionReply represents the data returned from a PrintQueryVersion request. +type PrintQueryVersionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ListCount uint32 - // padding: 20 bytes - Roots []xproto.Window // size: xgb.Pad((int(ListCount) * 4)) + MajorVersion uint16 + MinorVersion uint16 } -// Reply blocks and returns the reply data for a PrintQueryScreens request. -func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { +// Reply blocks and returns the reply data for a PrintQueryVersion request. +func (cook PrintQueryVersionCookie) Reply() (*PrintQueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2181,12 +1868,12 @@ func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { if buf == nil { return nil, nil } - return printQueryScreensReply(buf), nil + return printQueryVersionReply(buf), nil } -// printQueryScreensReply reads a byte slice into a PrintQueryScreensReply value. -func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { - v := new(PrintQueryScreensReply) +// printQueryVersionReply reads a byte slice into a PrintQueryVersionReply value. +func printQueryVersionReply(buf []byte) *PrintQueryVersionReply { + v := new(PrintQueryVersionReply) b := 1 // skip reply determinant b += 1 // padding @@ -2197,37 +1884,273 @@ func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ListCount = xgb.Get32(buf[b:]) - b += 4 + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Roots = make([]xproto.Window, v.ListCount) - for i := 0; i < int(v.ListCount); i++ { - v.Roots[i] = xproto.Window(xgb.Get32(buf[b:])) + return v +} + +// Write request to wire for PrintQueryVersion +// printQueryVersionRequest writes a PrintQueryVersion request to a byte slice. +func printQueryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 +} + +// PrintRehashPrinterListCookie is a cookie used only for PrintRehashPrinterList requests. +type PrintRehashPrinterListCookie struct { + *xgb.Cookie +} + +// PrintRehashPrinterList sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintRehashPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{cookie} +} + +// PrintRehashPrinterListChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintRehashPrinterListCookie.Check() +func PrintRehashPrinterListChecked(c *xgb.Conn) PrintRehashPrinterListCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintRehashPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{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 PrintRehashPrinterListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintRehashPrinterList +// printRehashPrinterListRequest writes a PrintRehashPrinterList request to a byte slice. +func printRehashPrinterListRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// PrintSelectInputCookie is a cookie used only for PrintSelectInput requests. +type PrintSelectInputCookie struct { + *xgb.Cookie +} + +// PrintSelectInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} +} + +// PrintSelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSelectInputCookie.Check() +func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{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 PrintSelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSelectInput +// printSelectInputRequest writes a PrintSelectInput request to a byte slice. +func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 15 // 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(Context)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + for i := 0; i < xgb.PopCount(int(EventMask)); i++ { + xgb.Put32(buf[b:], EventList[i]) b += 4 } b = xgb.Pad(b) - return v + return buf } -// Write request to wire for PrintQueryScreens -// printQueryScreensRequest writes a PrintQueryScreens request to a byte slice. -func printQueryScreensRequest(c *xgb.Conn) []byte { - size := 4 +// PrintSetAttributesCookie is a cookie used only for PrintSetAttributes requests. +type PrintSetAttributesCookie struct { + *xgb.Cookie +} + +// PrintSetAttributes sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintSetAttributes(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) + return PrintSetAttributesCookie{cookie} +} + +// PrintSetAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSetAttributesCookie.Check() +func PrintSetAttributesChecked(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSetAttributes' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) + return PrintSetAttributesCookie{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 PrintSetAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSetAttributes +// printSetAttributesRequest writes a PrintSetAttributes request to a byte slice. +func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 22 // request opcode + buf[b] = 18 // 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(Context)) + b += 4 + + xgb.Put32(buf[b:], StringLen) + b += 4 + + buf[b] = Pool + b += 1 + + buf[b] = Rule + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Attributes)); i++ { + buf[b] = byte(Attributes[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// PrintSetContextCookie is a cookie used only for PrintSetContext requests. +type PrintSetContextCookie struct { + *xgb.Cookie +} + +// PrintSetContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintSetContext(c *xgb.Conn, Context uint32) PrintSetContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{cookie} +} + +// PrintSetContextChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSetContextCookie.Check() +func PrintSetContextChecked(c *xgb.Conn, Context uint32) PrintSetContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{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 PrintSetContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSetContext +// printSetContextRequest writes a PrintSetContext request to a byte slice. +func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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:], Context) + b += 4 + return buf } @@ -2327,75 +2250,152 @@ func printSetImageResolutionRequest(c *xgb.Conn, Context Pcontext, ImageResoluti return buf } -// PrintGetImageResolutionCookie is a cookie used only for PrintGetImageResolution requests. -type PrintGetImageResolutionCookie struct { +// PrintStartDocCookie is a cookie used only for PrintStartDoc requests. +type PrintStartDocCookie struct { *xgb.Cookie } -// PrintGetImageResolution sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetImageResolutionCookie.Reply() -func PrintGetImageResolution(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { +// PrintStartDoc sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintStartDoc(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetImageResolution' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintStartDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) - return PrintGetImageResolutionCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(printStartDocRequest(c, DriverMode), cookie) + return PrintStartDocCookie{cookie} } -// PrintGetImageResolutionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { +// PrintStartDocChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintStartDocCookie.Check() +func PrintStartDocChecked(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetImageResolution' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintStartDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) - return PrintGetImageResolutionCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(printStartDocRequest(c, DriverMode), cookie) + return PrintStartDocCookie{cookie} } -// PrintGetImageResolutionReply represents the data returned from a PrintGetImageResolution request. -type PrintGetImageResolutionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ImageResolution uint16 +// 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 PrintStartDocCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a PrintGetImageResolution request. -func (cook PrintGetImageResolutionCookie) Reply() (*PrintGetImageResolutionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err +// Write request to wire for PrintStartDoc +// printStartDocRequest writes a PrintStartDoc request to a byte slice. +func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 + + buf[b] = DriverMode + b += 1 + + return buf +} + +// PrintStartJobCookie is a cookie used only for PrintStartJob requests. +type PrintStartJobCookie struct { + *xgb.Cookie +} + +// PrintStartJob sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintStartJob(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintStartJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - if buf == nil { - return nil, nil + cookie := c.NewCookie(false, false) + c.NewRequest(printStartJobRequest(c, OutputMode), cookie) + return PrintStartJobCookie{cookie} +} + +// PrintStartJobChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintStartJobCookie.Check() +func PrintStartJobChecked(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintStartJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - return printGetImageResolutionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(printStartJobRequest(c, OutputMode), cookie) + return PrintStartJobCookie{cookie} } -// printGetImageResolutionReply reads a byte slice into a PrintGetImageResolutionReply value. -func printGetImageResolutionReply(buf []byte) *PrintGetImageResolutionReply { - v := new(PrintGetImageResolutionReply) - b := 1 // skip reply determinant +// 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 PrintStartJobCookie) Check() error { + return cook.Cookie.Check() +} - b += 1 // padding +// Write request to wire for PrintStartJob +// printStartJobRequest writes a PrintStartJob request to a byte slice. +func printStartJobRequest(c *xgb.Conn, OutputMode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + buf[b] = 7 // request opcode + b += 1 - v.ImageResolution = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return v + buf[b] = OutputMode + b += 1 + + return buf } -// Write request to wire for PrintGetImageResolution -// printGetImageResolutionRequest writes a PrintGetImageResolution request to a byte slice. -func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { +// PrintStartPageCookie is a cookie used only for PrintStartPage requests. +type PrintStartPageCookie struct { + *xgb.Cookie +} + +// PrintStartPage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintStartPage(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintStartPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printStartPageRequest(c, Window), cookie) + return PrintStartPageCookie{cookie} +} + +// PrintStartPageChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintStartPageCookie.Check() +func PrintStartPageChecked(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintStartPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printStartPageRequest(c, Window), cookie) + return PrintStartPageCookie{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 PrintStartPageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintStartPage +// printStartPageRequest writes a PrintStartPage request to a byte slice. +func printStartPageRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -2403,13 +2403,13 @@ func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 24 // request opcode + buf[b] = 13 // 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(Context)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf diff --git a/nexgb/xproto/xproto.go b/nexgb/xproto/xproto.go index 7527db5..f162b19 100644 --- a/nexgb/xproto/xproto.go +++ b/nexgb/xproto/xproto.go @@ -2,7 +2,7 @@ package xproto /* - This file was generated by xproto.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xproto.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -23,163 +23,195 @@ func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo { return &s.Roots[c.DefaultScreen] } -// Skipping definition for base type 'Byte' +// BadAccess is the error number for a BadAccess. +const BadAccess = 10 -// Skipping definition for base type 'Int8' +type AccessError RequestError -// Skipping definition for base type 'Card16' +// AccessErrorNew constructs a AccessError value that implements xgb.Error from a byte slice. +func AccessErrorNew(buf []byte) xgb.Error { + v := AccessError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Access" + return v +} -// Skipping definition for base type 'Char' +// SequenceId returns the sequence id attached to the BadAccess error. +// This is mostly used internally. +func (err AccessError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Card32' +// BadId returns the 'BadValue' number if one exists for the BadAccess error. If no bad value exists, 0 is returned. +func (err AccessError) BadId() uint32 { + return err.BadValue +} -// Skipping definition for base type 'Double' +// Error returns a rudimentary string representation of the BadAccess error. +func (err AccessError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAccess {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Bool' +func init() { + xgb.NewErrorFuncs[10] = AccessErrorNew +} -// Skipping definition for base type 'Float' +const ( + AccessControlDisable = 0 + AccessControlEnable = 1 +) -// Skipping definition for base type 'Card8' +// BadAlloc is the error number for a BadAlloc. +const BadAlloc = 11 -// Skipping definition for base type 'Int16' +type AllocError RequestError -// Skipping definition for base type 'Int32' +// AllocErrorNew constructs a AllocError value that implements xgb.Error from a byte slice. +func AllocErrorNew(buf []byte) xgb.Error { + v := AllocError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Alloc" + return v +} -// Skipping definition for base type 'Void' +// SequenceId returns the sequence id attached to the BadAlloc error. +// This is mostly used internally. +func (err AllocError) SequenceId() uint16 { + return err.Sequence +} -const ( - VisualClassStaticGray = 0 - VisualClassGrayScale = 1 - VisualClassStaticColor = 2 - VisualClassPseudoColor = 3 - VisualClassTrueColor = 4 - VisualClassDirectColor = 5 -) +// BadId returns the 'BadValue' number if one exists for the BadAlloc error. If no bad value exists, 0 is returned. +func (err AllocError) BadId() uint32 { + return err.BadValue +} -const ( - EventMaskNoEvent = 0 - EventMaskKeyPress = 1 - EventMaskKeyRelease = 2 - EventMaskButtonPress = 4 - EventMaskButtonRelease = 8 - EventMaskEnterWindow = 16 - EventMaskLeaveWindow = 32 - EventMaskPointerMotion = 64 - EventMaskPointerMotionHint = 128 - EventMaskButton1Motion = 256 - EventMaskButton2Motion = 512 - EventMaskButton3Motion = 1024 - EventMaskButton4Motion = 2048 - EventMaskButton5Motion = 4096 - EventMaskButtonMotion = 8192 - EventMaskKeymapState = 16384 - EventMaskExposure = 32768 - EventMaskVisibilityChange = 65536 - EventMaskStructureNotify = 131072 - EventMaskResizeRedirect = 262144 - EventMaskSubstructureNotify = 524288 - EventMaskSubstructureRedirect = 1048576 - EventMaskFocusChange = 2097152 - EventMaskPropertyChange = 4194304 - EventMaskColorMapChange = 8388608 - EventMaskOwnerGrabButton = 16777216 -) +// Error returns a rudimentary string representation of the BadAlloc error. +func (err AllocError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -const ( - BackingStoreNotUseful = 0 - BackingStoreWhenMapped = 1 - BackingStoreAlways = 2 -) +func init() { + xgb.NewErrorFuncs[11] = AllocErrorNew +} const ( - ImageOrderLSBFirst = 0 - ImageOrderMSBFirst = 1 + AllowAsyncPointer = 0 + AllowSyncPointer = 1 + AllowReplayPointer = 2 + AllowAsyncKeyboard = 3 + AllowSyncKeyboard = 4 + AllowReplayKeyboard = 5 + AllowAsyncBoth = 6 + AllowSyncBoth = 7 ) -const ( - ModMaskShift = 1 - ModMaskLock = 2 - ModMaskControl = 4 - ModMask1 = 8 - ModMask2 = 16 - ModMask3 = 32 - ModMask4 = 64 - ModMask5 = 128 - ModMaskAny = 32768 -) +type Arc struct { + X int16 + Y int16 + Width uint16 + Height uint16 + Angle1 int16 + Angle2 int16 +} -const ( - KeyButMaskShift = 1 - KeyButMaskLock = 2 - KeyButMaskControl = 4 - KeyButMaskMod1 = 8 - KeyButMaskMod2 = 16 - KeyButMaskMod3 = 32 - KeyButMaskMod4 = 64 - KeyButMaskMod5 = 128 - KeyButMaskButton1 = 256 - KeyButMaskButton2 = 512 - KeyButMaskButton3 = 1024 - KeyButMaskButton4 = 2048 - KeyButMaskButton5 = 4096 -) +// ArcRead reads a byte slice into a Arc value. +func ArcRead(buf []byte, v *Arc) int { + b := 0 -const ( - WindowNone = 0 -) + v.X = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - ButtonMask1 = 256 - ButtonMask2 = 512 - ButtonMask3 = 1024 - ButtonMask4 = 2048 - ButtonMask5 = 4096 - ButtonMaskAny = 32768 -) + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - MotionNormal = 0 - MotionHint = 1 -) + v.Width = xgb.Get16(buf[b:]) + b += 2 -const ( - NotifyDetailAncestor = 0 - NotifyDetailVirtual = 1 - NotifyDetailInferior = 2 - NotifyDetailNonlinear = 3 - NotifyDetailNonlinearVirtual = 4 - NotifyDetailPointer = 5 - NotifyDetailPointerRoot = 6 - NotifyDetailNone = 7 -) + v.Height = xgb.Get16(buf[b:]) + b += 2 -const ( - NotifyModeNormal = 0 - NotifyModeGrab = 1 - NotifyModeUngrab = 2 - NotifyModeWhileGrabbed = 3 -) + v.Angle1 = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - VisibilityUnobscured = 0 - VisibilityPartiallyObscured = 1 - VisibilityFullyObscured = 2 -) + v.Angle2 = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - PlaceOnTop = 0 - PlaceOnBottom = 1 -) + return b +} -const ( - PropertyNewValue = 0 - PropertyDelete = 1 -) +// ArcReadList reads a byte slice into a list of Arc values. +func ArcReadList(buf []byte, dest []Arc) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Arc{} + b += ArcRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Arc value to a byte slice. +func (v Arc) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle2)) + b += 2 + + return buf +} + +// ArcListBytes writes a list of Arc values to a byte slice. +func ArcListBytes(buf []byte, list []Arc) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} const ( - TimeCurrentTime = 0 + ArcModeChord = 0 + ArcModePieSlice = 1 ) +type Atom uint32 + +func NewAtomId(c *xgb.Conn) (Atom, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Atom(id), nil +} + const ( AtomNone = 0 AtomAny = 0 @@ -253,130 +285,68 @@ const ( AtomWmTransientFor = 68 ) -const ( - ColormapStateUninstalled = 0 - ColormapStateInstalled = 1 -) - -const ( - ColormapNone = 0 -) - -const ( - MappingModifier = 0 - MappingKeyboard = 1 - MappingPointer = 2 -) - -const ( - WindowClassCopyFromParent = 0 - WindowClassInputOutput = 1 - WindowClassInputOnly = 2 -) - -const ( - CwBackPixmap = 1 - CwBackPixel = 2 - CwBorderPixmap = 4 - CwBorderPixel = 8 - CwBitGravity = 16 - CwWinGravity = 32 - CwBackingStore = 64 - CwBackingPlanes = 128 - CwBackingPixel = 256 - CwOverrideRedirect = 512 - CwSaveUnder = 1024 - CwEventMask = 2048 - CwDontPropagate = 4096 - CwColormap = 8192 - CwCursor = 16384 -) - -const ( - BackPixmapNone = 0 - BackPixmapParentRelative = 1 -) - -const ( - GravityBitForget = 0 - GravityWinUnmap = 0 - GravityNorthWest = 1 - GravityNorth = 2 - GravityNorthEast = 3 - GravityWest = 4 - GravityCenter = 5 - GravityEast = 6 - GravitySouthWest = 7 - GravitySouth = 8 - GravitySouthEast = 9 - GravityStatic = 10 -) +// BadAtom is the error number for a BadAtom. +const BadAtom = 5 -const ( - MapStateUnmapped = 0 - MapStateUnviewable = 1 - MapStateViewable = 2 -) +type AtomError ValueError -const ( - SetModeInsert = 0 - SetModeDelete = 1 -) +// AtomErrorNew constructs a AtomError value that implements xgb.Error from a byte slice. +func AtomErrorNew(buf []byte) xgb.Error { + v := AtomError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Atom" + return v +} -const ( - ConfigWindowX = 1 - ConfigWindowY = 2 - ConfigWindowWidth = 4 - ConfigWindowHeight = 8 - ConfigWindowBorderWidth = 16 - ConfigWindowSibling = 32 - ConfigWindowStackMode = 64 -) +// SequenceId returns the sequence id attached to the BadAtom error. +// This is mostly used internally. +func (err AtomError) SequenceId() uint16 { + return err.Sequence +} -const ( - StackModeAbove = 0 - StackModeBelow = 1 - StackModeTopIf = 2 - StackModeBottomIf = 3 - StackModeOpposite = 4 -) +// BadId returns the 'BadValue' number if one exists for the BadAtom error. If no bad value exists, 0 is returned. +func (err AtomError) BadId() uint32 { + return err.BadValue +} -const ( - CirculateRaiseLowest = 0 - CirculateLowerHighest = 1 -) +// Error returns a rudimentary string representation of the BadAtom error. +func (err AtomError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -const ( - PropModeReplace = 0 - PropModePrepend = 1 - PropModeAppend = 2 -) +func init() { + xgb.NewErrorFuncs[5] = AtomErrorNew +} const ( - GetPropertyTypeAny = 0 + AutoRepeatModeOff = 0 + AutoRepeatModeOn = 1 + AutoRepeatModeDefault = 2 ) const ( - SendEventDestPointerWindow = 0 - SendEventDestItemFocus = 1 + BackPixmapNone = 0 + BackPixmapParentRelative = 1 ) const ( - GrabModeSync = 0 - GrabModeAsync = 1 + BackingStoreNotUseful = 0 + BackingStoreWhenMapped = 1 + BackingStoreAlways = 2 ) const ( - GrabStatusSuccess = 0 - GrabStatusAlreadyGrabbed = 1 - GrabStatusInvalidTime = 2 - GrabStatusNotViewable = 3 - GrabStatusFrozen = 4 + BlankingNotPreferred = 0 + BlankingPreferred = 1 + BlankingDefault = 2 ) -const ( - CursorNone = 0 -) +type Button byte const ( ButtonIndexAny = 0 @@ -388,1626 +358,259 @@ const ( ) const ( - GrabAny = 0 -) - -const ( - AllowAsyncPointer = 0 - AllowSyncPointer = 1 - AllowReplayPointer = 2 - AllowAsyncKeyboard = 3 - AllowSyncKeyboard = 4 - AllowReplayKeyboard = 5 - AllowAsyncBoth = 6 - AllowSyncBoth = 7 -) - -const ( - InputFocusNone = 0 - InputFocusPointerRoot = 1 - InputFocusParent = 2 - InputFocusFollowKeyboard = 3 -) - -const ( - FontDrawLeftToRight = 0 - FontDrawRightToLeft = 1 -) - -const ( - GcFunction = 1 - GcPlaneMask = 2 - GcForeground = 4 - GcBackground = 8 - GcLineWidth = 16 - GcLineStyle = 32 - GcCapStyle = 64 - GcJoinStyle = 128 - GcFillStyle = 256 - GcFillRule = 512 - GcTile = 1024 - GcStipple = 2048 - GcTileStippleOriginX = 4096 - GcTileStippleOriginY = 8192 - GcFont = 16384 - GcSubwindowMode = 32768 - GcGraphicsExposures = 65536 - GcClipOriginX = 131072 - GcClipOriginY = 262144 - GcClipMask = 524288 - GcDashOffset = 1048576 - GcDashList = 2097152 - GcArcMode = 4194304 -) - -const ( - GxClear = 0 - GxAnd = 1 - GxAndReverse = 2 - GxCopy = 3 - GxAndInverted = 4 - GxNoop = 5 - GxXor = 6 - GxOr = 7 - GxNor = 8 - GxEquiv = 9 - GxInvert = 10 - GxOrReverse = 11 - GxCopyInverted = 12 - GxOrInverted = 13 - GxNand = 14 - GxSet = 15 -) - -const ( - LineStyleSolid = 0 - LineStyleOnOffDash = 1 - LineStyleDoubleDash = 2 -) - -const ( - CapStyleNotLast = 0 - CapStyleButt = 1 - CapStyleRound = 2 - CapStyleProjecting = 3 -) - -const ( - JoinStyleMiter = 0 - JoinStyleRound = 1 - JoinStyleBevel = 2 -) - -const ( - FillStyleSolid = 0 - FillStyleTiled = 1 - FillStyleStippled = 2 - FillStyleOpaqueStippled = 3 -) - -const ( - FillRuleEvenOdd = 0 - FillRuleWinding = 1 -) - -const ( - SubwindowModeClipByChildren = 0 - SubwindowModeIncludeInferiors = 1 -) - -const ( - ArcModeChord = 0 - ArcModePieSlice = 1 -) - -const ( - ClipOrderingUnsorted = 0 - ClipOrderingYSorted = 1 - ClipOrderingYXSorted = 2 - ClipOrderingYXBanded = 3 -) - -const ( - CoordModeOrigin = 0 - CoordModePrevious = 1 -) - -const ( - PolyShapeComplex = 0 - PolyShapeNonconvex = 1 - PolyShapeConvex = 2 -) - -const ( - ImageFormatXYBitmap = 0 - ImageFormatXYPixmap = 1 - ImageFormatZPixmap = 2 -) - -const ( - ColormapAllocNone = 0 - ColormapAllocAll = 1 -) - -const ( - ColorFlagRed = 1 - ColorFlagGreen = 2 - ColorFlagBlue = 4 -) - -const ( - PixmapNone = 0 -) - -const ( - FontNone = 0 -) - -const ( - QueryShapeOfLargestCursor = 0 - QueryShapeOfFastestTile = 1 - QueryShapeOfFastestStipple = 2 -) - -const ( - KbKeyClickPercent = 1 - KbBellPercent = 2 - KbBellPitch = 4 - KbBellDuration = 8 - KbLed = 16 - KbLedMode = 32 - KbKey = 64 - KbAutoRepeatMode = 128 -) - -const ( - LedModeOff = 0 - LedModeOn = 1 -) - -const ( - AutoRepeatModeOff = 0 - AutoRepeatModeOn = 1 - AutoRepeatModeDefault = 2 -) - -const ( - BlankingNotPreferred = 0 - BlankingPreferred = 1 - BlankingDefault = 2 -) - -const ( - ExposuresNotAllowed = 0 - ExposuresAllowed = 1 - ExposuresDefault = 2 -) - -const ( - HostModeInsert = 0 - HostModeDelete = 1 -) - -const ( - FamilyInternet = 0 - FamilyDECnet = 1 - FamilyChaos = 2 - FamilyServerInterpreted = 5 - FamilyInternet6 = 6 -) - -const ( - AccessControlDisable = 0 - AccessControlEnable = 1 -) - -const ( - CloseDownDestroyAll = 0 - CloseDownRetainPermanent = 1 - CloseDownRetainTemporary = 2 -) - -const ( - KillAllTemporary = 0 -) - -const ( - ScreenSaverReset = 0 - ScreenSaverActive = 1 -) - -const ( - MappingStatusSuccess = 0 - MappingStatusBusy = 1 - MappingStatusFailure = 2 -) - -const ( - MapIndexShift = 0 - MapIndexLock = 1 - MapIndexControl = 2 - MapIndex1 = 3 - MapIndex2 = 4 - MapIndex3 = 5 - MapIndex4 = 6 - MapIndex5 = 7 + ButtonMask1 = 256 + ButtonMask2 = 512 + ButtonMask3 = 1024 + ButtonMask4 = 2048 + ButtonMask5 = 4096 + ButtonMaskAny = 32768 ) -type Window uint32 - -func NewWindowId(c *xgb.Conn) (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} - -type Pixmap uint32 - -func NewPixmapId(c *xgb.Conn) (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} - -type Cursor uint32 - -func NewCursorId(c *xgb.Conn) (Cursor, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Cursor(id), nil -} - -type Font uint32 - -func NewFontId(c *xgb.Conn) (Font, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Font(id), nil -} - -type Gcontext uint32 - -func NewGcontextId(c *xgb.Conn) (Gcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Gcontext(id), nil -} - -type Colormap uint32 - -func NewColormapId(c *xgb.Conn) (Colormap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Colormap(id), nil -} - -type Atom uint32 - -func NewAtomId(c *xgb.Conn) (Atom, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Atom(id), nil -} - -type Drawable uint32 - -func NewDrawableId(c *xgb.Conn) (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil -} - -type Fontable uint32 - -func NewFontableId(c *xgb.Conn) (Fontable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fontable(id), nil -} - -type Visualid uint32 - -type Timestamp uint32 - -type Keysym uint32 - -type Keycode byte - -type Button byte - -type Char2b struct { - Byte1 byte - Byte2 byte -} - -// Char2bRead reads a byte slice into a Char2b value. -func Char2bRead(buf []byte, v *Char2b) int { - b := 0 - - v.Byte1 = buf[b] - b += 1 - - v.Byte2 = buf[b] - b += 1 - - return b -} - -// Char2bReadList reads a byte slice into a list of Char2b values. -func Char2bReadList(buf []byte, dest []Char2b) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Char2b{} - b += Char2bRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Char2b value to a byte slice. -func (v Char2b) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.Byte1 - b += 1 - - buf[b] = v.Byte2 - b += 1 - - return buf -} - -// Char2bListBytes writes a list of Char2b values to a byte slice. -func Char2bListBytes(buf []byte, list []Char2b) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Point struct { - X int16 - Y int16 -} - -// PointRead reads a byte slice into a Point value. -func PointRead(buf []byte, v *Point) int { - b := 0 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - return b -} - -// PointReadList reads a byte slice into a list of Point values. -func PointReadList(buf []byte, dest []Point) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Point{} - b += PointRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Point value to a byte slice. -func (v Point) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// PointListBytes writes a list of Point values to a byte slice. -func PointListBytes(buf []byte, list []Point) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Rectangle struct { - X int16 - Y int16 - Width uint16 - Height uint16 -} - -// RectangleRead reads a byte slice into a Rectangle value. -func RectangleRead(buf []byte, v *Rectangle) int { - b := 0 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - return b -} - -// RectangleReadList reads a byte slice into a list of Rectangle values. -func RectangleReadList(buf []byte, dest []Rectangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rectangle{} - b += RectangleRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Rectangle value to a byte slice. -func (v Rectangle) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -// RectangleListBytes writes a list of Rectangle values to a byte slice. -func RectangleListBytes(buf []byte, list []Rectangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Arc struct { - X int16 - Y int16 - Width uint16 - Height uint16 - Angle1 int16 - Angle2 int16 -} - -// ArcRead reads a byte slice into a Arc value. -func ArcRead(buf []byte, v *Arc) int { - b := 0 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.Angle1 = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Angle2 = int16(xgb.Get16(buf[b:])) - b += 2 - - return b -} - -// ArcReadList reads a byte slice into a list of Arc values. -func ArcReadList(buf []byte, dest []Arc) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Arc{} - b += ArcRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Arc value to a byte slice. -func (v Arc) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Angle1)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Angle2)) - b += 2 - - return buf -} - -// ArcListBytes writes a list of Arc values to a byte slice. -func ArcListBytes(buf []byte, list []Arc) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Format struct { - Depth byte - BitsPerPixel byte - ScanlinePad byte - // padding: 5 bytes -} - -// FormatRead reads a byte slice into a Format value. -func FormatRead(buf []byte, v *Format) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - v.BitsPerPixel = buf[b] - b += 1 - - v.ScanlinePad = buf[b] - b += 1 - - b += 5 // padding - - return b -} - -// FormatReadList reads a byte slice into a list of Format values. -func FormatReadList(buf []byte, dest []Format) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Format{} - b += FormatRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Format value to a byte slice. -func (v Format) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.Depth - b += 1 - - buf[b] = v.BitsPerPixel - b += 1 - - buf[b] = v.ScanlinePad - b += 1 - - b += 5 // padding - - return buf -} - -// FormatListBytes writes a list of Format values to a byte slice. -func FormatListBytes(buf []byte, list []Format) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type VisualInfo struct { - VisualId Visualid - Class byte - BitsPerRgbValue byte - ColormapEntries uint16 - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 4 bytes -} - -// VisualInfoRead reads a byte slice into a VisualInfo value. -func VisualInfoRead(buf []byte, v *VisualInfo) int { - b := 0 - - v.VisualId = Visualid(xgb.Get32(buf[b:])) - b += 4 - - v.Class = buf[b] - b += 1 - - v.BitsPerRgbValue = buf[b] - b += 1 - - v.ColormapEntries = xgb.Get16(buf[b:]) - b += 2 - - v.RedMask = xgb.Get32(buf[b:]) - b += 4 - - v.GreenMask = xgb.Get32(buf[b:]) - b += 4 - - v.BlueMask = xgb.Get32(buf[b:]) - b += 4 - - b += 4 // padding - - return b -} - -// VisualInfoReadList reads a byte slice into a list of VisualInfo values. -func VisualInfoReadList(buf []byte, dest []VisualInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = VisualInfo{} - b += VisualInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a VisualInfo value to a byte slice. -func (v VisualInfo) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - xgb.Put32(buf[b:], uint32(v.VisualId)) - b += 4 - - buf[b] = v.Class - b += 1 - - buf[b] = v.BitsPerRgbValue - b += 1 - - xgb.Put16(buf[b:], v.ColormapEntries) - b += 2 - - xgb.Put32(buf[b:], v.RedMask) - b += 4 - - xgb.Put32(buf[b:], v.GreenMask) - b += 4 - - xgb.Put32(buf[b:], v.BlueMask) - b += 4 - - b += 4 // padding - - return buf -} - -// VisualInfoListBytes writes a list of VisualInfo values to a byte slice. -func VisualInfoListBytes(buf []byte, list []VisualInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} +// ButtonPress is the event number for a ButtonPressEvent. +const ButtonPress = 4 -type DepthInfo struct { - Depth byte +type ButtonPressEvent struct { + Sequence uint16 + Detail Button + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool // padding: 1 bytes - VisualsLen uint16 - // padding: 4 bytes - Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) -} - -// DepthInfoRead reads a byte slice into a DepthInfo value. -func DepthInfoRead(buf []byte, v *DepthInfo) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - b += 1 // padding - - v.VisualsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Visuals = make([]VisualInfo, v.VisualsLen) - b += VisualInfoReadList(buf[b:], v.Visuals) - - return b -} - -// DepthInfoReadList reads a byte slice into a list of DepthInfo values. -func DepthInfoReadList(buf []byte, dest []DepthInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DepthInfo{} - b += DepthInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) } -// Bytes writes a DepthInfo value to a byte slice. -func (v DepthInfo) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) - b := 0 +// ButtonPressEventNew constructs a ButtonPressEvent value that implements xgb.Event from a byte slice. +func ButtonPressEventNew(buf []byte) xgb.Event { + v := ButtonPressEvent{} + b := 1 // don't read event number - buf[b] = v.Depth + v.Detail = Button(buf[b]) b += 1 - b += 1 // padding - - xgb.Put16(buf[b:], v.VisualsLen) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - b += 4 // padding - - b += VisualInfoListBytes(buf[b:], v.Visuals) - - return buf -} - -// DepthInfoListBytes writes a list of DepthInfo values to a byte slice. -func DepthInfoListBytes(buf []byte, list []DepthInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. -func DepthInfoListSize(list []DepthInfo) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) - } - return size -} - -type ScreenInfo struct { - Root Window - DefaultColormap Colormap - WhitePixel uint32 - BlackPixel uint32 - CurrentInputMasks uint32 - WidthInPixels uint16 - HeightInPixels uint16 - WidthInMillimeters uint16 - HeightInMillimeters uint16 - MinInstalledMaps uint16 - MaxInstalledMaps uint16 - RootVisual Visualid - BackingStores byte - SaveUnders bool - RootDepth byte - AllowedDepthsLen byte - AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) -} - -// ScreenInfoRead reads a byte slice into a ScreenInfo value. -func ScreenInfoRead(buf []byte, v *ScreenInfo) int { - b := 0 - - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - - v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.WhitePixel = xgb.Get32(buf[b:]) + v.Root = Window(xgb.Get32(buf[b:])) b += 4 - v.BlackPixel = xgb.Get32(buf[b:]) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.CurrentInputMasks = xgb.Get32(buf[b:]) + v.Child = Window(xgb.Get32(buf[b:])) b += 4 - v.WidthInPixels = xgb.Get16(buf[b:]) - b += 2 - - v.HeightInPixels = xgb.Get16(buf[b:]) + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - v.WidthInMillimeters = xgb.Get16(buf[b:]) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.HeightInMillimeters = xgb.Get16(buf[b:]) + v.EventX = int16(xgb.Get16(buf[b:])) b += 2 - v.MinInstalledMaps = xgb.Get16(buf[b:]) + v.EventY = int16(xgb.Get16(buf[b:])) b += 2 - v.MaxInstalledMaps = xgb.Get16(buf[b:]) + v.State = xgb.Get16(buf[b:]) b += 2 - v.RootVisual = Visualid(xgb.Get32(buf[b:])) - b += 4 - - v.BackingStores = buf[b] - b += 1 - if buf[b] == 1 { - v.SaveUnders = true + v.SameScreen = true } else { - v.SaveUnders = false + v.SameScreen = false } b += 1 - v.RootDepth = buf[b] - b += 1 - - v.AllowedDepthsLen = buf[b] - b += 1 - - v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) - b += DepthInfoReadList(buf[b:], v.AllowedDepths) + b += 1 // padding - return b + return v } -// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. -func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { +// Bytes writes a ButtonPressEvent value to a byte slice. +func (v ButtonPressEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ScreenInfo{} - b += ScreenInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} -// Bytes writes a ScreenInfo value to a byte slice. -func (v ScreenInfo) Bytes() []byte { - buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) - b := 0 + // write event number + buf[b] = 4 + b += 1 - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 + buf[b] = byte(v.Detail) + b += 1 - xgb.Put32(buf[b:], uint32(v.DefaultColormap)) - b += 4 + b += 2 // skip sequence number - xgb.Put32(buf[b:], v.WhitePixel) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], v.BlackPixel) + xgb.Put32(buf[b:], uint32(v.Root)) b += 4 - xgb.Put32(buf[b:], v.CurrentInputMasks) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put16(buf[b:], v.WidthInPixels) - b += 2 + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 - xgb.Put16(buf[b:], v.HeightInPixels) + xgb.Put16(buf[b:], uint16(v.RootX)) b += 2 - xgb.Put16(buf[b:], v.WidthInMillimeters) + xgb.Put16(buf[b:], uint16(v.RootY)) b += 2 - xgb.Put16(buf[b:], v.HeightInMillimeters) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], v.MinInstalledMaps) + xgb.Put16(buf[b:], uint16(v.EventY)) b += 2 - xgb.Put16(buf[b:], v.MaxInstalledMaps) + xgb.Put16(buf[b:], v.State) b += 2 - xgb.Put32(buf[b:], uint32(v.RootVisual)) - b += 4 - - buf[b] = v.BackingStores - b += 1 - - if v.SaveUnders { + if v.SameScreen { buf[b] = 1 } else { buf[b] = 0 } b += 1 - buf[b] = v.RootDepth - b += 1 - - buf[b] = v.AllowedDepthsLen - b += 1 - - b += DepthInfoListBytes(buf[b:], v.AllowedDepths) - - return buf -} - -// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. -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 -} - -// ScreenInfoListSize computes the size (bytes) of a list of ScreenInfo values. -func ScreenInfoListSize(list []ScreenInfo) int { - size := 0 - for _, item := range list { - size += (40 + DepthInfoListSize(item.AllowedDepths)) - } - return size -} - -type SetupRequest struct { - ByteOrder byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - AuthorizationProtocolNameLen uint16 - AuthorizationProtocolDataLen uint16 - // padding: 2 bytes - AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) - AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) -} - -// SetupRequestRead reads a byte slice into a SetupRequest value. -func SetupRequestRead(buf []byte, v *SetupRequest) int { - b := 0 - - v.ByteOrder = buf[b] - b += 1 - b += 1 // padding - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) - b += 2 - - v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - { - byteString := make([]byte, v.AuthorizationProtocolNameLen) - copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) - v.AuthorizationProtocolName = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - } - - { - byteString := make([]byte, v.AuthorizationProtocolDataLen) - copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) - v.AuthorizationProtocolData = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) - } - - return b -} - -// SetupRequestReadList reads a byte slice into a list of SetupRequest values. -func SetupRequestReadList(buf []byte, dest []SetupRequest) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupRequest{} - b += SetupRequestRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a SetupRequest value to a byte slice. -func (v SetupRequest) Bytes() []byte { - buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) - b := 0 - - buf[b] = v.ByteOrder - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) - b += 2 - - xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - - copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) - return buf } -// SetupRequestListBytes writes a list of SetupRequest values to a byte slice. -func SetupRequestListBytes(buf []byte, list []SetupRequest) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. -func SetupRequestListSize(list []SetupRequest) int { - size := 0 - for _, item := range list { - size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) - } - return size -} - -type SetupFailed struct { - Status byte - ReasonLen byte - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - Reason string // size: xgb.Pad((int(ReasonLen) * 1)) -} - -// SetupFailedRead reads a byte slice into a SetupFailed value. -func SetupFailedRead(buf []byte, v *SetupFailed) int { - b := 0 - - v.Status = buf[b] - b += 1 - - v.ReasonLen = buf[b] - b += 1 - - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.ReasonLen) - copy(byteString[:v.ReasonLen], buf[b:]) - v.Reason = string(byteString) - b += xgb.Pad(int(v.ReasonLen)) - } - - return b +// SequenceId returns the sequence id attached to the ButtonPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ButtonPressEvent) SequenceId() uint16 { + return v.Sequence } -// SetupFailedReadList reads a byte slice into a list of SetupFailed values. -func SetupFailedReadList(buf []byte, dest []SetupFailed) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupFailed{} - b += SetupFailedRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// String is a rudimentary string representation of ButtonPressEvent. +func (v ButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// Bytes writes a SetupFailed value to a byte slice. -func (v SetupFailed) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - buf[b] = v.ReasonLen - b += 1 - - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - xgb.Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:v.ReasonLen]) - b += xgb.Pad(int(v.ReasonLen)) - - return buf +func init() { + xgb.NewEventFuncs[4] = ButtonPressEventNew } -// SetupFailedListBytes writes a list of SetupFailed values to a byte slice. -func SetupFailedListBytes(buf []byte, list []SetupFailed) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} +// ButtonRelease is the event number for a ButtonReleaseEvent. +const ButtonRelease = 5 -// SetupFailedListSize computes the size (bytes) of a list of SetupFailed values. -func SetupFailedListSize(list []SetupFailed) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.ReasonLen) * 1))) - } - return size -} +type ButtonReleaseEvent ButtonPressEvent -type SetupAuthenticate struct { - Status byte - // padding: 5 bytes - Length uint16 - Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) +// ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. +func ButtonReleaseEventNew(buf []byte) xgb.Event { + return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) } -// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. -func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { - b := 0 - - v.Status = buf[b] - b += 1 - - b += 5 // padding - - v.Length = xgb.Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, (int(v.Length) * 4)) - copy(byteString[:(int(v.Length)*4)], buf[b:]) - v.Reason = string(byteString) - b += xgb.Pad(int((int(v.Length) * 4))) - } - - return b +// Bytes writes a ButtonReleaseEvent value to a byte slice. +func (v ButtonReleaseEvent) Bytes() []byte { + return ButtonPressEvent(v).Bytes() } -// SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values. -func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupAuthenticate{} - b += SetupAuthenticateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the ButtonRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ButtonReleaseEvent) SequenceId() uint16 { + return v.Sequence } -// Bytes writes a SetupAuthenticate value to a byte slice. -func (v SetupAuthenticate) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - b += 5 // padding - - xgb.Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:(int(v.Length)*4)]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return buf +func (v ButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// SetupAuthenticateListBytes writes a list of SetupAuthenticate values to a byte slice. -func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +func init() { + xgb.NewEventFuncs[5] = ButtonReleaseEventNew } -// SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. -func SetupAuthenticateListSize(list []SetupAuthenticate) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) - } - return size -} +const ( + CapStyleNotLast = 0 + CapStyleButt = 1 + CapStyleRound = 2 + CapStyleProjecting = 3 +) -type SetupInfo struct { - Status byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - ReleaseNumber uint32 - ResourceIdBase uint32 - ResourceIdMask uint32 - MotionBufferSize uint32 - VendorLen uint16 - MaximumRequestLength uint16 - RootsLen byte - PixmapFormatsLen byte - ImageByteOrder byte - BitmapFormatBitOrder byte - BitmapFormatScanlineUnit byte - BitmapFormatScanlinePad byte - MinKeycode Keycode - MaxKeycode Keycode - // padding: 4 bytes - Vendor string // size: xgb.Pad((int(VendorLen) * 1)) - PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) - Roots []ScreenInfo // size: ScreenInfoListSize(Roots) +type Char2b struct { + Byte1 byte + Byte2 byte } -// SetupInfoRead reads a byte slice into a SetupInfo value. -func SetupInfoRead(buf []byte, v *SetupInfo) int { +// Char2bRead reads a byte slice into a Char2b value. +func Char2bRead(buf []byte, v *Char2b) int { b := 0 - v.Status = buf[b] - b += 1 - - b += 1 // padding - - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get16(buf[b:]) - b += 2 - - v.ReleaseNumber = xgb.Get32(buf[b:]) - b += 4 - - v.ResourceIdBase = xgb.Get32(buf[b:]) - b += 4 - - v.ResourceIdMask = xgb.Get32(buf[b:]) - b += 4 - - v.MotionBufferSize = xgb.Get32(buf[b:]) - b += 4 - - v.VendorLen = xgb.Get16(buf[b:]) - b += 2 - - v.MaximumRequestLength = xgb.Get16(buf[b:]) - b += 2 - - v.RootsLen = buf[b] - b += 1 - - v.PixmapFormatsLen = buf[b] - b += 1 - - v.ImageByteOrder = buf[b] - b += 1 - - v.BitmapFormatBitOrder = buf[b] - b += 1 - - v.BitmapFormatScanlineUnit = buf[b] - b += 1 - - v.BitmapFormatScanlinePad = buf[b] - b += 1 - - v.MinKeycode = Keycode(buf[b]) + v.Byte1 = buf[b] b += 1 - v.MaxKeycode = Keycode(buf[b]) + v.Byte2 = buf[b] b += 1 - b += 4 // padding - - { - byteString := make([]byte, v.VendorLen) - copy(byteString[:v.VendorLen], buf[b:]) - v.Vendor = string(byteString) - b += xgb.Pad(int(v.VendorLen)) - } - - v.PixmapFormats = make([]Format, v.PixmapFormatsLen) - b += FormatReadList(buf[b:], v.PixmapFormats) - - v.Roots = make([]ScreenInfo, v.RootsLen) - b += ScreenInfoReadList(buf[b:], v.Roots) - return b } -// SetupInfoReadList reads a byte slice into a list of SetupInfo values. -func SetupInfoReadList(buf []byte, dest []SetupInfo) int { +// Char2bReadList reads a byte slice into a list of Char2b values. +func Char2bReadList(buf []byte, dest []Char2b) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = SetupInfo{} - b += SetupInfoRead(buf[b:], &dest[i]) + dest[i] = Char2b{} + b += Char2bRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a SetupInfo value to a byte slice. -func (v SetupInfo) Bytes() []byte { - buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) +// Bytes writes a Char2b value to a byte slice. +func (v Char2b) Bytes() []byte { + buf := make([]byte, 2) b := 0 - buf[b] = v.Status - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - xgb.Put16(buf[b:], v.Length) - b += 2 - - xgb.Put32(buf[b:], v.ReleaseNumber) - b += 4 - - xgb.Put32(buf[b:], v.ResourceIdBase) - b += 4 - - xgb.Put32(buf[b:], v.ResourceIdMask) - b += 4 - - xgb.Put32(buf[b:], v.MotionBufferSize) - b += 4 - - xgb.Put16(buf[b:], v.VendorLen) - b += 2 - - xgb.Put16(buf[b:], v.MaximumRequestLength) - b += 2 - - buf[b] = v.RootsLen - b += 1 - - buf[b] = v.PixmapFormatsLen - b += 1 - - buf[b] = v.ImageByteOrder - b += 1 - - buf[b] = v.BitmapFormatBitOrder - b += 1 - - buf[b] = v.BitmapFormatScanlineUnit - b += 1 - - buf[b] = v.BitmapFormatScanlinePad - b += 1 - - buf[b] = byte(v.MinKeycode) + buf[b] = v.Byte1 b += 1 - buf[b] = byte(v.MaxKeycode) + buf[b] = v.Byte2 b += 1 - b += 4 // padding - - copy(buf[b:], v.Vendor[:v.VendorLen]) - b += xgb.Pad(int(v.VendorLen)) - - b += FormatListBytes(buf[b:], v.PixmapFormats) - - b += ScreenInfoListBytes(buf[b:], v.Roots) - return buf } -// SetupInfoListBytes writes a list of SetupInfo values to a byte slice. -func SetupInfoListBytes(buf []byte, list []SetupInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. -func SetupInfoListSize(list []SetupInfo) int { - size := 0 - for _, item := range list { - size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) - } - return size -} - -type Timecoord struct { - Time Timestamp - X int16 - Y int16 -} - -// TimecoordRead reads a byte slice into a Timecoord value. -func TimecoordRead(buf []byte, v *Timecoord) int { - b := 0 - - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - return b -} - -// TimecoordReadList reads a byte slice into a list of Timecoord values. -func TimecoordReadList(buf []byte, dest []Timecoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Timecoord{} - b += TimecoordRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Timecoord value to a byte slice. -func (v Timecoord) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// TimecoordListBytes writes a list of Timecoord values to a byte slice. -func TimecoordListBytes(buf []byte, list []Timecoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Fontprop struct { - Name Atom - Value uint32 -} - -// FontpropRead reads a byte slice into a Fontprop value. -func FontpropRead(buf []byte, v *Fontprop) int { - b := 0 - - v.Name = Atom(xgb.Get32(buf[b:])) - b += 4 - - v.Value = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// FontpropReadList reads a byte slice into a list of Fontprop values. -func FontpropReadList(buf []byte, dest []Fontprop) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Fontprop{} - b += FontpropRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Fontprop value to a byte slice. -func (v Fontprop) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Name)) - b += 4 - - xgb.Put32(buf[b:], v.Value) - b += 4 - - return buf -} - -// FontpropListBytes writes a list of Fontprop values to a byte slice. -func FontpropListBytes(buf []byte, list []Fontprop) int { +// Char2bListBytes writes a list of Char2b values to a byte slice. +func Char2bListBytes(buf []byte, list []Char2b) int { b := 0 var structBytes []byte for _, item := range list { @@ -2100,361 +703,217 @@ func CharinfoListBytes(buf []byte, list []Charinfo) int { return b } -type Str struct { - NameLen byte - Name string // size: xgb.Pad((int(NameLen) * 1)) -} - -// StrRead reads a byte slice into a Str value. -func StrRead(buf []byte, v *Str) int { - b := 0 - - v.NameLen = buf[b] - b += 1 - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } - - return b -} - -// StrReadList reads a byte slice into a list of Str values. -func StrReadList(buf []byte, dest []Str) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Str{} - b += StrRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Str value to a byte slice. -func (v Str) Bytes() []byte { - buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) - b := 0 - - buf[b] = v.NameLen - b += 1 - - copy(buf[b:], v.Name[:v.NameLen]) - b += xgb.Pad(int(v.NameLen)) - - return buf -} - -// StrListBytes writes a list of Str values to a byte slice. -func StrListBytes(buf []byte, list []Str) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// StrListSize computes the size (bytes) of a list of Str values. -func StrListSize(list []Str) int { - size := 0 - for _, item := range list { - size += (1 + xgb.Pad((int(item.NameLen) * 1))) - } - return size -} - -type Segment struct { - X1 int16 - Y1 int16 - X2 int16 - Y2 int16 -} - -// SegmentRead reads a byte slice into a Segment value. -func SegmentRead(buf []byte, v *Segment) 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 +const ( + CirculateRaiseLowest = 0 + CirculateLowerHighest = 1 +) - v.Y2 = int16(xgb.Get16(buf[b:])) - b += 2 +// CirculateNotify is the event number for a CirculateNotifyEvent. +const CirculateNotify = 26 - return b +type CirculateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + // padding: 4 bytes + Place byte + // padding: 3 bytes } -// SegmentReadList reads a byte slice into a list of Segment values. -func SegmentReadList(buf []byte, dest []Segment) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Segment{} - b += SegmentRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} +// CirculateNotifyEventNew constructs a CirculateNotifyEvent value that implements xgb.Event from a byte slice. +func CirculateNotifyEventNew(buf []byte) xgb.Event { + v := CirculateNotifyEvent{} + b := 1 // don't read event number -// Bytes writes a Segment value to a byte slice. -func (v Segment) Bytes() []byte { - buf := make([]byte, 8) - b := 0 + b += 1 // padding - xgb.Put16(buf[b:], uint16(v.X1)) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(v.Y1)) - b += 2 + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 - xgb.Put16(buf[b:], uint16(v.X2)) - b += 2 + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 - xgb.Put16(buf[b:], uint16(v.Y2)) - b += 2 + b += 4 // padding - return buf -} + v.Place = buf[b] + b += 1 -// SegmentListBytes writes a list of Segment values to a byte slice. -func SegmentListBytes(buf []byte, list []Segment) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} + b += 3 // padding -type Coloritem struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Flags byte - // padding: 1 bytes + return v } -// ColoritemRead reads a byte slice into a Coloritem value. -func ColoritemRead(buf []byte, v *Coloritem) int { +// Bytes writes a CirculateNotifyEvent value to a byte slice. +func (v CirculateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.Pixel = xgb.Get32(buf[b:]) - b += 4 - - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 - - v.Blue = xgb.Get16(buf[b:]) - b += 2 - - v.Flags = buf[b] + // write event number + buf[b] = 26 b += 1 b += 1 // padding - return b -} - -// ColoritemReadList reads a byte slice into a list of Coloritem values. -func ColoritemReadList(buf []byte, dest []Coloritem) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Coloritem{} - b += ColoritemRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Coloritem value to a byte slice. -func (v Coloritem) Bytes() []byte { - buf := make([]byte, 12) - b := 0 + b += 2 // skip sequence number - xgb.Put32(buf[b:], v.Pixel) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - xgb.Put16(buf[b:], v.Blue) - b += 2 + b += 4 // padding - buf[b] = v.Flags + buf[b] = v.Place b += 1 - b += 1 // padding + b += 3 // padding return buf } -// ColoritemListBytes writes a list of Coloritem values to a byte slice. -func ColoritemListBytes(buf []byte, list []Coloritem) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the CirculateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CirculateNotifyEvent) SequenceId() uint16 { + return v.Sequence } -type Rgb struct { - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes +// String is a rudimentary string representation of CirculateNotifyEvent. +func (v CirculateNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// RgbRead reads a byte slice into a Rgb value. -func RgbRead(buf []byte, v *Rgb) int { - b := 0 - - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 +func init() { + xgb.NewEventFuncs[26] = CirculateNotifyEventNew +} - v.Blue = xgb.Get16(buf[b:]) - b += 2 +// CirculateRequest is the event number for a CirculateRequestEvent. +const CirculateRequest = 27 - b += 2 // padding +type CirculateRequestEvent CirculateNotifyEvent - return b +// CirculateRequestEventNew constructs a CirculateRequestEvent value that implements xgb.Event from a byte slice. +func CirculateRequestEventNew(buf []byte) xgb.Event { + return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) } -// RgbReadList reads a byte slice into a list of Rgb values. -func RgbReadList(buf []byte, dest []Rgb) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rgb{} - b += RgbRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// Bytes writes a CirculateRequestEvent value to a byte slice. +func (v CirculateRequestEvent) Bytes() []byte { + return CirculateNotifyEvent(v).Bytes() } -// Bytes writes a Rgb value to a byte slice. -func (v Rgb) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 - - xgb.Put16(buf[b:], v.Blue) - b += 2 - - b += 2 // padding +// SequenceId returns the sequence id attached to the CirculateRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CirculateRequestEvent) SequenceId() uint16 { + return v.Sequence +} - return buf +func (v CirculateRequestEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// RgbListBytes writes a list of Rgb values to a byte slice. -func RgbListBytes(buf []byte, list []Rgb) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +func init() { + xgb.NewEventFuncs[27] = CirculateRequestEventNew } -type Host struct { - Family byte - // padding: 1 bytes - AddressLen uint16 - Address []byte // size: xgb.Pad((int(AddressLen) * 1)) +// ClientMessage is the event number for a ClientMessageEvent. +const ClientMessage = 33 + +type ClientMessageEvent struct { + Sequence uint16 + Format byte + Window Window + Type Atom + Data ClientMessageDataUnion } -// HostRead reads a byte slice into a Host value. -func HostRead(buf []byte, v *Host) int { - b := 0 +// ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. +func ClientMessageEventNew(buf []byte) xgb.Event { + v := ClientMessageEvent{} + b := 1 // don't read event number - v.Family = buf[b] + v.Format = buf[b] b += 1 - b += 1 // padding - - v.AddressLen = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Address = make([]byte, v.AddressLen) - copy(v.Address[:v.AddressLen], buf[b:]) - b += xgb.Pad(int(v.AddressLen)) + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 - return b -} + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 -// HostReadList reads a byte slice into a list of Host values. -func HostReadList(buf []byte, dest []Host) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Host{} - b += HostRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + v.Data = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &v.Data) + + return v } -// Bytes writes a Host value to a byte slice. -func (v Host) Bytes() []byte { - buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) +// Bytes writes a ClientMessageEvent value to a byte slice. +func (v ClientMessageEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.Family + // write event number + buf[b] = 33 b += 1 - b += 1 // padding + buf[b] = v.Format + b += 1 - xgb.Put16(buf[b:], v.AddressLen) - b += 2 + b += 2 // skip sequence number - copy(buf[b:], v.Address[:v.AddressLen]) - b += xgb.Pad(int(v.AddressLen)) + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Type)) + b += 4 + + { + unionBytes := v.Data.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } return buf } -// HostListBytes writes a list of Host values to a byte slice. -func HostListBytes(buf []byte, list []Host) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the ClientMessage event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ClientMessageEvent) SequenceId() uint16 { + return v.Sequence } -// HostListSize computes the size (bytes) of a list of Host values. -func HostListSize(list []Host) int { - size := 0 - for _, item := range list { - size += (4 + xgb.Pad((int(item.AddressLen) * 1))) - } - return size +// String is a rudimentary string representation of ClientMessageEvent. +func (v ClientMessageEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) + return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[33] = ClientMessageEventNew } // ClientMessageDataUnion is a represention of the ClientMessageDataUnion union type. @@ -2649,67 +1108,333 @@ func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) return b } -// KeyPress is the event number for a KeyPressEvent. -const KeyPress = 2 +const ( + ClipOrderingUnsorted = 0 + ClipOrderingYSorted = 1 + ClipOrderingYXSorted = 2 + ClipOrderingYXBanded = 3 +) -type KeyPressEvent struct { - Sequence uint16 - Detail Keycode - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool +const ( + CloseDownDestroyAll = 0 + CloseDownRetainPermanent = 1 + CloseDownRetainTemporary = 2 +) + +const ( + ColorFlagRed = 1 + ColorFlagGreen = 2 + ColorFlagBlue = 4 +) + +type Coloritem struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Flags byte // padding: 1 bytes } -// KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. -func KeyPressEventNew(buf []byte) xgb.Event { - v := KeyPressEvent{} - b := 1 // don't read event number +// ColoritemRead reads a byte slice into a Coloritem value. +func ColoritemRead(buf []byte, v *Coloritem) int { + b := 0 - v.Detail = Keycode(buf[b]) + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Flags = buf[b] + b += 1 + + b += 1 // padding + + return b +} + +// ColoritemReadList reads a byte slice into a list of Coloritem values. +func ColoritemReadList(buf []byte, dest []Coloritem) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Coloritem{} + b += ColoritemRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Coloritem value to a byte slice. +func (v Coloritem) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Pixel) + b += 4 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + buf[b] = v.Flags b += 1 + b += 1 // padding + + return buf +} + +// ColoritemListBytes writes a list of Coloritem values to a byte slice. +func ColoritemListBytes(buf []byte, list []Coloritem) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Colormap uint32 + +func NewColormapId(c *xgb.Conn) (Colormap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Colormap(id), nil +} + +// BadColormap is the error number for a BadColormap. +const BadColormap = 12 + +type ColormapError ValueError + +// ColormapErrorNew constructs a ColormapError value that implements xgb.Error from a byte slice. +func ColormapErrorNew(buf []byte) xgb.Error { + v := ColormapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Colormap" + return v +} + +// SequenceId returns the sequence id attached to the BadColormap error. +// This is mostly used internally. +func (err ColormapError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadColormap error. If no bad value exists, 0 is returned. +func (err ColormapError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadColormap error. +func (err ColormapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadColormap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[12] = ColormapErrorNew +} + +const ( + ColormapNone = 0 +) + +const ( + ColormapAllocNone = 0 + ColormapAllocAll = 1 +) + +// ColormapNotify is the event number for a ColormapNotifyEvent. +const ColormapNotify = 32 + +type ColormapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Colormap Colormap + New bool + State byte + // padding: 2 bytes +} + +// ColormapNotifyEventNew constructs a ColormapNotifyEvent value that implements xgb.Event from a byte slice. +func ColormapNotifyEventNew(buf []byte) xgb.Event { + v := ColormapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.Root = Window(xgb.Get32(buf[b:])) + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.New = true + } else { + v.New = false + } + b += 1 + + v.State = buf[b] + b += 1 + + b += 2 // padding + + return v +} + +// Bytes writes a ColormapNotifyEvent value to a byte slice. +func (v ColormapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 32 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + if v.New { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.State + b += 1 + + b += 2 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the ColormapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ColormapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of ColormapNotifyEvent. +func (v ColormapNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Colormap: %d", v.Colormap)) + fieldVals = append(fieldVals, xgb.Sprintf("New: %t", v.New)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[32] = ColormapNotifyEventNew +} + +const ( + ColormapStateUninstalled = 0 + ColormapStateInstalled = 1 +) + +const ( + ConfigWindowX = 1 + ConfigWindowY = 2 + ConfigWindowWidth = 4 + ConfigWindowHeight = 8 + ConfigWindowBorderWidth = 16 + ConfigWindowSibling = 32 + ConfigWindowStackMode = 64 +) + +// ConfigureNotify is the event number for a ConfigureNotifyEvent. +const ConfigureNotify = 22 + +type ConfigureNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + AboveSibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// ConfigureNotifyEventNew constructs a ConfigureNotifyEvent value that implements xgb.Event from a byte slice. +func ConfigureNotifyEventNew(buf []byte) xgb.Event { + v := ConfigureNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.Child = Window(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.RootX = int16(xgb.Get16(buf[b:])) + v.AboveSibling = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.RootY = int16(xgb.Get16(buf[b:])) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.EventX = int16(xgb.Get16(buf[b:])) + v.Width = xgb.Get16(buf[b:]) b += 2 - v.EventY = int16(xgb.Get16(buf[b:])) + v.Height = xgb.Get16(buf[b:]) b += 2 - v.State = xgb.Get16(buf[b:]) + v.BorderWidth = xgb.Get16(buf[b:]) b += 2 if buf[b] == 1 { - v.SameScreen = true + v.OverrideRedirect = true } else { - v.SameScreen = false + v.OverrideRedirect = false } b += 1 @@ -2718,48 +1443,44 @@ func KeyPressEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a KeyPressEvent value to a byte slice. -func (v KeyPressEvent) Bytes() []byte { +// Bytes writes a ConfigureNotifyEvent value to a byte slice. +func (v ConfigureNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 2 + buf[b] = 22 b += 1 - buf[b] = byte(v.Detail) - b += 1 + b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Root)) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], uint32(v.Child)) + xgb.Put32(buf[b:], uint32(v.AboveSibling)) b += 4 - xgb.Put16(buf[b:], uint16(v.RootX)) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - xgb.Put16(buf[b:], uint16(v.RootY)) + xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - xgb.Put16(buf[b:], uint16(v.EventX)) + xgb.Put16(buf[b:], v.Width) b += 2 - xgb.Put16(buf[b:], uint16(v.EventY)) + xgb.Put16(buf[b:], v.Height) b += 2 - xgb.Put16(buf[b:], v.State) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - if v.SameScreen { + if v.OverrideRedirect { buf[b] = 1 } else { buf[b] = 0 @@ -2771,247 +1492,220 @@ func (v KeyPressEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the KeyPress event. +// SequenceId returns the sequence id attached to the ConfigureNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v KeyPressEvent) SequenceId() uint16 { +func (v ConfigureNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of KeyPressEvent. -func (v KeyPressEvent) String() string { - fieldVals := make([]string, 0, 12) +// String is a rudimentary string representation of ConfigureNotifyEvent. +func (v ConfigureNotifyEvent) String() string { + fieldVals := make([]string, 0, 11) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("AboveSibling: %d", v.AboveSibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ConfigureNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[2] = KeyPressEventNew + xgb.NewEventFuncs[22] = ConfigureNotifyEventNew } -// ButtonPress is the event number for a ButtonPressEvent. -const ButtonPress = 4 +// ConfigureRequest is the event number for a ConfigureRequestEvent. +const ConfigureRequest = 23 -type ButtonPressEvent struct { - Sequence uint16 - Detail Button - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes +type ConfigureRequestEvent struct { + Sequence uint16 + StackMode byte + Parent Window + Window Window + Sibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + ValueMask uint16 } -// ButtonPressEventNew constructs a ButtonPressEvent value that implements xgb.Event from a byte slice. -func ButtonPressEventNew(buf []byte) xgb.Event { - v := ButtonPressEvent{} +// ConfigureRequestEventNew constructs a ConfigureRequestEvent value that implements xgb.Event from a byte slice. +func ConfigureRequestEventNew(buf []byte) xgb.Event { + v := ConfigureRequestEvent{} b := 1 // don't read event number - v.Detail = Button(buf[b]) + v.StackMode = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Root = Window(xgb.Get32(buf[b:])) + v.Parent = Window(xgb.Get32(buf[b:])) b += 4 - v.Event = Window(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.Child = Window(xgb.Get32(buf[b:])) + v.Sibling = Window(xgb.Get32(buf[b:])) b += 4 - v.RootX = int16(xgb.Get16(buf[b:])) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.RootY = int16(xgb.Get16(buf[b:])) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.EventX = int16(xgb.Get16(buf[b:])) + v.Width = xgb.Get16(buf[b:]) b += 2 - v.EventY = int16(xgb.Get16(buf[b:])) + v.Height = xgb.Get16(buf[b:]) b += 2 - v.State = xgb.Get16(buf[b:]) + v.BorderWidth = xgb.Get16(buf[b:]) b += 2 - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding + v.ValueMask = xgb.Get16(buf[b:]) + b += 2 return v } -// Bytes writes a ButtonPressEvent value to a byte slice. -func (v ButtonPressEvent) Bytes() []byte { +// Bytes writes a ConfigureRequestEvent value to a byte slice. +func (v ConfigureRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 4 + buf[b] = 23 b += 1 - buf[b] = byte(v.Detail) + buf[b] = v.StackMode b += 1 b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Root)) + xgb.Put32(buf[b:], uint32(v.Parent)) b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], uint32(v.Child)) + xgb.Put32(buf[b:], uint32(v.Sibling)) b += 4 - xgb.Put16(buf[b:], uint16(v.RootX)) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - xgb.Put16(buf[b:], uint16(v.RootY)) + xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - xgb.Put16(buf[b:], uint16(v.EventX)) + xgb.Put16(buf[b:], v.Width) b += 2 - xgb.Put16(buf[b:], uint16(v.EventY)) + xgb.Put16(buf[b:], v.Height) b += 2 - xgb.Put16(buf[b:], v.State) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding + xgb.Put16(buf[b:], v.ValueMask) + b += 2 return buf } -// SequenceId returns the sequence id attached to the ButtonPress event. +// SequenceId returns the sequence id attached to the ConfigureRequest event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ButtonPressEvent) SequenceId() uint16 { +func (v ConfigureRequestEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ButtonPressEvent. -func (v ButtonPressEvent) String() string { - fieldVals := make([]string, 0, 12) +// String is a rudimentary string representation of ConfigureRequestEvent. +func (v ConfigureRequestEvent) String() string { + fieldVals := make([]string, 0, 10) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("StackMode: %d", v.StackMode)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Sibling: %d", v.Sibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("ValueMask: %d", v.ValueMask)) + return "ConfigureRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[4] = ButtonPressEventNew + xgb.NewEventFuncs[23] = ConfigureRequestEventNew } -// MotionNotify is the event number for a MotionNotifyEvent. -const MotionNotify = 6 +const ( + CoordModeOrigin = 0 + CoordModePrevious = 1 +) -type MotionNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool +// CreateNotify is the event number for a CreateNotifyEvent. +const CreateNotify = 16 + +type CreateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool // padding: 1 bytes } -// MotionNotifyEventNew constructs a MotionNotifyEvent value that implements xgb.Event from a byte slice. -func MotionNotifyEventNew(buf []byte) xgb.Event { - v := MotionNotifyEvent{} +// CreateNotifyEventNew constructs a CreateNotifyEvent value that implements xgb.Event from a byte slice. +func CreateNotifyEventNew(buf []byte) xgb.Event { + v := CreateNotifyEvent{} b := 1 // don't read event number - v.Detail = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Event = Window(xgb.Get32(buf[b:])) + v.Parent = Window(xgb.Get32(buf[b:])) b += 4 - v.Child = Window(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.RootX = int16(xgb.Get16(buf[b:])) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.RootY = int16(xgb.Get16(buf[b:])) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.EventX = int16(xgb.Get16(buf[b:])) + v.Width = xgb.Get16(buf[b:]) b += 2 - v.EventY = int16(xgb.Get16(buf[b:])) + v.Height = xgb.Get16(buf[b:]) b += 2 - v.State = xgb.Get16(buf[b:]) + v.BorderWidth = xgb.Get16(buf[b:]) b += 2 if buf[b] == 1 { - v.SameScreen = true + v.OverrideRedirect = true } else { - v.SameScreen = false + v.OverrideRedirect = false } b += 1 @@ -3020,48 +1714,41 @@ func MotionNotifyEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a MotionNotifyEvent value to a byte slice. -func (v MotionNotifyEvent) Bytes() []byte { +// Bytes writes a CreateNotifyEvent value to a byte slice. +func (v CreateNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 6 + buf[b] = 16 b += 1 - buf[b] = v.Detail - b += 1 + b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Parent)) b += 4 - xgb.Put32(buf[b:], uint32(v.Child)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put16(buf[b:], uint16(v.RootX)) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - xgb.Put16(buf[b:], uint16(v.RootY)) + xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - xgb.Put16(buf[b:], uint16(v.EventX)) + xgb.Put16(buf[b:], v.Width) b += 2 - xgb.Put16(buf[b:], uint16(v.EventY)) + xgb.Put16(buf[b:], v.Height) b += 2 - xgb.Put16(buf[b:], v.State) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - if v.SameScreen { + if v.OverrideRedirect { buf[b] = 1 } else { buf[b] = 0 @@ -3073,33 +1760,298 @@ func (v MotionNotifyEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the MotionNotify event. +// SequenceId returns the sequence id attached to the CreateNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v MotionNotifyEvent) SequenceId() uint16 { +func (v CreateNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of MotionNotifyEvent. -func (v MotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) +// String is a rudimentary string representation of CreateNotifyEvent. +func (v CreateNotifyEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[16] = CreateNotifyEventNew +} + +type Cursor uint32 + +func NewCursorId(c *xgb.Conn) (Cursor, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Cursor(id), nil +} + +// BadCursor is the error number for a BadCursor. +const BadCursor = 6 + +type CursorError ValueError + +// CursorErrorNew constructs a CursorError value that implements xgb.Error from a byte slice. +func CursorErrorNew(buf []byte) xgb.Error { + v := CursorError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Cursor" + return v +} + +// SequenceId returns the sequence id attached to the BadCursor error. +// This is mostly used internally. +func (err CursorError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadCursor error. If no bad value exists, 0 is returned. +func (err CursorError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadCursor error. +func (err CursorError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[6] = CursorErrorNew +} + +const ( + CursorNone = 0 +) + +const ( + CwBackPixmap = 1 + CwBackPixel = 2 + CwBorderPixmap = 4 + CwBorderPixel = 8 + CwBitGravity = 16 + CwWinGravity = 32 + CwBackingStore = 64 + CwBackingPlanes = 128 + CwBackingPixel = 256 + CwOverrideRedirect = 512 + CwSaveUnder = 1024 + CwEventMask = 2048 + CwDontPropagate = 4096 + CwColormap = 8192 + CwCursor = 16384 +) + +type DepthInfo struct { + Depth byte + // padding: 1 bytes + VisualsLen uint16 + // padding: 4 bytes + Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) +} + +// DepthInfoRead reads a byte slice into a DepthInfo value. +func DepthInfoRead(buf []byte, v *DepthInfo) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.VisualsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]VisualInfo, v.VisualsLen) + b += VisualInfoReadList(buf[b:], v.Visuals) + + return b +} + +// DepthInfoReadList reads a byte slice into a list of DepthInfo values. +func DepthInfoReadList(buf []byte, dest []DepthInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DepthInfo{} + b += DepthInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a DepthInfo value to a byte slice. +func (v DepthInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.VisualsLen) + b += 2 + + b += 4 // padding + + b += VisualInfoListBytes(buf[b:], v.Visuals) + + return buf +} + +// DepthInfoListBytes writes a list of DepthInfo values to a byte slice. +func DepthInfoListBytes(buf []byte, list []DepthInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. +func DepthInfoListSize(list []DepthInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) + } + return size +} + +// DestroyNotify is the event number for a DestroyNotifyEvent. +const DestroyNotify = 17 + +type DestroyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window +} + +// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. +func DestroyNotifyEventNew(buf []byte) xgb.Event { + v := DestroyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Bytes writes a DestroyNotifyEvent value to a byte slice. +func (v DestroyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 17 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +// SequenceId returns the sequence id attached to the DestroyNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DestroyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of DestroyNotifyEvent. +func (v DestroyNotifyEvent) String() string { + fieldVals := make([]string, 0, 3) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[6] = MotionNotifyEventNew + xgb.NewEventFuncs[17] = DestroyNotifyEventNew +} + +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Drawable(id), nil +} + +// BadDrawable is the error number for a BadDrawable. +const BadDrawable = 9 + +type DrawableError ValueError + +// DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. +func DrawableErrorNew(buf []byte) xgb.Error { + v := DrawableError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Drawable" + return v +} + +// SequenceId returns the sequence id attached to the BadDrawable error. +// This is mostly used internally. +func (err DrawableError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadDrawable error. If no bad value exists, 0 is returned. +func (err DrawableError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadDrawable error. +func (err DrawableError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[9] = DrawableErrorNew } // EnterNotify is the event number for a EnterNotifyEvent. @@ -3248,6 +2200,169 @@ func init() { xgb.NewEventFuncs[7] = EnterNotifyEventNew } +const ( + EventMaskNoEvent = 0 + EventMaskKeyPress = 1 + EventMaskKeyRelease = 2 + EventMaskButtonPress = 4 + EventMaskButtonRelease = 8 + EventMaskEnterWindow = 16 + EventMaskLeaveWindow = 32 + EventMaskPointerMotion = 64 + EventMaskPointerMotionHint = 128 + EventMaskButton1Motion = 256 + EventMaskButton2Motion = 512 + EventMaskButton3Motion = 1024 + EventMaskButton4Motion = 2048 + EventMaskButton5Motion = 4096 + EventMaskButtonMotion = 8192 + EventMaskKeymapState = 16384 + EventMaskExposure = 32768 + EventMaskVisibilityChange = 65536 + EventMaskStructureNotify = 131072 + EventMaskResizeRedirect = 262144 + EventMaskSubstructureNotify = 524288 + EventMaskSubstructureRedirect = 1048576 + EventMaskFocusChange = 2097152 + EventMaskPropertyChange = 4194304 + EventMaskColorMapChange = 8388608 + EventMaskOwnerGrabButton = 16777216 +) + +// Expose is the event number for a ExposeEvent. +const Expose = 12 + +type ExposeEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 2 bytes +} + +// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. +func ExposeEventNew(buf []byte) xgb.Event { + v := ExposeEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Bytes writes a ExposeEvent value to a byte slice. +func (v ExposeEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 12 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + b += 2 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the Expose event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ExposeEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of ExposeEvent. +func (v ExposeEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[12] = ExposeEventNew +} + +const ( + ExposuresNotAllowed = 0 + ExposuresAllowed = 1 + ExposuresDefault = 2 +) + +const ( + FamilyInternet = 0 + FamilyDECnet = 1 + FamilyChaos = 2 + FamilyServerInterpreted = 5 + FamilyInternet6 = 6 +) + +const ( + FillRuleEvenOdd = 0 + FillRuleWinding = 1 +) + +const ( + FillStyleSolid = 0 + FillStyleTiled = 1 + FillStyleStippled = 2 + FillStyleOpaqueStippled = 3 +) + // FocusIn is the event number for a FocusInEvent. const FocusIn = 9 @@ -3327,165 +2442,323 @@ func init() { xgb.NewEventFuncs[9] = FocusInEventNew } -// KeymapNotify is the event number for a KeymapNotifyEvent. -const KeymapNotify = 11 +// FocusOut is the event number for a FocusOutEvent. +const FocusOut = 10 -type KeymapNotifyEvent struct { - Keys []byte // size: 32 +type FocusOutEvent FocusInEvent + +// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) } -// KeymapNotifyEventNew constructs a KeymapNotifyEvent value that implements xgb.Event from a byte slice. -func KeymapNotifyEventNew(buf []byte) xgb.Event { - v := KeymapNotifyEvent{} - b := 1 // don't read event number +// Bytes writes a FocusOutEvent value to a byte slice. +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} - v.Keys = make([]byte, 31) - copy(v.Keys[:31], buf[b:]) - b += xgb.Pad(int(31)) +// SequenceId returns the sequence id attached to the FocusOut event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v FocusOutEvent) SequenceId() uint16 { + return v.Sequence +} - return v +func (v FocusOutEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// Bytes writes a KeymapNotifyEvent value to a byte slice. -func (v KeymapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 +func init() { + xgb.NewEventFuncs[10] = FocusOutEventNew +} - // write event number - buf[b] = 11 - b += 1 +type Font uint32 - copy(buf[b:], v.Keys[:31]) - b += xgb.Pad(int(31)) +func NewFontId(c *xgb.Conn) (Font, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Font(id), nil +} - return buf +const ( + FontNone = 0 +) + +// BadFont is the error number for a BadFont. +const BadFont = 7 + +type FontError ValueError + +// FontErrorNew constructs a FontError value that implements xgb.Error from a byte slice. +func FontErrorNew(buf []byte) xgb.Error { + v := FontError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Font" + return v } -// SequenceId returns the sequence id attached to the KeymapNotify event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadFont error. // This is mostly used internally. -func (v KeymapNotifyEvent) SequenceId() uint16 { - return uint16(0) +func (err FontError) SequenceId() uint16 { + return err.Sequence } -// String is a rudimentary string representation of KeymapNotifyEvent. -func (v KeymapNotifyEvent) String() string { - fieldVals := make([]string, 0, 1) - return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// BadId returns the 'BadValue' number if one exists for the BadFont error. If no bad value exists, 0 is returned. +func (err FontError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadFont error. +func (err FontError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[11] = KeymapNotifyEventNew + xgb.NewErrorFuncs[7] = FontErrorNew } -// Expose is the event number for a ExposeEvent. -const Expose = 12 +const ( + FontDrawLeftToRight = 0 + FontDrawRightToLeft = 1 +) -type ExposeEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 2 bytes +type Fontable uint32 + +func NewFontableId(c *xgb.Conn) (Fontable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fontable(id), nil } -// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. -func ExposeEventNew(buf []byte) xgb.Event { - v := ExposeEvent{} - b := 1 // don't read event number +type Fontprop struct { + Name Atom + Value uint32 +} - b += 1 // padding +// FontpropRead reads a byte slice into a Fontprop value. +func FontpropRead(buf []byte, v *Fontprop) int { + b := 0 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.Name = Atom(xgb.Get32(buf[b:])) + b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + v.Value = xgb.Get32(buf[b:]) b += 4 - v.X = xgb.Get16(buf[b:]) - b += 2 + return b +} - v.Y = xgb.Get16(buf[b:]) - b += 2 +// FontpropReadList reads a byte slice into a list of Fontprop values. +func FontpropReadList(buf []byte, dest []Fontprop) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Fontprop{} + b += FontpropRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - v.Width = xgb.Get16(buf[b:]) - b += 2 +// Bytes writes a Fontprop value to a byte slice. +func (v Fontprop) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - v.Height = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 - v.Count = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], v.Value) + b += 4 - b += 2 // padding + return buf +} - return v +// FontpropListBytes writes a list of Fontprop values to a byte slice. +func FontpropListBytes(buf []byte, list []Fontprop) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// Bytes writes a ExposeEvent value to a byte slice. -func (v ExposeEvent) Bytes() []byte { - buf := make([]byte, 32) +type Format struct { + Depth byte + BitsPerPixel byte + ScanlinePad byte + // padding: 5 bytes +} + +// FormatRead reads a byte slice into a Format value. +func FormatRead(buf []byte, v *Format) int { b := 0 - // write event number - buf[b] = 12 + v.Depth = buf[b] b += 1 - b += 1 // padding + v.BitsPerPixel = buf[b] + b += 1 - b += 2 // skip sequence number + v.ScanlinePad = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + b += 5 // padding - xgb.Put16(buf[b:], v.X) - b += 2 + return b +} - xgb.Put16(buf[b:], v.Y) - b += 2 +// FormatReadList reads a byte slice into a list of Format values. +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - xgb.Put16(buf[b:], v.Width) - b += 2 +// Bytes writes a Format value to a byte slice. +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - xgb.Put16(buf[b:], v.Height) - b += 2 + buf[b] = v.Depth + b += 1 - xgb.Put16(buf[b:], v.Count) - b += 2 + buf[b] = v.BitsPerPixel + b += 1 - b += 2 // padding + buf[b] = v.ScanlinePad + b += 1 + + b += 5 // padding return buf } -// SequenceId returns the sequence id attached to the Expose event. -// Events without a sequence number (KeymapNotify) return 0. +// FormatListBytes writes a list of Format values to a byte slice. +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// BadGContext is the error number for a BadGContext. +const BadGContext = 13 + +type GContextError ValueError + +// GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. +func GContextErrorNew(buf []byte) xgb.Error { + v := GContextError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "GContext" + return v +} + +// SequenceId returns the sequence id attached to the BadGContext error. // This is mostly used internally. -func (v ExposeEvent) SequenceId() uint16 { - return v.Sequence +func (err GContextError) SequenceId() uint16 { + return err.Sequence } -// String is a rudimentary string representation of ExposeEvent. -func (v ExposeEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// BadId returns the 'BadValue' number if one exists for the BadGContext error. If no bad value exists, 0 is returned. +func (err GContextError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadGContext error. +func (err GContextError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[12] = ExposeEventNew + xgb.NewErrorFuncs[13] = GContextErrorNew +} + +const ( + GcFunction = 1 + GcPlaneMask = 2 + GcForeground = 4 + GcBackground = 8 + GcLineWidth = 16 + GcLineStyle = 32 + GcCapStyle = 64 + GcJoinStyle = 128 + GcFillStyle = 256 + GcFillRule = 512 + GcTile = 1024 + GcStipple = 2048 + GcTileStippleOriginX = 4096 + GcTileStippleOriginY = 8192 + GcFont = 16384 + GcSubwindowMode = 32768 + GcGraphicsExposures = 65536 + GcClipOriginX = 131072 + GcClipOriginY = 262144 + GcClipMask = 524288 + GcDashOffset = 1048576 + GcDashList = 2097152 + GcArcMode = 4194304 +) + +type Gcontext uint32 + +func NewGcontextId(c *xgb.Conn) (Gcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Gcontext(id), nil } +const ( + GetPropertyTypeAny = 0 +) + +const ( + GrabAny = 0 +) + +const ( + GrabModeSync = 0 + GrabModeAsync = 1 +) + +const ( + GrabStatusSuccess = 0 + GrabStatusAlreadyGrabbed = 1 + GrabStatusInvalidTime = 2 + GrabStatusNotViewable = 3 + GrabStatusFrozen = 4 +) + // GraphicsExposure is the event number for a GraphicsExposureEvent. const GraphicsExposure = 13 @@ -3610,21 +2883,36 @@ func init() { xgb.NewEventFuncs[13] = GraphicsExposureEventNew } -// NoExposure is the event number for a NoExposureEvent. -const NoExposure = 14 +const ( + GravityBitForget = 0 + GravityWinUnmap = 0 + GravityNorthWest = 1 + GravityNorth = 2 + GravityNorthEast = 3 + GravityWest = 4 + GravityCenter = 5 + GravityEast = 6 + GravitySouthWest = 7 + GravitySouth = 8 + GravitySouthEast = 9 + GravityStatic = 10 +) -type NoExposureEvent struct { +// GravityNotify is the event number for a GravityNotifyEvent. +const GravityNotify = 24 + +type GravityNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Drawable Drawable - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes + Event Window + Window Window + X int16 + Y int16 } -// NoExposureEventNew constructs a NoExposureEvent value that implements xgb.Event from a byte slice. -func NoExposureEventNew(buf []byte) xgb.Event { - v := NoExposureEvent{} +// GravityNotifyEventNew constructs a GravityNotifyEvent value that implements xgb.Event from a byte slice. +func GravityNotifyEventNew(buf []byte) xgb.Event { + v := GravityNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -3632,196 +2920,359 @@ func NoExposureEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Drawable = Drawable(xgb.Get32(buf[b:])) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 - v.MajorOpcode = buf[b] - b += 1 + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - b += 1 // padding + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 return v } -// Bytes writes a NoExposureEvent value to a byte slice. -func (v NoExposureEvent) Bytes() []byte { +// Bytes writes a GravityNotifyEvent value to a byte slice. +func (v GravityNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 14 + buf[b] = 24 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Drawable)) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put16(buf[b:], v.MinorOpcode) - b += 2 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - buf[b] = v.MajorOpcode - b += 1 + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 return buf } -// SequenceId returns the sequence id attached to the NoExposure event. +// SequenceId returns the sequence id attached to the GravityNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v NoExposureEvent) SequenceId() uint16 { +func (v GravityNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of NoExposureEvent. -func (v NoExposureEvent) String() string { +// String is a rudimentary string representation of GravityNotifyEvent. +func (v GravityNotifyEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + return "GravityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[14] = NoExposureEventNew + xgb.NewEventFuncs[24] = GravityNotifyEventNew } -// VisibilityNotify is the event number for a VisibilityNotifyEvent. -const VisibilityNotify = 15 +const ( + GxClear = 0 + GxAnd = 1 + GxAndReverse = 2 + GxCopy = 3 + GxAndInverted = 4 + GxNoop = 5 + GxXor = 6 + GxOr = 7 + GxNor = 8 + GxEquiv = 9 + GxInvert = 10 + GxOrReverse = 11 + GxCopyInverted = 12 + GxOrInverted = 13 + GxNand = 14 + GxSet = 15 +) -type VisibilityNotifyEvent struct { - Sequence uint16 +type Host struct { + Family byte // padding: 1 bytes - Window Window - State byte - // padding: 3 bytes + AddressLen uint16 + Address []byte // size: xgb.Pad((int(AddressLen) * 1)) } -// VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. -func VisibilityNotifyEventNew(buf []byte) xgb.Event { - v := VisibilityNotifyEvent{} - b := 1 // don't read event number +// HostRead reads a byte slice into a Host value. +func HostRead(buf []byte, v *Host) int { + b := 0 + + v.Family = buf[b] + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + v.AddressLen = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 + v.Address = make([]byte, v.AddressLen) + copy(v.Address[:v.AddressLen], buf[b:]) + b += xgb.Pad(int(v.AddressLen)) - b += 3 // padding + return b +} - return v +// HostReadList reads a byte slice into a list of Host values. +func HostReadList(buf []byte, dest []Host) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Host{} + b += HostRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// Bytes writes a VisibilityNotifyEvent value to a byte slice. -func (v VisibilityNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// Bytes writes a Host value to a byte slice. +func (v Host) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) b := 0 - // write event number - buf[b] = 15 + buf[b] = v.Family b += 1 b += 1 // padding - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.AddressLen) + b += 2 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + copy(buf[b:], v.Address[:v.AddressLen]) + b += xgb.Pad(int(v.AddressLen)) - buf[b] = v.State - b += 1 + return buf +} - b += 3 // padding +// HostListBytes writes a list of Host values to a byte slice. +func HostListBytes(buf []byte, list []Host) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} - return buf +// HostListSize computes the size (bytes) of a list of Host values. +func HostListSize(list []Host) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.AddressLen) * 1))) + } + return size } -// SequenceId returns the sequence id attached to the VisibilityNotify event. -// Events without a sequence number (KeymapNotify) return 0. +const ( + HostModeInsert = 0 + HostModeDelete = 1 +) + +// BadIDChoice is the error number for a BadIDChoice. +const BadIDChoice = 14 + +type IDChoiceError ValueError + +// IDChoiceErrorNew constructs a IDChoiceError value that implements xgb.Error from a byte slice. +func IDChoiceErrorNew(buf []byte) xgb.Error { + v := IDChoiceError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "IDChoice" + return v +} + +// SequenceId returns the sequence id attached to the BadIDChoice error. // This is mostly used internally. -func (v VisibilityNotifyEvent) SequenceId() uint16 { - return v.Sequence +func (err IDChoiceError) SequenceId() uint16 { + return err.Sequence } -// String is a rudimentary string representation of VisibilityNotifyEvent. -func (v VisibilityNotifyEvent) String() string { +// BadId returns the 'BadValue' number if one exists for the BadIDChoice error. If no bad value exists, 0 is returned. +func (err IDChoiceError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadIDChoice error. +func (err IDChoiceError) Error() string { fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[15] = VisibilityNotifyEventNew + xgb.NewErrorFuncs[14] = IDChoiceErrorNew } -// CreateNotify is the event number for a CreateNotifyEvent. -const CreateNotify = 16 +const ( + ImageFormatXYBitmap = 0 + ImageFormatXYPixmap = 1 + ImageFormatZPixmap = 2 +) -type CreateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool +const ( + ImageOrderLSBFirst = 0 + ImageOrderMSBFirst = 1 +) + +// BadImplementation is the error number for a BadImplementation. +const BadImplementation = 17 + +type ImplementationError RequestError + +// ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. +func ImplementationErrorNew(buf []byte) xgb.Error { + v := ImplementationError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Implementation" + return v +} + +// SequenceId returns the sequence id attached to the BadImplementation error. +// This is mostly used internally. +func (err ImplementationError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadImplementation error. If no bad value exists, 0 is returned. +func (err ImplementationError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadImplementation error. +func (err ImplementationError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[17] = ImplementationErrorNew +} + +const ( + InputFocusNone = 0 + InputFocusPointerRoot = 1 + InputFocusParent = 2 + InputFocusFollowKeyboard = 3 +) + +const ( + JoinStyleMiter = 0 + JoinStyleRound = 1 + JoinStyleBevel = 2 +) + +const ( + KbKeyClickPercent = 1 + KbBellPercent = 2 + KbBellPitch = 4 + KbBellDuration = 8 + KbLed = 16 + KbLedMode = 32 + KbKey = 64 + KbAutoRepeatMode = 128 +) + +const ( + KeyButMaskShift = 1 + KeyButMaskLock = 2 + KeyButMaskControl = 4 + KeyButMaskMod1 = 8 + KeyButMaskMod2 = 16 + KeyButMaskMod3 = 32 + KeyButMaskMod4 = 64 + KeyButMaskMod5 = 128 + KeyButMaskButton1 = 256 + KeyButMaskButton2 = 512 + KeyButMaskButton3 = 1024 + KeyButMaskButton4 = 2048 + KeyButMaskButton5 = 4096 +) + +// KeyPress is the event number for a KeyPressEvent. +const KeyPress = 2 + +type KeyPressEvent struct { + Sequence uint16 + Detail Keycode + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool // padding: 1 bytes } -// CreateNotifyEventNew constructs a CreateNotifyEvent value that implements xgb.Event from a byte slice. -func CreateNotifyEventNew(buf []byte) xgb.Event { - v := CreateNotifyEvent{} +// KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. +func KeyPressEventNew(buf []byte) xgb.Event { + v := KeyPressEvent{} b := 1 // don't read event number - b += 1 // padding + v.Detail = Keycode(buf[b]) + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Parent = Window(xgb.Get32(buf[b:])) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + v.Root = Window(xgb.Get32(buf[b:])) b += 4 - v.X = int16(xgb.Get16(buf[b:])) + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - v.Y = int16(xgb.Get16(buf[b:])) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.Width = xgb.Get16(buf[b:]) + v.EventX = int16(xgb.Get16(buf[b:])) b += 2 - v.Height = xgb.Get16(buf[b:]) + v.EventY = int16(xgb.Get16(buf[b:])) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) + v.State = xgb.Get16(buf[b:]) b += 2 if buf[b] == 1 { - v.OverrideRedirect = true + v.SameScreen = true } else { - v.OverrideRedirect = false + v.SameScreen = false } b += 1 @@ -3830,41 +3281,48 @@ func CreateNotifyEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a CreateNotifyEvent value to a byte slice. -func (v CreateNotifyEvent) Bytes() []byte { +// Bytes writes a KeyPressEvent value to a byte slice. +func (v KeyPressEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 16 + buf[b] = 2 b += 1 - b += 1 // padding + buf[b] = byte(v.Detail) + b += 1 b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Parent)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Root)) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) b += 2 - xgb.Put16(buf[b:], uint16(v.Y)) + xgb.Put16(buf[b:], uint16(v.RootY)) b += 2 - xgb.Put16(buf[b:], v.Width) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], v.Height) + xgb.Put16(buf[b:], uint16(v.EventY)) b += 2 - xgb.Put16(buf[b:], v.BorderWidth) + xgb.Put16(buf[b:], v.State) b += 2 - if v.OverrideRedirect { + if v.SameScreen { buf[b] = 1 } else { buf[b] = 0 @@ -3876,195 +3334,241 @@ func (v CreateNotifyEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the CreateNotify event. +// SequenceId returns the sequence id attached to the KeyPress event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v CreateNotifyEvent) SequenceId() uint16 { +func (v KeyPressEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of CreateNotifyEvent. -func (v CreateNotifyEvent) String() string { - fieldVals := make([]string, 0, 10) +// String is a rudimentary string representation of KeyPressEvent. +func (v KeyPressEvent) String() string { + fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[16] = CreateNotifyEventNew -} - -// DestroyNotify is the event number for a DestroyNotifyEvent. -const DestroyNotify = 17 - -type DestroyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window + xgb.NewEventFuncs[2] = KeyPressEventNew } -// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. -func DestroyNotifyEventNew(buf []byte) xgb.Event { - v := DestroyNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 +// KeyRelease is the event number for a KeyReleaseEvent. +const KeyRelease = 3 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 +type KeyReleaseEvent KeyPressEvent - return v +// KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice. +func KeyReleaseEventNew(buf []byte) xgb.Event { + return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) } -// Bytes writes a DestroyNotifyEvent value to a byte slice. -func (v DestroyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 17 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - return buf +// Bytes writes a KeyReleaseEvent value to a byte slice. +func (v KeyReleaseEvent) Bytes() []byte { + return KeyPressEvent(v).Bytes() } -// SequenceId returns the sequence id attached to the DestroyNotify event. +// SequenceId returns the sequence id attached to the KeyRelease event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v DestroyNotifyEvent) SequenceId() uint16 { +func (v KeyReleaseEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of DestroyNotifyEvent. -func (v DestroyNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) +func (v KeyReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[17] = DestroyNotifyEventNew + xgb.NewEventFuncs[3] = KeyReleaseEventNew } -// UnmapNotify is the event number for a UnmapNotifyEvent. -const UnmapNotify = 18 +type Keycode byte -type UnmapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - FromConfigure bool - // padding: 3 bytes +// KeymapNotify is the event number for a KeymapNotifyEvent. +const KeymapNotify = 11 + +type KeymapNotifyEvent struct { + Keys []byte // size: 32 } -// UnmapNotifyEventNew constructs a UnmapNotifyEvent value that implements xgb.Event from a byte slice. -func UnmapNotifyEventNew(buf []byte) xgb.Event { - v := UnmapNotifyEvent{} +// KeymapNotifyEventNew constructs a KeymapNotifyEvent value that implements xgb.Event from a byte slice. +func KeymapNotifyEventNew(buf []byte) xgb.Event { + v := KeymapNotifyEvent{} b := 1 // don't read event number - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.FromConfigure = true - } else { - v.FromConfigure = false - } - b += 1 - - b += 3 // padding + v.Keys = make([]byte, 31) + copy(v.Keys[:31], buf[b:]) + b += xgb.Pad(int(31)) return v } -// Bytes writes a UnmapNotifyEvent value to a byte slice. -func (v UnmapNotifyEvent) Bytes() []byte { +// Bytes writes a KeymapNotifyEvent value to a byte slice. +func (v KeymapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 18 + buf[b] = 11 b += 1 - b += 1 // padding + copy(buf[b:], v.Keys[:31]) + b += xgb.Pad(int(31)) - b += 2 // skip sequence number + return buf +} - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 +// SequenceId returns the sequence id attached to the KeymapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v KeymapNotifyEvent) SequenceId() uint16 { + return uint16(0) +} - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 +// String is a rudimentary string representation of KeymapNotifyEvent. +func (v KeymapNotifyEvent) String() string { + fieldVals := make([]string, 0, 1) + return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - if v.FromConfigure { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 +func init() { + xgb.NewEventFuncs[11] = KeymapNotifyEventNew +} - b += 3 // padding +type Keysym uint32 - return buf +const ( + KillAllTemporary = 0 +) + +// LeaveNotify is the event number for a LeaveNotifyEvent. +const LeaveNotify = 8 + +type LeaveNotifyEvent EnterNotifyEvent + +// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. +func LeaveNotifyEventNew(buf []byte) xgb.Event { + return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) } -// SequenceId returns the sequence id attached to the UnmapNotify event. +// Bytes writes a LeaveNotifyEvent value to a byte slice. +func (v LeaveNotifyEvent) Bytes() []byte { + return EnterNotifyEvent(v).Bytes() +} + +// SequenceId returns the sequence id attached to the LeaveNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v UnmapNotifyEvent) SequenceId() uint16 { +func (v LeaveNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of UnmapNotifyEvent. -func (v UnmapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +func (v LeaveNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) - return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) + return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[18] = UnmapNotifyEventNew + xgb.NewEventFuncs[8] = LeaveNotifyEventNew +} + +const ( + LedModeOff = 0 + LedModeOn = 1 +) + +// BadLength is the error number for a BadLength. +const BadLength = 16 + +type LengthError RequestError + +// LengthErrorNew constructs a LengthError value that implements xgb.Error from a byte slice. +func LengthErrorNew(buf []byte) xgb.Error { + v := LengthError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Length" + return v +} + +// SequenceId returns the sequence id attached to the BadLength error. +// This is mostly used internally. +func (err LengthError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadLength error. If no bad value exists, 0 is returned. +func (err LengthError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadLength error. +func (err LengthError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[16] = LengthErrorNew } +const ( + LineStyleSolid = 0 + LineStyleOnOffDash = 1 + LineStyleDoubleDash = 2 +) + +const ( + MapIndexShift = 0 + MapIndexLock = 1 + MapIndexControl = 2 + MapIndex1 = 3 + MapIndex2 = 4 + MapIndex3 = 5 + MapIndex4 = 6 + MapIndex5 = 7 +) + // MapNotify is the event number for a MapNotifyEvent. const MapNotify = 19 @@ -4228,24 +3732,33 @@ func init() { xgb.NewEventFuncs[20] = MapRequestEventNew } -// ReparentNotify is the event number for a ReparentNotifyEvent. -const ReparentNotify = 21 +const ( + MapStateUnmapped = 0 + MapStateUnviewable = 1 + MapStateViewable = 2 +) -type ReparentNotifyEvent struct { +const ( + MappingModifier = 0 + MappingKeyboard = 1 + MappingPointer = 2 +) + +// MappingNotify is the event number for a MappingNotifyEvent. +const MappingNotify = 34 + +type MappingNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - Parent Window - X int16 - Y int16 - OverrideRedirect bool - // padding: 3 bytes + Request byte + FirstKeycode Keycode + Count byte + // padding: 1 bytes } -// ReparentNotifyEventNew constructs a ReparentNotifyEvent value that implements xgb.Event from a byte slice. -func ReparentNotifyEventNew(buf []byte) xgb.Event { - v := ReparentNotifyEvent{} +// MappingNotifyEventNew constructs a MappingNotifyEvent value that implements xgb.Event from a byte slice. +func MappingNotifyEventNew(buf []byte) xgb.Event { + v := MappingNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -4253,153 +3766,190 @@ func ReparentNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + v.Request = buf[b] + b += 1 - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + v.FirstKeycode = Keycode(buf[b]) + b += 1 - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } + v.Count = buf[b] b += 1 - b += 3 // padding + b += 1 // padding return v } -// Bytes writes a ReparentNotifyEvent value to a byte slice. -func (v ReparentNotifyEvent) Bytes() []byte { +// Bytes writes a MappingNotifyEvent value to a byte slice. +func (v MappingNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 21 + buf[b] = 34 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Parent)) - b += 4 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + buf[b] = v.Request + b += 1 - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + buf[b] = byte(v.FirstKeycode) + b += 1 - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } + buf[b] = v.Count b += 1 - b += 3 // padding + b += 1 // padding return buf } -// SequenceId returns the sequence id attached to the ReparentNotify event. +// SequenceId returns the sequence id attached to the MappingNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ReparentNotifyEvent) SequenceId() uint16 { +func (v MappingNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ReparentNotifyEvent. -func (v ReparentNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) +// String is a rudimentary string representation of MappingNotifyEvent. +func (v MappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[21] = ReparentNotifyEventNew + xgb.NewEventFuncs[34] = MappingNotifyEventNew } -// ConfigureNotify is the event number for a ConfigureNotifyEvent. -const ConfigureNotify = 22 +const ( + MappingStatusSuccess = 0 + MappingStatusBusy = 1 + MappingStatusFailure = 2 +) -type ConfigureNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - AboveSibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool +// BadMatch is the error number for a BadMatch. +const BadMatch = 8 + +type MatchError RequestError + +// MatchErrorNew constructs a MatchError value that implements xgb.Error from a byte slice. +func MatchErrorNew(buf []byte) xgb.Error { + v := MatchError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Match" + return v +} + +// SequenceId returns the sequence id attached to the BadMatch error. +// This is mostly used internally. +func (err MatchError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadMatch error. If no bad value exists, 0 is returned. +func (err MatchError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadMatch error. +func (err MatchError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[8] = MatchErrorNew +} + +const ( + ModMaskShift = 1 + ModMaskLock = 2 + ModMaskControl = 4 + ModMask1 = 8 + ModMask2 = 16 + ModMask3 = 32 + ModMask4 = 64 + ModMask5 = 128 + ModMaskAny = 32768 +) + +const ( + MotionNormal = 0 + MotionHint = 1 +) + +// MotionNotify is the event number for a MotionNotifyEvent. +const MotionNotify = 6 + +type MotionNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool // padding: 1 bytes } -// ConfigureNotifyEventNew constructs a ConfigureNotifyEvent value that implements xgb.Event from a byte slice. -func ConfigureNotifyEventNew(buf []byte) xgb.Event { - v := ConfigureNotifyEvent{} +// MotionNotifyEventNew constructs a MotionNotifyEvent value that implements xgb.Event from a byte slice. +func MotionNotifyEventNew(buf []byte) xgb.Event { + v := MotionNotifyEvent{} b := 1 // don't read event number - b += 1 // padding + v.Detail = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + v.Root = Window(xgb.Get32(buf[b:])) b += 4 - v.AboveSibling = Window(xgb.Get32(buf[b:])) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.X = int16(xgb.Get16(buf[b:])) + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - v.Y = int16(xgb.Get16(buf[b:])) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.Width = xgb.Get16(buf[b:]) + v.EventX = int16(xgb.Get16(buf[b:])) b += 2 - v.Height = xgb.Get16(buf[b:]) + v.EventY = int16(xgb.Get16(buf[b:])) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) + v.State = xgb.Get16(buf[b:]) b += 2 if buf[b] == 1 { - v.OverrideRedirect = true + v.SameScreen = true } else { - v.OverrideRedirect = false + v.SameScreen = false } b += 1 @@ -4408,44 +3958,48 @@ func ConfigureNotifyEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a ConfigureNotifyEvent value to a byte slice. -func (v ConfigureNotifyEvent) Bytes() []byte { +// Bytes writes a MotionNotifyEvent value to a byte slice. +func (v MotionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 22 + buf[b] = 6 b += 1 - b += 1 // padding + buf[b] = v.Detail + b += 1 b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Root)) b += 4 - xgb.Put32(buf[b:], uint32(v.AboveSibling)) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) b += 2 - xgb.Put16(buf[b:], uint16(v.Y)) + xgb.Put16(buf[b:], uint16(v.RootY)) b += 2 - xgb.Put16(buf[b:], v.Width) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], v.Height) + xgb.Put16(buf[b:], uint16(v.EventY)) b += 2 - xgb.Put16(buf[b:], v.BorderWidth) + xgb.Put16(buf[b:], v.State) b += 2 - if v.OverrideRedirect { + if v.SameScreen { buf[b] = 1 } else { buf[b] = 0 @@ -4457,178 +4011,487 @@ func (v ConfigureNotifyEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the ConfigureNotify event. +// SequenceId returns the sequence id attached to the MotionNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ConfigureNotifyEvent) SequenceId() uint16 { +func (v MotionNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ConfigureNotifyEvent. -func (v ConfigureNotifyEvent) String() string { - fieldVals := make([]string, 0, 11) +// String is a rudimentary string representation of MotionNotifyEvent. +func (v MotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("AboveSibling: %d", v.AboveSibling)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ConfigureNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[22] = ConfigureNotifyEventNew + xgb.NewEventFuncs[6] = MotionNotifyEventNew } -// ConfigureRequest is the event number for a ConfigureRequestEvent. -const ConfigureRequest = 23 +// BadName is the error number for a BadName. +const BadName = 15 -type ConfigureRequestEvent struct { - Sequence uint16 - StackMode byte - Parent Window - Window Window - Sibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - ValueMask uint16 +type NameError RequestError + +// NameErrorNew constructs a NameError value that implements xgb.Error from a byte slice. +func NameErrorNew(buf []byte) xgb.Error { + v := NameError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Name" + return v } -// ConfigureRequestEventNew constructs a ConfigureRequestEvent value that implements xgb.Event from a byte slice. -func ConfigureRequestEventNew(buf []byte) xgb.Event { - v := ConfigureRequestEvent{} +// SequenceId returns the sequence id attached to the BadName error. +// This is mostly used internally. +func (err NameError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadName error. If no bad value exists, 0 is returned. +func (err NameError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadName error. +func (err NameError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[15] = NameErrorNew +} + +// NoExposure is the event number for a NoExposureEvent. +const NoExposure = 14 + +type NoExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// NoExposureEventNew constructs a NoExposureEvent value that implements xgb.Event from a byte slice. +func NoExposureEventNew(buf []byte) xgb.Event { + v := NoExposureEvent{} b := 1 // don't read event number - v.StackMode = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Parent = Window(xgb.Get32(buf[b:])) + v.Drawable = Drawable(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 - v.Sibling = Window(xgb.Get32(buf[b:])) + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// Bytes writes a NoExposureEvent value to a byte slice. +func (v NoExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) b += 4 + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 1 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the NoExposure event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v NoExposureEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of NoExposureEvent. +func (v NoExposureEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[14] = NoExposureEventNew +} + +const ( + NotifyDetailAncestor = 0 + NotifyDetailVirtual = 1 + NotifyDetailInferior = 2 + NotifyDetailNonlinear = 3 + NotifyDetailNonlinearVirtual = 4 + NotifyDetailPointer = 5 + NotifyDetailPointerRoot = 6 + NotifyDetailNone = 7 +) + +const ( + NotifyModeNormal = 0 + NotifyModeGrab = 1 + NotifyModeUngrab = 2 + NotifyModeWhileGrabbed = 3 +) + +type Pixmap uint32 + +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} + +// BadPixmap is the error number for a BadPixmap. +const BadPixmap = 4 + +type PixmapError ValueError + +// PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. +func PixmapErrorNew(buf []byte) xgb.Error { + v := PixmapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Pixmap" + return v +} + +// SequenceId returns the sequence id attached to the BadPixmap error. +// This is mostly used internally. +func (err PixmapError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadPixmap error. If no bad value exists, 0 is returned. +func (err PixmapError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadPixmap error. +func (err PixmapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[4] = PixmapErrorNew +} + +const ( + PixmapNone = 0 +) + +const ( + PlaceOnTop = 0 + PlaceOnBottom = 1 +) + +type Point struct { + X int16 + Y int16 +} + +// PointRead reads a byte slice into a Point value. +func PointRead(buf []byte, v *Point) int { + b := 0 + v.X = int16(xgb.Get16(buf[b:])) b += 2 v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.Width = xgb.Get16(buf[b:]) - b += 2 + return b +} - v.Height = xgb.Get16(buf[b:]) +// PointReadList reads a byte slice into a list of Point values. +func PointReadList(buf []byte, dest []Point) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Point{} + b += PointRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Point value to a byte slice. +func (v Point) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - v.ValueMask = xgb.Get16(buf[b:]) + return buf +} + +// PointListBytes writes a list of Point values to a byte slice. +func PointListBytes(buf []byte, list []Point) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + PolyShapeComplex = 0 + PolyShapeNonconvex = 1 + PolyShapeConvex = 2 +) + +const ( + PropModeReplace = 0 + PropModePrepend = 1 + PropModeAppend = 2 +) + +const ( + PropertyNewValue = 0 + PropertyDelete = 1 +) + +// PropertyNotify is the event number for a PropertyNotifyEvent. +const PropertyNotify = 28 + +type PropertyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Atom Atom + Time Timestamp + State byte + // padding: 3 bytes +} + +// PropertyNotifyEventNew constructs a PropertyNotifyEvent value that implements xgb.Event from a byte slice. +func PropertyNotifyEventNew(buf []byte) xgb.Event { + v := PropertyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) b += 2 + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + return v } -// Bytes writes a ConfigureRequestEvent value to a byte slice. -func (v ConfigureRequestEvent) Bytes() []byte { +// Bytes writes a PropertyNotifyEvent value to a byte slice. +func (v PropertyNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 23 + buf[b] = 28 b += 1 - buf[b] = v.StackMode - b += 1 + b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Parent)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Atom)) b += 4 - xgb.Put32(buf[b:], uint32(v.Sibling)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + buf[b] = v.State + b += 1 - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + b += 3 // padding - xgb.Put16(buf[b:], v.Width) + return buf +} + +// SequenceId returns the sequence id attached to the PropertyNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v PropertyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of PropertyNotifyEvent. +func (v PropertyNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Atom: %d", v.Atom)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "PropertyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[28] = PropertyNotifyEventNew +} + +const ( + QueryShapeOfLargestCursor = 0 + QueryShapeOfFastestTile = 1 + QueryShapeOfFastestStipple = 2 +) + +type Rectangle struct { + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// RectangleRead reads a byte slice into a Rectangle value. +func RectangleRead(buf []byte, v *Rectangle) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], v.Height) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], v.BorderWidth) + v.Width = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], v.ValueMask) + v.Height = xgb.Get16(buf[b:]) b += 2 - return buf + return b } -// SequenceId returns the sequence id attached to the ConfigureRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ConfigureRequestEvent) SequenceId() uint16 { - return v.Sequence +// RectangleReadList reads a byte slice into a list of Rectangle values. +func RectangleReadList(buf []byte, dest []Rectangle) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rectangle{} + b += RectangleRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// String is a rudimentary string representation of ConfigureRequestEvent. -func (v ConfigureRequestEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("StackMode: %d", v.StackMode)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Sibling: %d", v.Sibling)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, xgb.Sprintf("ValueMask: %d", v.ValueMask)) - return "ConfigureRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Bytes writes a Rectangle value to a byte slice. +func (v Rectangle) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf } -func init() { - xgb.NewEventFuncs[23] = ConfigureRequestEventNew +// RectangleListBytes writes a list of Rectangle values to a byte slice. +func RectangleListBytes(buf []byte, list []Rectangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// GravityNotify is the event number for a GravityNotifyEvent. -const GravityNotify = 24 +// ReparentNotify is the event number for a ReparentNotifyEvent. +const ReparentNotify = 21 -type GravityNotifyEvent struct { +type ReparentNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - X int16 - Y int16 + Event Window + Window Window + Parent Window + X int16 + Y int16 + OverrideRedirect bool + // padding: 3 bytes } -// GravityNotifyEventNew constructs a GravityNotifyEvent value that implements xgb.Event from a byte slice. -func GravityNotifyEventNew(buf []byte) xgb.Event { - v := GravityNotifyEvent{} +// ReparentNotifyEventNew constructs a ReparentNotifyEvent value that implements xgb.Event from a byte slice. +func ReparentNotifyEventNew(buf []byte) xgb.Event { + v := ReparentNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -4642,22 +4505,34 @@ func GravityNotifyEventNew(buf []byte) xgb.Event { v.Window = Window(xgb.Get32(buf[b:])) b += 4 + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + v.X = int16(xgb.Get16(buf[b:])) b += 2 v.Y = int16(xgb.Get16(buf[b:])) b += 2 + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + return v } -// Bytes writes a GravityNotifyEvent value to a byte slice. -func (v GravityNotifyEvent) Bytes() []byte { +// Bytes writes a ReparentNotifyEvent value to a byte slice. +func (v ReparentNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 24 + buf[b] = 21 b += 1 b += 1 // padding @@ -4670,35 +4545,113 @@ func (v GravityNotifyEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Window)) b += 4 + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + xgb.Put16(buf[b:], uint16(v.X)) b += 2 xgb.Put16(buf[b:], uint16(v.Y)) b += 2 + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + return buf } -// SequenceId returns the sequence id attached to the GravityNotify event. +// SequenceId returns the sequence id attached to the ReparentNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v GravityNotifyEvent) SequenceId() uint16 { +func (v ReparentNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of GravityNotifyEvent. -func (v GravityNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +// String is a rudimentary string representation of ReparentNotifyEvent. +func (v ReparentNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - return "GravityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[24] = GravityNotifyEventNew + xgb.NewEventFuncs[21] = ReparentNotifyEventNew +} + +// BadRequest is the error number for a BadRequest. +const BadRequest = 1 + +type RequestError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. +func RequestErrorNew(buf []byte) xgb.Error { + v := RequestError{} + v.NiceName = "Request" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// SequenceId returns the sequence id attached to the BadRequest error. +// This is mostly used internally. +func (err RequestError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadRequest error. If no bad value exists, 0 is returned. +func (err RequestError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadRequest error. + +func (err RequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[1] = RequestErrorNew } // ResizeRequest is the event number for a ResizeRequestEvent. @@ -4780,185 +4733,318 @@ func init() { xgb.NewEventFuncs[25] = ResizeRequestEventNew } -// CirculateNotify is the event number for a CirculateNotifyEvent. -const CirculateNotify = 26 +type Rgb struct { + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes +} -type CirculateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - // padding: 4 bytes - Place byte - // padding: 3 bytes +// RgbRead reads a byte slice into a Rgb value. +func RgbRead(buf []byte, v *Rgb) int { + b := 0 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b } -// CirculateNotifyEventNew constructs a CirculateNotifyEvent value that implements xgb.Event from a byte slice. -func CirculateNotifyEventNew(buf []byte) xgb.Event { - v := CirculateNotifyEvent{} - b := 1 // don't read event number +// RgbReadList reads a byte slice into a list of Rgb values. +func RgbReadList(buf []byte, dest []Rgb) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rgb{} + b += RgbRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - b += 1 // padding +// Bytes writes a Rgb value to a byte slice. +func (v Rgb) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Red) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 + xgb.Put16(buf[b:], v.Green) + b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + xgb.Put16(buf[b:], v.Blue) + b += 2 - b += 4 // padding + b += 2 // padding - v.Place = buf[b] - b += 1 + return buf +} - b += 3 // padding +// RgbListBytes writes a list of Rgb values to a byte slice. +func RgbListBytes(buf []byte, list []Rgb) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} - return v +type ScreenInfo struct { + Root Window + DefaultColormap Colormap + WhitePixel uint32 + BlackPixel uint32 + CurrentInputMasks uint32 + WidthInPixels uint16 + HeightInPixels uint16 + WidthInMillimeters uint16 + HeightInMillimeters uint16 + MinInstalledMaps uint16 + MaxInstalledMaps uint16 + RootVisual Visualid + BackingStores byte + SaveUnders bool + RootDepth byte + AllowedDepthsLen byte + AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) } -// Bytes writes a CirculateNotifyEvent value to a byte slice. -func (v CirculateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// ScreenInfoRead reads a byte slice into a ScreenInfo value. +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { b := 0 - // write event number - buf[b] = 26 - b += 1 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - b += 1 // padding + v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + b += 4 - b += 2 // skip sequence number + v.WhitePixel = xgb.Get32(buf[b:]) + b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) + v.BlackPixel = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + v.CurrentInputMasks = xgb.Get32(buf[b:]) b += 4 - b += 4 // padding + v.WidthInPixels = xgb.Get16(buf[b:]) + b += 2 - buf[b] = v.Place + v.HeightInPixels = xgb.Get16(buf[b:]) + b += 2 + + v.WidthInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.HeightInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.MinInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.MaxInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.RootVisual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.BackingStores = buf[b] b += 1 - b += 3 // padding + if buf[b] == 1 { + v.SaveUnders = true + } else { + v.SaveUnders = false + } + b += 1 - return buf -} + v.RootDepth = buf[b] + b += 1 -// SequenceId returns the sequence id attached to the CirculateNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CirculateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} + v.AllowedDepthsLen = buf[b] + b += 1 -// String is a rudimentary string representation of CirculateNotifyEvent. -func (v CirculateNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) - return "CirculateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) + b += DepthInfoReadList(buf[b:], v.AllowedDepths) -func init() { - xgb.NewEventFuncs[26] = CirculateNotifyEventNew + return b } -// PropertyNotify is the event number for a PropertyNotifyEvent. -const PropertyNotify = 28 - -type PropertyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Atom Atom - Time Timestamp - State byte - // padding: 3 bytes +// 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++ { + dest[i] = ScreenInfo{} + b += ScreenInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// PropertyNotifyEventNew constructs a PropertyNotifyEvent value that implements xgb.Event from a byte slice. -func PropertyNotifyEventNew(buf []byte) xgb.Event { - v := PropertyNotifyEvent{} - b := 1 // don't read event number +// Bytes writes a ScreenInfo value to a byte slice. +func (v ScreenInfo) Bytes() []byte { + buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) + b := 0 - b += 1 // padding + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(v.DefaultColormap)) + b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], v.WhitePixel) b += 4 - v.Atom = Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], v.BlackPixel) b += 4 - v.Time = Timestamp(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], v.CurrentInputMasks) b += 4 - v.State = buf[b] + xgb.Put16(buf[b:], v.WidthInPixels) + b += 2 + + xgb.Put16(buf[b:], v.HeightInPixels) + b += 2 + + xgb.Put16(buf[b:], v.WidthInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.HeightInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.MinInstalledMaps) + b += 2 + + xgb.Put16(buf[b:], v.MaxInstalledMaps) + b += 2 + + xgb.Put32(buf[b:], uint32(v.RootVisual)) + b += 4 + + buf[b] = v.BackingStores b += 1 - b += 3 // padding + if v.SaveUnders { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - return v + buf[b] = v.RootDepth + b += 1 + + buf[b] = v.AllowedDepthsLen + b += 1 + + b += DepthInfoListBytes(buf[b:], v.AllowedDepths) + + return buf } -// Bytes writes a PropertyNotifyEvent value to a byte slice. -func (v PropertyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. +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 +} - // write event number - buf[b] = 28 - b += 1 +// ScreenInfoListSize computes the size (bytes) of a list of ScreenInfo values. +func ScreenInfoListSize(list []ScreenInfo) int { + size := 0 + for _, item := range list { + size += (40 + DepthInfoListSize(item.AllowedDepths)) + } + return size +} - b += 1 // padding +const ( + ScreenSaverReset = 0 + ScreenSaverActive = 1 +) - b += 2 // skip sequence number +type Segment struct { + X1 int16 + Y1 int16 + X2 int16 + Y2 int16 +} - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 +// SegmentRead reads a byte slice into a Segment value. +func SegmentRead(buf []byte, v *Segment) int { + b := 0 - xgb.Put32(buf[b:], uint32(v.Atom)) - b += 4 + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 - buf[b] = v.State - b += 1 + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 - b += 3 // padding + v.Y2 = int16(xgb.Get16(buf[b:])) + b += 2 - return buf + return b } -// SequenceId returns the sequence id attached to the PropertyNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v PropertyNotifyEvent) SequenceId() uint16 { - return v.Sequence +// SegmentReadList reads a byte slice into a list of Segment values. +func SegmentReadList(buf []byte, dest []Segment) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Segment{} + b += SegmentRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// String is a rudimentary string representation of PropertyNotifyEvent. -func (v PropertyNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Atom: %d", v.Atom)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "PropertyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Bytes writes a Segment value to a byte slice. +func (v Segment) 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.Y2)) + b += 2 + + return buf } -func init() { - xgb.NewEventFuncs[28] = PropertyNotifyEventNew +// SegmentListBytes writes a list of Segment values to a byte slice. +func SegmentListBytes(buf []byte, list []Segment) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } // SelectionClear is the event number for a SelectionClearEvent. @@ -5040,23 +5126,22 @@ func init() { xgb.NewEventFuncs[29] = SelectionClearEventNew } -// SelectionRequest is the event number for a SelectionRequestEvent. -const SelectionRequest = 30 +// SelectionNotify is the event number for a SelectionNotifyEvent. +const SelectionNotify = 31 -type SelectionRequestEvent struct { +type SelectionNotifyEvent struct { Sequence uint16 // padding: 1 bytes Time Timestamp - Owner Window Requestor Window Selection Atom Target Atom Property Atom } -// SelectionRequestEventNew constructs a SelectionRequestEvent value that implements xgb.Event from a byte slice. -func SelectionRequestEventNew(buf []byte) xgb.Event { - v := SelectionRequestEvent{} +// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. +func SelectionNotifyEventNew(buf []byte) xgb.Event { + v := SelectionNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -5067,9 +5152,6 @@ func SelectionRequestEventNew(buf []byte) xgb.Event { v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.Owner = Window(xgb.Get32(buf[b:])) - b += 4 - v.Requestor = Window(xgb.Get32(buf[b:])) b += 4 @@ -5085,13 +5167,13 @@ func SelectionRequestEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a SelectionRequestEvent value to a byte slice. -func (v SelectionRequestEvent) Bytes() []byte { +// Bytes writes a SelectionNotifyEvent value to a byte slice. +func (v SelectionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 30 + buf[b] = 31 b += 1 b += 1 // padding @@ -5101,9 +5183,6 @@ func (v SelectionRequestEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Owner)) - b += 4 - xgb.Put32(buf[b:], uint32(v.Requestor)) b += 4 @@ -5119,46 +5198,46 @@ func (v SelectionRequestEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the SelectionRequest event. +// SequenceId returns the sequence id attached to the SelectionNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v SelectionRequestEvent) SequenceId() uint16 { +func (v SelectionNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of SelectionRequestEvent. -func (v SelectionRequestEvent) String() string { - fieldVals := make([]string, 0, 7) +// String is a rudimentary string representation of SelectionNotifyEvent. +func (v SelectionNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) - return "SelectionRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[30] = SelectionRequestEventNew + xgb.NewEventFuncs[31] = SelectionNotifyEventNew } -// SelectionNotify is the event number for a SelectionNotifyEvent. -const SelectionNotify = 31 +// SelectionRequest is the event number for a SelectionRequestEvent. +const SelectionRequest = 30 -type SelectionNotifyEvent struct { +type SelectionRequestEvent struct { Sequence uint16 // padding: 1 bytes Time Timestamp + Owner Window Requestor Window Selection Atom Target Atom Property Atom } -// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. -func SelectionNotifyEventNew(buf []byte) xgb.Event { - v := SelectionNotifyEvent{} +// SelectionRequestEventNew constructs a SelectionRequestEvent value that implements xgb.Event from a byte slice. +func SelectionRequestEventNew(buf []byte) xgb.Event { + v := SelectionRequestEvent{} b := 1 // don't read event number b += 1 // padding @@ -5169,6 +5248,9 @@ func SelectionNotifyEventNew(buf []byte) xgb.Event { v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + v.Requestor = Window(xgb.Get32(buf[b:])) b += 4 @@ -5184,13 +5266,13 @@ func SelectionNotifyEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a SelectionNotifyEvent value to a byte slice. -func (v SelectionNotifyEvent) Bytes() []byte { +// Bytes writes a SelectionRequestEvent value to a byte slice. +func (v SelectionRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 31 + buf[b] = 30 b += 1 b += 1 // padding @@ -5200,6 +5282,9 @@ func (v SelectionNotifyEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Time)) b += 4 + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + xgb.Put32(buf[b:], uint32(v.Requestor)) b += 4 @@ -5215,559 +5300,775 @@ func (v SelectionNotifyEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the SelectionNotify event. +// SequenceId returns the sequence id attached to the SelectionRequest event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v SelectionNotifyEvent) SequenceId() uint16 { +func (v SelectionRequestEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of SelectionNotifyEvent. -func (v SelectionNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) +// String is a rudimentary string representation of SelectionRequestEvent. +func (v SelectionRequestEvent) String() string { + fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) - return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "SelectionRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[31] = SelectionNotifyEventNew + xgb.NewEventFuncs[30] = SelectionRequestEventNew } -// ColormapNotify is the event number for a ColormapNotifyEvent. -const ColormapNotify = 32 +const ( + SendEventDestPointerWindow = 0 + SendEventDestItemFocus = 1 +) -type ColormapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Colormap Colormap - New bool - State byte - // padding: 2 bytes +const ( + SetModeInsert = 0 + SetModeDelete = 1 +) + +type SetupAuthenticate struct { + Status byte + // padding: 5 bytes + Length uint16 + Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) } -// ColormapNotifyEventNew constructs a ColormapNotifyEvent value that implements xgb.Event from a byte slice. -func ColormapNotifyEventNew(buf []byte) xgb.Event { - v := ColormapNotifyEvent{} - b := 1 // don't read event number +// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. +func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { + b := 0 - b += 1 // padding + v.Status = buf[b] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + b += 5 // padding + + v.Length = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + { + byteString := make([]byte, (int(v.Length) * 4)) + copy(byteString[:(int(v.Length)*4)], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int((int(v.Length) * 4))) + } - v.Colormap = Colormap(xgb.Get32(buf[b:])) - b += 4 + return b +} - if buf[b] == 1 { - v.New = true - } else { - v.New = false +// SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values. +func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupAuthenticate{} + b += SetupAuthenticateRead(buf[b:], &dest[i]) } - b += 1 + return xgb.Pad(b) +} - v.State = buf[b] +// Bytes writes a SetupAuthenticate value to a byte slice. +func (v SetupAuthenticate) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) + b := 0 + + buf[b] = v.Status b += 1 - b += 2 // padding + b += 5 // padding - return v + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:(int(v.Length)*4)]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return buf } -// Bytes writes a ColormapNotifyEvent value to a byte slice. -func (v ColormapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// SetupAuthenticateListBytes writes a list of SetupAuthenticate values to a byte slice. +func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} - // write event number - buf[b] = 32 +// SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. +func SetupAuthenticateListSize(list []SetupAuthenticate) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) + } + return size +} + +type SetupFailed struct { + Status byte + ReasonLen byte + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + Reason string // size: xgb.Pad((int(ReasonLen) * 1)) +} + +// SetupFailedRead reads a byte slice into a SetupFailed value. +func SetupFailedRead(buf []byte, v *SetupFailed) int { + b := 0 + + v.Status = buf[b] b += 1 - b += 1 // padding + v.ReasonLen = buf[b] + b += 1 - b += 2 // skip sequence number + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(v.Colormap)) - b += 4 + v.Length = xgb.Get16(buf[b:]) + b += 2 - if v.New { - buf[b] = 1 - } else { - buf[b] = 0 + { + byteString := make([]byte, v.ReasonLen) + copy(byteString[:v.ReasonLen], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int(v.ReasonLen)) + } + + return b +} + +// SetupFailedReadList reads a byte slice into a list of SetupFailed values. +func SetupFailedReadList(buf []byte, dest []SetupFailed) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupFailed{} + b += SetupFailedRead(buf[b:], &dest[i]) } + return xgb.Pad(b) +} + +// Bytes writes a SetupFailed value to a byte slice. +func (v SetupFailed) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) + b := 0 + + buf[b] = v.Status b += 1 - buf[b] = v.State + buf[b] = v.ReasonLen b += 1 - b += 2 // padding + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:v.ReasonLen]) + b += xgb.Pad(int(v.ReasonLen)) return buf } -// SequenceId returns the sequence id attached to the ColormapNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ColormapNotifyEvent) SequenceId() uint16 { - return v.Sequence +// SetupFailedListBytes writes a list of SetupFailed values to a byte slice. +func SetupFailedListBytes(buf []byte, list []SetupFailed) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of ColormapNotifyEvent. -func (v ColormapNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Colormap: %d", v.Colormap)) - fieldVals = append(fieldVals, xgb.Sprintf("New: %t", v.New)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// SetupFailedListSize computes the size (bytes) of a list of SetupFailed values. +func SetupFailedListSize(list []SetupFailed) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.ReasonLen) * 1))) + } + return size } -func init() { - xgb.NewEventFuncs[32] = ColormapNotifyEventNew +type SetupInfo struct { + Status byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + ReleaseNumber uint32 + ResourceIdBase uint32 + ResourceIdMask uint32 + MotionBufferSize uint32 + VendorLen uint16 + MaximumRequestLength uint16 + RootsLen byte + PixmapFormatsLen byte + ImageByteOrder byte + BitmapFormatBitOrder byte + BitmapFormatScanlineUnit byte + BitmapFormatScanlinePad byte + MinKeycode Keycode + MaxKeycode Keycode + // padding: 4 bytes + Vendor string // size: xgb.Pad((int(VendorLen) * 1)) + PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) + Roots []ScreenInfo // size: ScreenInfoListSize(Roots) } -// ClientMessage is the event number for a ClientMessageEvent. -const ClientMessage = 33 +// SetupInfoRead reads a byte slice into a SetupInfo value. +func SetupInfoRead(buf []byte, v *SetupInfo) int { + b := 0 -type ClientMessageEvent struct { - Sequence uint16 - Format byte - Window Window - Type Atom - Data ClientMessageDataUnion -} + v.Status = buf[b] + b += 1 -// ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. -func ClientMessageEventNew(buf []byte) xgb.Event { - v := ClientMessageEvent{} - b := 1 // don't read event number + b += 1 // padding - v.Format = buf[b] - b += 1 + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) + v.Length = xgb.Get16(buf[b:]) + b += 2 + + v.ReleaseNumber = xgb.Get32(buf[b:]) b += 4 - v.Type = Atom(xgb.Get32(buf[b:])) + v.ResourceIdBase = xgb.Get32(buf[b:]) b += 4 - v.Data = ClientMessageDataUnion{} - b += ClientMessageDataUnionRead(buf[b:], &v.Data) + v.ResourceIdMask = xgb.Get32(buf[b:]) + b += 4 - return v -} + v.MotionBufferSize = xgb.Get32(buf[b:]) + b += 4 -// Bytes writes a ClientMessageEvent value to a byte slice. -func (v ClientMessageEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 + v.VendorLen = xgb.Get16(buf[b:]) + b += 2 - // write event number - buf[b] = 33 + v.MaximumRequestLength = xgb.Get16(buf[b:]) + b += 2 + + v.RootsLen = buf[b] b += 1 - buf[b] = v.Format + v.PixmapFormatsLen = buf[b] b += 1 - b += 2 // skip sequence number + v.ImageByteOrder = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + v.BitmapFormatBitOrder = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Type)) - b += 4 + v.BitmapFormatScanlineUnit = buf[b] + b += 1 + + v.BitmapFormatScanlinePad = buf[b] + b += 1 + + v.MinKeycode = Keycode(buf[b]) + b += 1 + + v.MaxKeycode = Keycode(buf[b]) + b += 1 + + b += 4 // padding { - unionBytes := v.Data.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) + byteString := make([]byte, v.VendorLen) + copy(byteString[:v.VendorLen], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLen)) } - return buf -} + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) + b += FormatReadList(buf[b:], v.PixmapFormats) -// SequenceId returns the sequence id attached to the ClientMessage event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ClientMessageEvent) SequenceId() uint16 { - return v.Sequence -} + v.Roots = make([]ScreenInfo, v.RootsLen) + b += ScreenInfoReadList(buf[b:], v.Roots) -// String is a rudimentary string representation of ClientMessageEvent. -func (v ClientMessageEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) - return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return b } -func init() { - xgb.NewEventFuncs[33] = ClientMessageEventNew +// SetupInfoReadList reads a byte slice into a list of SetupInfo values. +func SetupInfoReadList(buf []byte, dest []SetupInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupInfo{} + b += SetupInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// MappingNotify is the event number for a MappingNotifyEvent. -const MappingNotify = 34 - -type MappingNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Request byte - FirstKeycode Keycode - Count byte - // padding: 1 bytes -} +// Bytes writes a SetupInfo value to a byte slice. +func (v SetupInfo) Bytes() []byte { + buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) + b := 0 -// MappingNotifyEventNew constructs a MappingNotifyEvent value that implements xgb.Event from a byte slice. -func MappingNotifyEventNew(buf []byte) xgb.Event { - v := MappingNotifyEvent{} - b := 1 // don't read event number + buf[b] = v.Status + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.ProtocolMajorVersion) b += 2 - v.Request = buf[b] - b += 1 + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 - v.FirstKeycode = Keycode(buf[b]) - b += 1 + xgb.Put16(buf[b:], v.Length) + b += 2 - v.Count = buf[b] - b += 1 + xgb.Put32(buf[b:], v.ReleaseNumber) + b += 4 - b += 1 // padding + xgb.Put32(buf[b:], v.ResourceIdBase) + b += 4 - return v -} + xgb.Put32(buf[b:], v.ResourceIdMask) + b += 4 -// Bytes writes a MappingNotifyEvent value to a byte slice. -func (v MappingNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 + xgb.Put32(buf[b:], v.MotionBufferSize) + b += 4 - // write event number - buf[b] = 34 + xgb.Put16(buf[b:], v.VendorLen) + b += 2 + + xgb.Put16(buf[b:], v.MaximumRequestLength) + b += 2 + + buf[b] = v.RootsLen b += 1 - b += 1 // padding + buf[b] = v.PixmapFormatsLen + b += 1 - b += 2 // skip sequence number + buf[b] = v.ImageByteOrder + b += 1 - buf[b] = v.Request + buf[b] = v.BitmapFormatBitOrder b += 1 - buf[b] = byte(v.FirstKeycode) + buf[b] = v.BitmapFormatScanlineUnit b += 1 - buf[b] = v.Count + buf[b] = v.BitmapFormatScanlinePad b += 1 - b += 1 // padding + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + b += 4 // padding + + copy(buf[b:], v.Vendor[:v.VendorLen]) + b += xgb.Pad(int(v.VendorLen)) + + b += FormatListBytes(buf[b:], v.PixmapFormats) + + b += ScreenInfoListBytes(buf[b:], v.Roots) return buf } -// SequenceId returns the sequence id attached to the MappingNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v MappingNotifyEvent) SequenceId() uint16 { - return v.Sequence +// SetupInfoListBytes writes a list of SetupInfo values to a byte slice. +func SetupInfoListBytes(buf []byte, list []SetupInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of MappingNotifyEvent. -func (v MappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) - fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. +func SetupInfoListSize(list []SetupInfo) int { + size := 0 + for _, item := range list { + size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) + } + return size } -func init() { - xgb.NewEventFuncs[34] = MappingNotifyEventNew +type SetupRequest struct { + ByteOrder byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + AuthorizationProtocolNameLen uint16 + AuthorizationProtocolDataLen uint16 + // padding: 2 bytes + AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) + AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) } -// KeyRelease is the event number for a KeyReleaseEvent. -const KeyRelease = 3 +// SetupRequestRead reads a byte slice into a SetupRequest value. +func SetupRequestRead(buf []byte, v *SetupRequest) int { + b := 0 -type KeyReleaseEvent KeyPressEvent + v.ByteOrder = buf[b] + b += 1 -// KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice. -func KeyReleaseEventNew(buf []byte) xgb.Event { - return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) -} + b += 1 // padding -// Bytes writes a KeyReleaseEvent value to a byte slice. -func (v KeyReleaseEvent) Bytes() []byte { - return KeyPressEvent(v).Bytes() -} + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the KeyRelease event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v KeyReleaseEvent) SequenceId() uint16 { - return v.Sequence -} + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 -func (v KeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + b += 2 -func init() { - xgb.NewEventFuncs[3] = KeyReleaseEventNew -} + v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + b += 2 -// ButtonRelease is the event number for a ButtonReleaseEvent. -const ButtonRelease = 5 + b += 2 // padding -type ButtonReleaseEvent ButtonPressEvent + { + byteString := make([]byte, v.AuthorizationProtocolNameLen) + copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) + v.AuthorizationProtocolName = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + } -// ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. -func ButtonReleaseEventNew(buf []byte) xgb.Event { - return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) -} + { + byteString := make([]byte, v.AuthorizationProtocolDataLen) + copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) + v.AuthorizationProtocolData = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + } -// Bytes writes a ButtonReleaseEvent value to a byte slice. -func (v ButtonReleaseEvent) Bytes() []byte { - return ButtonPressEvent(v).Bytes() + return b } -// SequenceId returns the sequence id attached to the ButtonRelease event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ButtonReleaseEvent) SequenceId() uint16 { - return v.Sequence +// SetupRequestReadList reads a byte slice into a list of SetupRequest values. +func SetupRequestReadList(buf []byte, dest []SetupRequest) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupRequest{} + b += SetupRequestRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -func (v ButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Bytes writes a SetupRequest value to a byte slice. +func (v SetupRequest) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) + b := 0 -func init() { - xgb.NewEventFuncs[5] = ButtonReleaseEventNew -} + buf[b] = v.ByteOrder + b += 1 -// LeaveNotify is the event number for a LeaveNotifyEvent. -const LeaveNotify = 8 + b += 1 // padding -type LeaveNotifyEvent EnterNotifyEvent + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 -// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. -func LeaveNotifyEventNew(buf []byte) xgb.Event { - return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) -} + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 -// Bytes writes a LeaveNotifyEvent value to a byte slice. -func (v LeaveNotifyEvent) Bytes() []byte { - return EnterNotifyEvent(v).Bytes() + xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) + b += 2 + + xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + + copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + + return buf } -// SequenceId returns the sequence id attached to the LeaveNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v LeaveNotifyEvent) SequenceId() uint16 { - return v.Sequence +// SetupRequestListBytes writes a list of SetupRequest values to a byte slice. +func SetupRequestListBytes(buf []byte, list []SetupRequest) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -func (v LeaveNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) - return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. +func SetupRequestListSize(list []SetupRequest) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) + } + return size } -func init() { - xgb.NewEventFuncs[8] = LeaveNotifyEventNew +const ( + StackModeAbove = 0 + StackModeBelow = 1 + StackModeTopIf = 2 + StackModeBottomIf = 3 + StackModeOpposite = 4 +) + +type Str struct { + NameLen byte + Name string // size: xgb.Pad((int(NameLen) * 1)) } -// FocusOut is the event number for a FocusOutEvent. -const FocusOut = 10 +// StrRead reads a byte slice into a Str value. +func StrRead(buf []byte, v *Str) int { + b := 0 -type FocusOutEvent FocusInEvent + v.NameLen = buf[b] + b += 1 -// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. -func FocusOutEventNew(buf []byte) xgb.Event { - return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b } -// Bytes writes a FocusOutEvent value to a byte slice. -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() +// StrReadList reads a byte slice into a list of Str values. +func StrReadList(buf []byte, dest []Str) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Str{} + b += StrRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// SequenceId returns the sequence id attached to the FocusOut event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v FocusOutEvent) SequenceId() uint16 { - return v.Sequence +// Bytes writes a Str value to a byte slice. +func (v Str) Bytes() []byte { + buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 + + buf[b] = v.NameLen + b += 1 + + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) + + return buf } -func (v FocusOutEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) - return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// StrListBytes writes a list of Str values to a byte slice. +func StrListBytes(buf []byte, list []Str) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -func init() { - xgb.NewEventFuncs[10] = FocusOutEventNew +// StrListSize computes the size (bytes) of a list of Str values. +func StrListSize(list []Str) int { + size := 0 + for _, item := range list { + size += (1 + xgb.Pad((int(item.NameLen) * 1))) + } + return size } -// CirculateRequest is the event number for a CirculateRequestEvent. -const CirculateRequest = 27 +const ( + SubwindowModeClipByChildren = 0 + SubwindowModeIncludeInferiors = 1 +) -type CirculateRequestEvent CirculateNotifyEvent +const ( + TimeCurrentTime = 0 +) -// CirculateRequestEventNew constructs a CirculateRequestEvent value that implements xgb.Event from a byte slice. -func CirculateRequestEventNew(buf []byte) xgb.Event { - return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) +type Timecoord struct { + Time Timestamp + X int16 + Y int16 } -// Bytes writes a CirculateRequestEvent value to a byte slice. -func (v CirculateRequestEvent) Bytes() []byte { - return CirculateNotifyEvent(v).Bytes() +// TimecoordRead reads a byte slice into a Timecoord value. +func TimecoordRead(buf []byte, v *Timecoord) int { + b := 0 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return b } -// SequenceId returns the sequence id attached to the CirculateRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CirculateRequestEvent) SequenceId() uint16 { - return v.Sequence +// TimecoordReadList reads a byte slice into a list of Timecoord values. +func TimecoordReadList(buf []byte, dest []Timecoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Timecoord{} + b += TimecoordRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -func (v CirculateRequestEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) - return "CirculateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Bytes writes a Timecoord value to a byte slice. +func (v Timecoord) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf } -func init() { - xgb.NewEventFuncs[27] = CirculateRequestEventNew +// TimecoordListBytes writes a list of Timecoord values to a byte slice. +func TimecoordListBytes(buf []byte, list []Timecoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// BadRequest is the error number for a BadRequest. -const BadRequest = 1 +type Timestamp uint32 -type RequestError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte +// UnmapNotify is the event number for a UnmapNotifyEvent. +const UnmapNotify = 18 + +type UnmapNotifyEvent struct { + Sequence uint16 // padding: 1 bytes + Event Window + Window Window + FromConfigure bool + // padding: 3 bytes } -// RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. -func RequestErrorNew(buf []byte) xgb.Error { - v := RequestError{} - v.NiceName = "Request" +// UnmapNotifyEventNew constructs a UnmapNotifyEvent value that implements xgb.Event from a byte slice. +func UnmapNotifyEventNew(buf []byte) xgb.Event { + v := UnmapNotifyEvent{} + b := 1 // don't read event number - b := 1 // skip error determinant - b += 1 // don't read error number + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.BadValue = xgb.Get32(buf[b:]) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 - v.MajorOpcode = buf[b] + if buf[b] == 1 { + v.FromConfigure = true + } else { + v.FromConfigure = false + } b += 1 - b += 1 // padding + b += 3 // padding return v } -// SequenceId returns the sequence id attached to the BadRequest error. -// This is mostly used internally. -func (err RequestError) SequenceId() uint16 { - return err.Sequence -} +// Bytes writes a UnmapNotifyEvent value to a byte slice. +func (v UnmapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 -// BadId returns the 'BadValue' number if one exists for the BadRequest error. If no bad value exists, 0 is returned. -func (err RequestError) BadId() uint32 { - return err.BadValue + // write event number + buf[b] = 18 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + if v.FromConfigure { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf } -// Error returns a rudimentary string representation of the BadRequest error. +// SequenceId returns the sequence id attached to the UnmapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v UnmapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} -func (err RequestError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// String is a rudimentary string representation of UnmapNotifyEvent. +func (v UnmapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) + return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewErrorFuncs[1] = RequestErrorNew + xgb.NewEventFuncs[18] = UnmapNotifyEventNew } // BadValue is the error number for a BadValue. @@ -5834,6 +6135,207 @@ func init() { xgb.NewErrorFuncs[2] = ValueErrorNew } +const ( + VisibilityUnobscured = 0 + VisibilityPartiallyObscured = 1 + VisibilityFullyObscured = 2 +) + +// VisibilityNotify is the event number for a VisibilityNotifyEvent. +const VisibilityNotify = 15 + +type VisibilityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + State byte + // padding: 3 bytes +} + +// VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. +func VisibilityNotifyEventNew(buf []byte) xgb.Event { + v := VisibilityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a VisibilityNotifyEvent value to a byte slice. +func (v VisibilityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 15 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the VisibilityNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v VisibilityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of VisibilityNotifyEvent. +func (v VisibilityNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[15] = VisibilityNotifyEventNew +} + +const ( + VisualClassStaticGray = 0 + VisualClassGrayScale = 1 + VisualClassStaticColor = 2 + VisualClassPseudoColor = 3 + VisualClassTrueColor = 4 + VisualClassDirectColor = 5 +) + +type VisualInfo struct { + VisualId Visualid + Class byte + BitsPerRgbValue byte + ColormapEntries uint16 + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 4 bytes +} + +// VisualInfoRead reads a byte slice into a VisualInfo value. +func VisualInfoRead(buf []byte, v *VisualInfo) int { + b := 0 + + v.VisualId = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Class = buf[b] + b += 1 + + v.BitsPerRgbValue = buf[b] + b += 1 + + v.ColormapEntries = xgb.Get16(buf[b:]) + b += 2 + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + return b +} + +// VisualInfoReadList reads a byte slice into a list of VisualInfo values. +func VisualInfoReadList(buf []byte, dest []VisualInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = VisualInfo{} + b += VisualInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a VisualInfo value to a byte slice. +func (v VisualInfo) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + xgb.Put32(buf[b:], uint32(v.VisualId)) + b += 4 + + buf[b] = v.Class + b += 1 + + buf[b] = v.BitsPerRgbValue + b += 1 + + xgb.Put16(buf[b:], v.ColormapEntries) + b += 2 + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + b += 4 // padding + + return buf +} + +// VisualInfoListBytes writes a list of VisualInfo values to a byte slice. +func VisualInfoListBytes(buf []byte, list []VisualInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Visualid uint32 + +type Window uint32 + +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil +} + +const ( + WindowNone = 0 +) + // BadWindow is the error number for a BadWindow. const BadWindow = 3 @@ -5872,654 +6374,681 @@ func init() { xgb.NewErrorFuncs[3] = WindowErrorNew } -// BadPixmap is the error number for a BadPixmap. -const BadPixmap = 4 +const ( + WindowClassCopyFromParent = 0 + WindowClassInputOutput = 1 + WindowClassInputOnly = 2 +) -type PixmapError ValueError +// Skipping definition for base type 'Bool' -// PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. -func PixmapErrorNew(buf []byte) xgb.Error { - v := PixmapError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Pixmap" - return v -} +// Skipping definition for base type 'Byte' -// SequenceId returns the sequence id attached to the BadPixmap error. -// This is mostly used internally. -func (err PixmapError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Card8' -// BadId returns the 'BadValue' number if one exists for the BadPixmap error. If no bad value exists, 0 is returned. -func (err PixmapError) BadId() uint32 { - return err.BadValue -} +// Skipping definition for base type 'Char' -// Error returns a rudimentary string representation of the BadPixmap error. -func (err PixmapError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Void' -func init() { - xgb.NewErrorFuncs[4] = PixmapErrorNew -} +// Skipping definition for base type 'Double' -// BadAtom is the error number for a BadAtom. -const BadAtom = 5 +// Skipping definition for base type 'Float' -type AtomError ValueError +// Skipping definition for base type 'Int16' -// AtomErrorNew constructs a AtomError value that implements xgb.Error from a byte slice. -func AtomErrorNew(buf []byte) xgb.Error { - v := AtomError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Atom" - return v +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// AllocColorCookie is a cookie used only for AllocColor requests. +type AllocColorCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the BadAtom error. -// This is mostly used internally. -func (err AtomError) SequenceId() uint16 { - return err.Sequence +// AllocColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorCookie.Reply() +func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} } -// BadId returns the 'BadValue' number if one exists for the BadAtom error. If no bad value exists, 0 is returned. -func (err AtomError) BadId() uint32 { - return err.BadValue +// AllocColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} } -// Error returns a rudimentary string representation of the BadAtom error. -func (err AtomError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllocColorReply represents the data returned from a AllocColor request. +type AllocColorReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes + Pixel uint32 } -func init() { - xgb.NewErrorFuncs[5] = AtomErrorNew +// Reply blocks and returns the reply data for a AllocColor request. +func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorReply(buf), nil } -// BadCursor is the error number for a BadCursor. -const BadCursor = 6 +// allocColorReply reads a byte slice into a AllocColorReply value. +func allocColorReply(buf []byte) *AllocColorReply { + v := new(AllocColorReply) + b := 1 // skip reply determinant -type CursorError ValueError + b += 1 // padding -// CursorErrorNew constructs a CursorError value that implements xgb.Error from a byte slice. -func CursorErrorNew(buf []byte) xgb.Error { - v := CursorError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Cursor" - return v -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the BadCursor error. -// This is mostly used internally. -func (err CursorError) SequenceId() uint16 { - return err.Sequence -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// BadId returns the 'BadValue' number if one exists for the BadCursor error. If no bad value exists, 0 is returned. -func (err CursorError) BadId() uint32 { - return err.BadValue -} + v.Red = xgb.Get16(buf[b:]) + b += 2 -// Error returns a rudimentary string representation of the BadCursor error. -func (err CursorError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.Green = xgb.Get16(buf[b:]) + b += 2 -func init() { - xgb.NewErrorFuncs[6] = CursorErrorNew -} + v.Blue = xgb.Get16(buf[b:]) + b += 2 -// BadFont is the error number for a BadFont. -const BadFont = 7 + b += 2 // padding -type FontError ValueError + v.Pixel = xgb.Get32(buf[b:]) + b += 4 -// FontErrorNew constructs a FontError value that implements xgb.Error from a byte slice. -func FontErrorNew(buf []byte) xgb.Error { - v := FontError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Font" return v } -// SequenceId returns the sequence id attached to the BadFont error. -// This is mostly used internally. -func (err FontError) SequenceId() uint16 { - return err.Sequence -} +// Write request to wire for AllocColor +// allocColorRequest writes a AllocColor request to a byte slice. +func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) -// BadId returns the 'BadValue' number if one exists for the BadFont error. If no bad value exists, 0 is returned. -func (err FontError) BadId() uint32 { - return err.BadValue -} + buf[b] = 84 // request opcode + b += 1 -// Error returns a rudimentary string representation of the BadFont error. -func (err FontError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + b += 1 // padding -func init() { - xgb.NewErrorFuncs[7] = FontErrorNew -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadMatch is the error number for a BadMatch. -const BadMatch = 8 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -type MatchError RequestError + xgb.Put16(buf[b:], Red) + b += 2 -// MatchErrorNew constructs a MatchError value that implements xgb.Error from a byte slice. -func MatchErrorNew(buf []byte) xgb.Error { - v := MatchError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Match" - return v + xgb.Put16(buf[b:], Green) + b += 2 + + xgb.Put16(buf[b:], Blue) + b += 2 + + b += 2 // padding + + return buf } -// SequenceId returns the sequence id attached to the BadMatch error. -// This is mostly used internally. -func (err MatchError) SequenceId() uint16 { - return err.Sequence +// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. +type AllocColorCellsCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadMatch error. If no bad value exists, 0 is returned. -func (err MatchError) BadId() uint32 { - return err.BadValue +// AllocColorCells sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorCellsCookie.Reply() +func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} } -// Error returns a rudimentary string representation of the BadMatch error. -func (err MatchError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllocColorCellsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} } -func init() { - xgb.NewErrorFuncs[8] = MatchErrorNew +// AllocColorCellsReply represents the data returned from a AllocColorCells request. +type AllocColorCellsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + PixelsLen uint16 + MasksLen uint16 + // padding: 20 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) + Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) } -// BadDrawable is the error number for a BadDrawable. -const BadDrawable = 9 +// Reply blocks and returns the reply data for a AllocColorCells request. +func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorCellsReply(buf), nil +} -type DrawableError ValueError +// allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. +func allocColorCellsReply(buf []byte) *AllocColorCellsReply { + v := new(AllocColorCellsReply) + b := 1 // skip reply determinant -// DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. -func DrawableErrorNew(buf []byte) xgb.Error { - v := DrawableError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Drawable" - return v -} + b += 1 // padding -// SequenceId returns the sequence id attached to the BadDrawable error. -// This is mostly used internally. -func (err DrawableError) SequenceId() uint16 { - return err.Sequence -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadDrawable error. If no bad value exists, 0 is returned. -func (err DrawableError) BadId() uint32 { - return err.BadValue -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// Error returns a rudimentary string representation of the BadDrawable error. -func (err DrawableError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.PixelsLen = xgb.Get16(buf[b:]) + b += 2 -func init() { - xgb.NewErrorFuncs[9] = DrawableErrorNew -} + v.MasksLen = xgb.Get16(buf[b:]) + b += 2 -// BadAccess is the error number for a BadAccess. -const BadAccess = 10 + b += 20 // padding -type AccessError RequestError + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Masks = make([]uint32, v.MasksLen) + for i := 0; i < int(v.MasksLen); i++ { + v.Masks[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) -// AccessErrorNew constructs a AccessError value that implements xgb.Error from a byte slice. -func AccessErrorNew(buf []byte) xgb.Error { - v := AccessError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Access" return v } -// SequenceId returns the sequence id attached to the BadAccess error. -// This is mostly used internally. -func (err AccessError) SequenceId() uint16 { - return err.Sequence -} +// Write request to wire for AllocColorCells +// allocColorCellsRequest writes a AllocColorCells request to a byte slice. +func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) -// BadId returns the 'BadValue' number if one exists for the BadAccess error. If no bad value exists, 0 is returned. -func (err AccessError) BadId() uint32 { - return err.BadValue -} + buf[b] = 86 // request opcode + b += 1 -// Error returns a rudimentary string representation of the BadAccess error. -func (err AccessError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAccess {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -func init() { - xgb.NewErrorFuncs[10] = AccessErrorNew -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadAlloc is the error number for a BadAlloc. -const BadAlloc = 11 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -type AllocError RequestError + xgb.Put16(buf[b:], Colors) + b += 2 -// AllocErrorNew constructs a AllocError value that implements xgb.Error from a byte slice. -func AllocErrorNew(buf []byte) xgb.Error { - v := AllocError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Alloc" - return v + xgb.Put16(buf[b:], Planes) + b += 2 + + return buf } -// SequenceId returns the sequence id attached to the BadAlloc error. -// This is mostly used internally. -func (err AllocError) SequenceId() uint16 { - return err.Sequence +// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. +type AllocColorPlanesCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadAlloc error. If no bad value exists, 0 is returned. -func (err AllocError) BadId() uint32 { - return err.BadValue +// AllocColorPlanes sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorPlanesCookie.Reply() +func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} } -// Error returns a rudimentary string representation of the BadAlloc error. -func (err AllocError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllocColorPlanesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} } -func init() { - xgb.NewErrorFuncs[11] = AllocErrorNew +// AllocColorPlanesReply represents the data returned from a AllocColorPlanes request. +type AllocColorPlanesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + PixelsLen uint16 + // padding: 2 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 8 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) } -// BadColormap is the error number for a BadColormap. -const BadColormap = 12 +// Reply blocks and returns the reply data for a AllocColorPlanes request. +func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorPlanesReply(buf), nil +} -type ColormapError ValueError +// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. +func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { + v := new(AllocColorPlanesReply) + b := 1 // skip reply determinant -// ColormapErrorNew constructs a ColormapError value that implements xgb.Error from a byte slice. -func ColormapErrorNew(buf []byte) xgb.Error { - v := ColormapError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Colormap" - return v -} + b += 1 // padding -// SequenceId returns the sequence id attached to the BadColormap error. -// This is mostly used internally. -func (err ColormapError) SequenceId() uint16 { - return err.Sequence -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadColormap error. If no bad value exists, 0 is returned. -func (err ColormapError) BadId() uint32 { - return err.BadValue -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// Error returns a rudimentary string representation of the BadColormap error. -func (err ColormapError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadColormap {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.PixelsLen = xgb.Get16(buf[b:]) + b += 2 -func init() { - xgb.NewErrorFuncs[12] = ColormapErrorNew -} + b += 2 // padding -// BadGContext is the error number for a BadGContext. -const BadGContext = 13 + v.RedMask = xgb.Get32(buf[b:]) + b += 4 -type GContextError ValueError + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) -// GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. -func GContextErrorNew(buf []byte) xgb.Error { - v := GContextError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "GContext" return v } -// SequenceId returns the sequence id attached to the BadGContext error. -// This is mostly used internally. -func (err GContextError) SequenceId() uint16 { - return err.Sequence -} +// Write request to wire for AllocColorPlanes +// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. +func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) -// BadId returns the 'BadValue' number if one exists for the BadGContext error. If no bad value exists, 0 is returned. -func (err GContextError) BadId() uint32 { - return err.BadValue -} + buf[b] = 87 // request opcode + b += 1 -// Error returns a rudimentary string representation of the BadGContext error. -func (err GContextError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -func init() { - xgb.NewErrorFuncs[13] = GContextErrorNew -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadIDChoice is the error number for a BadIDChoice. -const BadIDChoice = 14 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -type IDChoiceError ValueError + xgb.Put16(buf[b:], Colors) + b += 2 -// IDChoiceErrorNew constructs a IDChoiceError value that implements xgb.Error from a byte slice. -func IDChoiceErrorNew(buf []byte) xgb.Error { - v := IDChoiceError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "IDChoice" - return v + xgb.Put16(buf[b:], Reds) + b += 2 + + xgb.Put16(buf[b:], Greens) + b += 2 + + xgb.Put16(buf[b:], Blues) + b += 2 + + return buf } -// SequenceId returns the sequence id attached to the BadIDChoice error. -// This is mostly used internally. -func (err IDChoiceError) SequenceId() uint16 { - return err.Sequence +// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. +type AllocNamedColorCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadIDChoice error. If no bad value exists, 0 is returned. -func (err IDChoiceError) BadId() uint32 { - return err.BadValue +// AllocNamedColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocNamedColorCookie.Reply() +func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} } -// Error returns a rudimentary string representation of the BadIDChoice error. -func (err IDChoiceError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllocNamedColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} } -func init() { - xgb.NewErrorFuncs[14] = IDChoiceErrorNew +// AllocNamedColorReply represents the data returned from a AllocNamedColor request. +type AllocNamedColorReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Pixel uint32 + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 } -// BadName is the error number for a BadName. -const BadName = 15 +// Reply blocks and returns the reply data for a AllocNamedColor request. +func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocNamedColorReply(buf), nil +} -type NameError RequestError +// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. +func allocNamedColorReply(buf []byte) *AllocNamedColorReply { + v := new(AllocNamedColorReply) + b := 1 // skip reply determinant -// NameErrorNew constructs a NameError value that implements xgb.Error from a byte slice. -func NameErrorNew(buf []byte) xgb.Error { - v := NameError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Name" - return v -} + b += 1 // padding -// SequenceId returns the sequence id attached to the BadName error. -// This is mostly used internally. -func (err NameError) SequenceId() uint16 { - return err.Sequence -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadName error. If no bad value exists, 0 is returned. -func (err NameError) BadId() uint32 { - return err.BadValue -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// Error returns a rudimentary string representation of the BadName error. -func (err NameError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.Pixel = xgb.Get32(buf[b:]) + b += 4 -func init() { - xgb.NewErrorFuncs[15] = NameErrorNew -} + v.ExactRed = xgb.Get16(buf[b:]) + b += 2 -// BadLength is the error number for a BadLength. -const BadLength = 16 + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 -type LengthError RequestError + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 + + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 + + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 + + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 -// LengthErrorNew constructs a LengthError value that implements xgb.Error from a byte slice. -func LengthErrorNew(buf []byte) xgb.Error { - v := LengthError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Length" return v } -// SequenceId returns the sequence id attached to the BadLength error. -// This is mostly used internally. -func (err LengthError) SequenceId() uint16 { - return err.Sequence -} +// Write request to wire for AllocNamedColor +// allocNamedColorRequest writes a AllocNamedColor request to a byte slice. +func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) -// BadId returns the 'BadValue' number if one exists for the BadLength error. If no bad value exists, 0 is returned. -func (err LengthError) BadId() uint32 { - return err.BadValue -} + buf[b] = 85 // request opcode + b += 1 -// Error returns a rudimentary string representation of the BadLength error. -func (err LengthError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + b += 1 // padding -func init() { - xgb.NewErrorFuncs[16] = LengthErrorNew -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadImplementation is the error number for a BadImplementation. -const BadImplementation = 17 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -type ImplementationError RequestError + xgb.Put16(buf[b:], NameLen) + b += 2 -// ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. -func ImplementationErrorNew(buf []byte) xgb.Error { - v := ImplementationError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Implementation" - return v + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf } -// SequenceId returns the sequence id attached to the BadImplementation error. -// This is mostly used internally. -func (err ImplementationError) SequenceId() uint16 { - return err.Sequence +// AllowEventsCookie is a cookie used only for AllowEvents requests. +type AllowEventsCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadImplementation error. If no bad value exists, 0 is returned. -func (err ImplementationError) BadId() uint32 { - return err.BadValue +// AllowEvents sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} } -// Error returns a rudimentary string representation of the BadImplementation error. -func (err ImplementationError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllowEventsChecked sends a checked request. +// If an error occurs, it can be retrieved using AllowEventsCookie.Check() +func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} } -func init() { - xgb.NewErrorFuncs[17] = ImplementationErrorNew +// 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 AllowEventsCookie) Check() error { + return cook.Cookie.Check() } -// CreateWindowCookie is a cookie used only for CreateWindow requests. -type CreateWindowCookie struct { +// Write request to wire for AllowEvents +// allowEventsRequest writes a AllowEvents request to a byte slice. +func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 35 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// BellCookie is a cookie used only for Bell requests. +type BellCookie struct { *xgb.Cookie } -// CreateWindow sends an unchecked request. +// Bell sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateWindow(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { +func Bell(c *xgb.Conn, Percent int8) BellCookie { cookie := c.NewCookie(false, false) - c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{cookie} } -// CreateWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateWindowCookie.Check() -func CreateWindowChecked(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { +// BellChecked sends a checked request. +// If an error occurs, it can be retrieved using BellCookie.Check() +func BellChecked(c *xgb.Conn, Percent int8) BellCookie { cookie := c.NewCookie(true, false) - c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{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 CreateWindowCookie) Check() error { +func (cook BellCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateWindow -// createWindowRequest writes a CreateWindow request to a byte slice. -func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for Bell +// bellRequest writes a Bell request to a byte slice. +func bellRequest(c *xgb.Conn, Percent int8) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 1 // request opcode + buf[b] = 104 // request opcode b += 1 - buf[b] = Depth + buf[b] = byte(Percent) b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Wid)) - b += 4 + return buf +} - xgb.Put32(buf[b:], uint32(Parent)) - b += 4 +// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. +type ChangeActivePointerGrabCookie struct { + *xgb.Cookie +} - xgb.Put16(buf[b:], uint16(X)) - b += 2 +// ChangeActivePointerGrab sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} +} - xgb.Put16(buf[b:], uint16(Y)) - b += 2 +// ChangeActivePointerGrabChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeActivePointerGrabCookie.Check() +func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} +} - xgb.Put16(buf[b:], Width) - b += 2 +// 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 ChangeActivePointerGrabCookie) Check() error { + return cook.Cookie.Check() +} - xgb.Put16(buf[b:], Height) - b += 2 +// Write request to wire for ChangeActivePointerGrab +// changeActivePointerGrabRequest writes a ChangeActivePointerGrab request to a byte slice. +func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) - xgb.Put16(buf[b:], BorderWidth) - b += 2 + buf[b] = 30 // request opcode + b += 1 - xgb.Put16(buf[b:], Class) + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Visual)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Time)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + + xgb.Put16(buf[b:], EventMask) + b += 2 + + b += 2 // padding return buf } -// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. -type ChangeWindowAttributesCookie struct { +// ChangeGCCookie is a cookie used only for ChangeGC requests. +type ChangeGCCookie struct { *xgb.Cookie } -// ChangeWindowAttributes sends an unchecked request. +// ChangeGC sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { +func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{cookie} } -// ChangeWindowAttributesChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeWindowAttributesCookie.Check() -func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { +// ChangeGCChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeGCCookie.Check() +func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{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 ChangeWindowAttributesCookie) Check() error { +func (cook ChangeGCCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeWindowAttributes -// changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice. -func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { +// Write request to wire for ChangeGC +// changeGCRequest writes a ChangeGC request to a byte slice. +func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 2 // request opcode + buf[b] = 56 // request opcode b += 1 b += 1 // padding @@ -6527,7 +7056,7 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 xgb.Put32(buf[b:], ValueMask) @@ -6541,190 +7070,211 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, return buf } -// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. -type GetWindowAttributesCookie struct { +// ChangeHostsCookie is a cookie used only for ChangeHosts requests. +type ChangeHostsCookie struct { *xgb.Cookie } -// GetWindowAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetWindowAttributesCookie.Reply() -func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getWindowAttributesRequest(c, Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -// GetWindowAttributesUnchecked sends an unchecked request. +// ChangeHosts sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getWindowAttributesRequest(c, Window), cookie) - return GetWindowAttributesCookie{cookie} +func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} } -// GetWindowAttributesReply represents the data returned from a GetWindowAttributes request. -type GetWindowAttributesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - BackingStore byte - Visual Visualid - Class uint16 - BitGravity byte - WinGravity byte - BackingPlanes uint32 - BackingPixel uint32 - SaveUnder bool - MapIsInstalled bool - MapState byte - OverrideRedirect bool - Colormap Colormap - AllEventMasks uint32 - YourEventMask uint32 - DoNotPropagateMask uint16 - // padding: 2 bytes +// ChangeHostsChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeHostsCookie.Check() +func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} } -// Reply blocks and returns the reply data for a GetWindowAttributes request. -func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getWindowAttributesReply(buf), nil +// 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 ChangeHostsCookie) Check() error { + return cook.Cookie.Check() } -// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. -func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { - v := new(GetWindowAttributesReply) - b := 1 // skip reply determinant +// Write request to wire for ChangeHosts +// changeHostsRequest writes a ChangeHosts request to a byte slice. +func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) + b := 0 + buf := make([]byte, size) - v.BackingStore = buf[b] + buf[b] = 109 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + buf[b] = Family + b += 1 - v.Visual = Visualid(xgb.Get32(buf[b:])) - b += 4 + b += 1 // padding - v.Class = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], AddressLen) b += 2 - v.BitGravity = buf[b] - b += 1 + copy(buf[b:], Address[:AddressLen]) + b += xgb.Pad(int(AddressLen)) - v.WinGravity = buf[b] - b += 1 + return buf +} - v.BackingPlanes = xgb.Get32(buf[b:]) - b += 4 +// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. +type ChangeKeyboardControlCookie struct { + *xgb.Cookie +} - v.BackingPixel = xgb.Get32(buf[b:]) - b += 4 +// ChangeKeyboardControl sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} - if buf[b] == 1 { - v.SaveUnder = true - } else { - v.SaveUnder = false - } - b += 1 +// ChangeKeyboardControlChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeKeyboardControlCookie.Check() +func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} - if buf[b] == 1 { - v.MapIsInstalled = true - } else { - v.MapIsInstalled = false - } - b += 1 +// 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 ChangeKeyboardControlCookie) Check() error { + return cook.Cookie.Check() +} - v.MapState = buf[b] - b += 1 +// Write request to wire for ChangeKeyboardControl +// changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice. +func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } + buf[b] = 102 // request opcode b += 1 - v.Colormap = Colormap(xgb.Get32(buf[b:])) - b += 4 + b += 1 // padding - v.AllEventMasks = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - v.YourEventMask = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], ValueMask) b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) - v.DoNotPropagateMask = xgb.Get16(buf[b:]) - b += 2 + return buf +} - b += 2 // padding +// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. +type ChangeKeyboardMappingCookie struct { + *xgb.Cookie +} - return v +// ChangeKeyboardMapping sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} } -// Write request to wire for GetWindowAttributes -// getWindowAttributesRequest writes a GetWindowAttributes request to a byte slice. -func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// ChangeKeyboardMappingChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() +func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{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 ChangeKeyboardMappingCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeKeyboardMapping +// changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice. +func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { + size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 3 // request opcode + buf[b] = 100 // request opcode b += 1 - b += 1 // padding + buf[b] = KeycodeCount + 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 + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = KeysymsPerKeycode + b += 1 + + b += 2 // padding + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) return buf } -// DestroyWindowCookie is a cookie used only for DestroyWindow requests. -type DestroyWindowCookie struct { +// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. +type ChangePointerControlCookie struct { *xgb.Cookie } -// DestroyWindow sends an unchecked request. +// ChangePointerControl sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { +func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { cookie := c.NewCookie(false, false) - c.NewRequest(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} } -// DestroyWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyWindowCookie.Check() -func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { +// ChangePointerControlChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePointerControlCookie.Check() +func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { cookie := c.NewCookie(true, false) - c.NewRequest(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{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 DestroyWindowCookie) Check() error { +func (cook ChangePointerControlCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyWindow -// destroyWindowRequest writes a DestroyWindow request to a byte slice. -func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ChangePointerControl +// changePointerControlRequest writes a ChangePointerControl request to a byte slice. +func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 4 // request opcode + buf[b] = 105 // request opcode b += 1 b += 1 // padding @@ -6732,50 +7282,71 @@ func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { 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.Put16(buf[b:], uint16(AccelerationNumerator)) + b += 2 + + xgb.Put16(buf[b:], uint16(AccelerationDenominator)) + b += 2 + + xgb.Put16(buf[b:], uint16(Threshold)) + b += 2 + + if DoAcceleration { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if DoThreshold { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 return buf } -// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. -type DestroySubwindowsCookie struct { +// ChangePropertyCookie is a cookie used only for ChangeProperty requests. +type ChangePropertyCookie struct { *xgb.Cookie } -// DestroySubwindows sends an unchecked request. +// ChangeProperty sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { +func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { cookie := c.NewCookie(false, false) - c.NewRequest(destroySubwindowsRequest(c, Window), cookie) - return DestroySubwindowsCookie{cookie} + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} } -// DestroySubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroySubwindowsCookie.Check() -func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { +// ChangePropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePropertyCookie.Check() +func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { cookie := c.NewCookie(true, false) - c.NewRequest(destroySubwindowsRequest(c, Window), cookie) - return DestroySubwindowsCookie{cookie} + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{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 DestroySubwindowsCookie) Check() error { +func (cook ChangePropertyCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroySubwindows -// destroySubwindowsRequest writes a DestroySubwindows request to a byte slice. -func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ChangeProperty +// changePropertyRequest writes a ChangeProperty request to a byte slice. +func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 5 // request opcode + buf[b] = 18 // request opcode b += 1 - b += 1 // padding + buf[b] = Mode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -6783,6 +7354,23 @@ func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], DataLen) + b += 4 + + copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) + b += xgb.Pad(int(((int(DataLen) * int(Format)) / 8))) + return buf } @@ -6835,41 +7423,41 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { return buf } -// ReparentWindowCookie is a cookie used only for ReparentWindow requests. -type ReparentWindowCookie struct { +// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. +type ChangeWindowAttributesCookie struct { *xgb.Cookie } -// ReparentWindow sends an unchecked request. +// ChangeWindowAttributes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { +func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} } -// ReparentWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using ReparentWindowCookie.Check() -func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { +// ChangeWindowAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeWindowAttributesCookie.Check() +func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { cookie := c.NewCookie(true, false) - c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{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 ReparentWindowCookie) Check() error { +func (cook ChangeWindowAttributesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ReparentWindow -// reparentWindowRequest writes a ReparentWindow request to a byte slice. -func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { - size := 16 +// Write request to wire for ChangeWindowAttributes +// changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice. +func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 7 // request opcode + buf[b] = 2 // request opcode b += 1 b += 1 // padding @@ -6880,56 +7468,56 @@ func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Parent)) + xgb.Put32(buf[b:], ValueMask) b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// MapWindowCookie is a cookie used only for MapWindow requests. -type MapWindowCookie struct { +// CirculateWindowCookie is a cookie used only for CirculateWindow requests. +type CirculateWindowCookie struct { *xgb.Cookie } -// MapWindow sends an unchecked request. +// CirculateWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { +func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{cookie} + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} } -// MapWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using MapWindowCookie.Check() -func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { +// CirculateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CirculateWindowCookie.Check() +func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { cookie := c.NewCookie(true, false) - c.NewRequest(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{cookie} + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{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 MapWindowCookie) Check() error { +func (cook CirculateWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for MapWindow -// mapWindowRequest writes a MapWindow request to a byte slice. -func mapWindowRequest(c *xgb.Conn, Window Window) []byte { +// Write request to wire for CirculateWindow +// circulateWindowRequest writes a CirculateWindow request to a byte slice. +func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 8 // request opcode + buf[b] = 13 // request opcode b += 1 - b += 1 // padding + buf[b] = Direction + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -6940,44 +7528,49 @@ func mapWindowRequest(c *xgb.Conn, Window Window) []byte { return buf } -// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. -type MapSubwindowsCookie struct { +// ClearAreaCookie is a cookie used only for ClearArea requests. +type ClearAreaCookie struct { *xgb.Cookie } -// MapSubwindows sends an unchecked request. +// ClearArea sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { +func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { cookie := c.NewCookie(false, false) - c.NewRequest(mapSubwindowsRequest(c, Window), cookie) - return MapSubwindowsCookie{cookie} + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} } -// MapSubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using MapSubwindowsCookie.Check() -func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { +// ClearAreaChecked sends a checked request. +// If an error occurs, it can be retrieved using ClearAreaCookie.Check() +func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { cookie := c.NewCookie(true, false) - c.NewRequest(mapSubwindowsRequest(c, Window), cookie) - return MapSubwindowsCookie{cookie} + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{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 MapSubwindowsCookie) Check() error { +func (cook ClearAreaCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for MapSubwindows -// mapSubwindowsRequest writes a MapSubwindows request to a byte slice. -func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ClearArea +// clearAreaRequest writes a ClearArea request to a byte slice. +func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 9 // request opcode + buf[b] = 61 // request opcode b += 1 - b += 1 // padding + if Exposures { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -6985,92 +7578,56 @@ func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 - return buf -} - -// UnmapWindowCookie is a cookie used only for UnmapWindow requests. -type UnmapWindowCookie struct { - *xgb.Cookie -} - -// UnmapWindow sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{cookie} -} - -// UnmapWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using UnmapWindowCookie.Check() -func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{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 UnmapWindowCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for UnmapWindow -// unmapWindowRequest writes a UnmapWindow request to a byte slice. -func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 10 // request opcode - b += 1 + xgb.Put16(buf[b:], uint16(X)) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], uint16(Y)) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Width) b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 + xgb.Put16(buf[b:], Height) + b += 2 return buf } -// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. -type UnmapSubwindowsCookie struct { +// CloseFontCookie is a cookie used only for CloseFont requests. +type CloseFontCookie struct { *xgb.Cookie } -// UnmapSubwindows sends an unchecked request. +// CloseFont sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { +func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { cookie := c.NewCookie(false, false) - c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{cookie} + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{cookie} } -// UnmapSubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using UnmapSubwindowsCookie.Check() -func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { +// CloseFontChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseFontCookie.Check() +func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { cookie := c.NewCookie(true, false) - c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{cookie} + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{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 UnmapSubwindowsCookie) Check() error { +func (cook CloseFontCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnmapSubwindows -// unmapSubwindowsRequest writes a UnmapSubwindows request to a byte slice. -func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { +// Write request to wire for CloseFont +// closeFontRequest writes a CloseFont request to a byte slice. +func closeFontRequest(c *xgb.Conn, Font Font) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 11 // request opcode + buf[b] = 46 // request opcode b += 1 b += 1 // padding @@ -7078,7 +7635,7 @@ func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Font)) b += 4 return buf @@ -7143,147 +7700,173 @@ func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueL return buf } -// CirculateWindowCookie is a cookie used only for CirculateWindow requests. -type CirculateWindowCookie struct { +// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. +type ConvertSelectionCookie struct { *xgb.Cookie } -// CirculateWindow sends an unchecked request. +// ConvertSelection sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { +func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { cookie := c.NewCookie(false, false) - c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) - return CirculateWindowCookie{cookie} + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{cookie} } -// CirculateWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using CirculateWindowCookie.Check() -func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { +// ConvertSelectionChecked sends a checked request. +// If an error occurs, it can be retrieved using ConvertSelectionCookie.Check() +func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { cookie := c.NewCookie(true, false) - c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) - return CirculateWindowCookie{cookie} + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{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 CirculateWindowCookie) Check() error { +func (cook ConvertSelectionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CirculateWindow -// circulateWindowRequest writes a CirculateWindow request to a byte slice. -func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { - size := 8 +// Write request to wire for ConvertSelection +// convertSelectionRequest writes a ConvertSelection request to a byte slice. +func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 13 // request opcode + buf[b] = 24 // request opcode b += 1 - buf[b] = Direction - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) b += 4 return buf } -// GetGeometryCookie is a cookie used only for GetGeometry requests. -type GetGeometryCookie struct { +// CopyAreaCookie is a cookie used only for CopyArea requests. +type CopyAreaCookie struct { *xgb.Cookie } -// GetGeometry sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetGeometryCookie.Reply() -func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getGeometryRequest(c, Drawable), cookie) - return GetGeometryCookie{cookie} -} - -// GetGeometryUnchecked sends an unchecked request. +// CopyArea sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getGeometryRequest(c, Drawable), cookie) - return GetGeometryCookie{cookie} +func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} } -// GetGeometryReply represents the data returned from a GetGeometry request. -type GetGeometryReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Depth byte - Root Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - // padding: 2 bytes +// CopyAreaChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyAreaCookie.Check() +func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} } -// Reply blocks and returns the reply data for a GetGeometry request. -func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getGeometryReply(buf), nil +// 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 CopyAreaCookie) Check() error { + return cook.Cookie.Check() } -// getGeometryReply reads a byte slice into a GetGeometryReply value. -func getGeometryReply(buf []byte) *GetGeometryReply { - v := new(GetGeometryReply) - b := 1 // skip reply determinant +// Write request to wire for CopyArea +// copyAreaRequest writes a CopyArea request to a byte slice. +func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 28 + b := 0 + buf := make([]byte, size) - v.Depth = buf[b] + buf[b] = 62 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(SrcDrawable)) b += 4 - v.Root = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(DstDrawable)) b += 4 - v.X = int16(xgb.Get16(buf[b:])) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 - v.Y = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - v.Width = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DstX)) b += 2 - v.Height = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DstY)) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Width) b += 2 - b += 2 // padding + xgb.Put16(buf[b:], Height) + b += 2 - return v + return buf } -// Write request to wire for GetGeometry -// getGeometryRequest writes a GetGeometry request to a byte slice. -func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { - size := 8 +// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. +type CopyColormapAndFreeCookie struct { + *xgb.Cookie +} + +// CopyColormapAndFree sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +// CopyColormapAndFreeChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() +func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{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 CopyColormapAndFreeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyColormapAndFree +// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. +func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 14 // request opcode + buf[b] = 80 // request opcode b += 1 b += 1 // padding @@ -7291,357 +7874,549 @@ func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Mid)) + b += 4 + + xgb.Put32(buf[b:], uint32(SrcCmap)) b += 4 return buf } -// QueryTreeCookie is a cookie used only for QueryTree requests. -type QueryTreeCookie struct { +// CopyGCCookie is a cookie used only for CopyGC requests. +type CopyGCCookie struct { *xgb.Cookie } -// QueryTree sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryTreeCookie.Reply() -func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(queryTreeRequest(c, Window), cookie) - return QueryTreeCookie{cookie} +// CopyGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} } -// QueryTreeUnchecked sends an unchecked request. +// CopyGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyGCCookie.Check() +func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{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 CopyGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyGC +// copyGCRequest writes a CopyGC request to a byte slice. +func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 57 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcGc)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstGc)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + + return buf +} + +// CopyPlaneCookie is a cookie used only for CopyPlane requests. +type CopyPlaneCookie struct { + *xgb.Cookie +} + +// CopyPlane sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryTreeRequest(c, Window), cookie) - return QueryTreeCookie{cookie} +func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} } -// QueryTreeReply represents the data returned from a QueryTree request. -type QueryTreeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Root Window - Parent Window - ChildrenLen uint16 - // padding: 14 bytes - Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) +// CopyPlaneChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyPlaneCookie.Check() +func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} } -// Reply blocks and returns the reply data for a QueryTree request. -func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryTreeReply(buf), nil +// 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 CopyPlaneCookie) Check() error { + return cook.Cookie.Check() } -// queryTreeReply reads a byte slice into a QueryTreeReply value. -func queryTreeReply(buf []byte) *QueryTreeReply { - v := new(QueryTreeReply) - b := 1 // skip reply determinant +// Write request to wire for CopyPlane +// copyPlaneRequest writes a CopyPlane request to a byte slice. +func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 63 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(SrcDrawable)) b += 4 - v.Root = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(DstDrawable)) b += 4 - v.Parent = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - v.ChildrenLen = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 - b += 14 // padding + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 - v.Children = make([]Window, v.ChildrenLen) - for i := 0; i < int(v.ChildrenLen); i++ { - v.Children[i] = Window(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 - return v + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], BitPlane) + b += 4 + + return buf } -// Write request to wire for QueryTree -// queryTreeRequest writes a QueryTree request to a byte slice. -func queryTreeRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// CreateColormapCookie is a cookie used only for CreateColormap requests. +type CreateColormapCookie struct { + *xgb.Cookie +} + +// CreateColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} +} + +// CreateColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateColormapCookie.Check() +func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{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 CreateColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateColormap +// createColormapRequest writes a CreateColormap request to a byte slice. +func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 15 // request opcode + buf[b] = 78 // request opcode b += 1 - b += 1 // padding + buf[b] = Alloc + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Mid)) + b += 4 + xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + return buf } -// InternAtomCookie is a cookie used only for InternAtom requests. -type InternAtomCookie struct { +// CreateCursorCookie is a cookie used only for CreateCursor requests. +type CreateCursorCookie struct { *xgb.Cookie } -// InternAtom sends a checked request. -// If an error occurs, it will be returned with the reply by calling InternAtomCookie.Reply() -func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} -} - -// InternAtomUnchecked sends an unchecked request. +// CreateCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} +func CreateCursor(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} } -// InternAtomReply represents the data returned from a InternAtom request. -type InternAtomReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Atom Atom +// CreateCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCursorCookie.Check() +func CreateCursorChecked(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} } -// Reply blocks and returns the reply data for a InternAtom request. -func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return internAtomReply(buf), nil +// 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 CreateCursorCookie) Check() error { + return cook.Cookie.Check() } -// internAtomReply reads a byte slice into a InternAtomReply value. -func internAtomReply(buf []byte) *InternAtomReply { - v := new(InternAtomReply) - b := 1 // skip reply determinant +// Write request to wire for CreateCursor +// createCursorRequest writes a CreateCursor request to a byte slice. +func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 93 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Cid)) b += 4 - v.Atom = Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - return v + xgb.Put32(buf[b:], uint32(Mask)) + b += 4 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + + return buf } -// Write request to wire for InternAtom -// internAtomRequest writes a InternAtom request to a byte slice. -func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// CreateGCCookie is a cookie used only for CreateGC requests. +type CreateGCCookie struct { + *xgb.Cookie +} + +// CreateGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +// CreateGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGCCookie.Check() +func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{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 CreateGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGC +// createGCRequest writes a CreateGC request to a byte slice. +func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 16 // request opcode + buf[b] = 55 // request opcode b += 1 - if OnlyIfExists { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], NameLen) - b += 2 + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 - b += 2 // padding + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// GetAtomNameCookie is a cookie used only for GetAtomName requests. -type GetAtomNameCookie struct { +// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. +type CreateGlyphCursorCookie struct { *xgb.Cookie } -// GetAtomName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetAtomNameCookie.Reply() -func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getAtomNameRequest(c, Atom), cookie) - return GetAtomNameCookie{cookie} -} - -// GetAtomNameUnchecked sends an unchecked request. +// CreateGlyphCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getAtomNameRequest(c, Atom), cookie) - return GetAtomNameCookie{cookie} +func CreateGlyphCursor(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} } -// GetAtomNameReply represents the data returned from a GetAtomName request. -type GetAtomNameReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NameLen uint16 - // padding: 22 bytes - Name string // size: xgb.Pad((int(NameLen) * 1)) +// CreateGlyphCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGlyphCursorCookie.Check() +func CreateGlyphCursorChecked(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} } -// Reply blocks and returns the reply data for a GetAtomName request. -func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getAtomNameReply(buf), nil +// 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 CreateGlyphCursorCookie) Check() error { + return cook.Cookie.Check() } -// getAtomNameReply reads a byte slice into a GetAtomNameReply value. -func getAtomNameReply(buf []byte) *GetAtomNameReply { - v := new(GetAtomNameReply) - b := 1 // skip reply determinant +// Write request to wire for CreateGlyphCursor +// createGlyphCursorRequest writes a CreateGlyphCursor request to a byte slice. +func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 94 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Cid)) b += 4 - v.NameLen = xgb.Get16(buf[b:]) + xgb.Put32(buf[b:], uint32(SourceFont)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFont)) + b += 4 + + xgb.Put16(buf[b:], SourceChar) b += 2 - b += 22 // padding + xgb.Put16(buf[b:], MaskChar) + b += 2 - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } + xgb.Put16(buf[b:], ForeRed) + b += 2 - return v + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + return buf } -// Write request to wire for GetAtomName -// getAtomNameRequest writes a GetAtomName request to a byte slice. -func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { - size := 8 +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { + *xgb.Cookie +} + +// CreatePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() +func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{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 CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. +func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 17 // request opcode + buf[b] = 53 // request opcode b += 1 - b += 1 // padding + buf[b] = Depth + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Atom)) + xgb.Put32(buf[b:], uint32(Pid)) b += 4 + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + return buf } -// ChangePropertyCookie is a cookie used only for ChangeProperty requests. -type ChangePropertyCookie struct { +// CreateWindowCookie is a cookie used only for CreateWindow requests. +type CreateWindowCookie struct { *xgb.Cookie } -// ChangeProperty sends an unchecked request. +// CreateWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { +func CreateWindow(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{cookie} } -// ChangePropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangePropertyCookie.Check() -func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { +// CreateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateWindowCookie.Check() +func CreateWindowChecked(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{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 ChangePropertyCookie) Check() error { +func (cook CreateWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeProperty -// changePropertyRequest writes a ChangeProperty request to a byte slice. -func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { - size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) +// Write request to wire for CreateWindow +// createWindowRequest writes a CreateWindow request to a byte slice. +func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 18 // request opcode + buf[b] = 1 // request opcode b += 1 - buf[b] = Mode + buf[b] = Depth b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Wid)) b += 4 - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Parent)) b += 4 - xgb.Put32(buf[b:], uint32(Type)) - b += 4 + xgb.Put16(buf[b:], uint16(X)) + b += 2 - buf[b] = Format - b += 1 + xgb.Put16(buf[b:], uint16(Y)) + b += 2 - b += 3 // padding + xgb.Put16(buf[b:], Width) + b += 2 - xgb.Put32(buf[b:], DataLen) + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], BorderWidth) + b += 2 + + xgb.Put16(buf[b:], Class) + b += 2 + + xgb.Put32(buf[b:], uint32(Visual)) b += 4 - copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) - b += xgb.Pad(int(((int(DataLen) * int(Format)) / 8))) + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) return buf } @@ -7697,99 +8472,92 @@ func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { return buf } -// GetPropertyCookie is a cookie used only for GetProperty requests. -type GetPropertyCookie struct { +// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. +type DestroySubwindowsCookie struct { *xgb.Cookie } -// GetProperty sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyCookie.Reply() -func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} -} - -// GetPropertyUnchecked sends an unchecked request. +// DestroySubwindows sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} +func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} } -// GetPropertyReply represents the data returned from a GetProperty request. -type GetPropertyReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Format byte - Type Atom - BytesAfter uint32 - ValueLen uint32 - // padding: 12 bytes - Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) +// DestroySubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroySubwindowsCookie.Check() +func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} } -// Reply blocks and returns the reply data for a GetProperty request. -func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPropertyReply(buf), nil +// 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 DestroySubwindowsCookie) Check() error { + return cook.Cookie.Check() } -// getPropertyReply reads a byte slice into a GetPropertyReply value. -func getPropertyReply(buf []byte) *GetPropertyReply { - v := new(GetPropertyReply) - b := 1 // skip reply determinant +// Write request to wire for DestroySubwindows +// destroySubwindowsRequest writes a DestroySubwindows request to a byte slice. +func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) - v.Format = buf[b] + buf[b] = 5 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + b += 1 // padding - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - v.Type = Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - v.BytesAfter = xgb.Get32(buf[b:]) - b += 4 + return buf +} - v.ValueLen = xgb.Get32(buf[b:]) - b += 4 +// DestroyWindowCookie is a cookie used only for DestroyWindow requests. +type DestroyWindowCookie struct { + *xgb.Cookie +} - b += 12 // padding +// DestroyWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} +} - v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) - copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) - b += xgb.Pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) +// DestroyWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyWindowCookie.Check() +func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} +} - 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 DestroyWindowCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetProperty -// getPropertyRequest writes a GetProperty request to a byte slice. -func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { - size := 24 +// Write request to wire for DestroyWindow +// destroyWindowRequest writes a DestroyWindow request to a byte slice. +func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 20 // request opcode + buf[b] = 4 // request opcode b += 1 - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -7797,148 +8565,151 @@ func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - xgb.Put32(buf[b:], uint32(Type)) - b += 4 - - xgb.Put32(buf[b:], LongOffset) - b += 4 - - xgb.Put32(buf[b:], LongLength) - b += 4 - return buf } -// ListPropertiesCookie is a cookie used only for ListProperties requests. -type ListPropertiesCookie struct { +// FillPolyCookie is a cookie used only for FillPoly requests. +type FillPolyCookie struct { *xgb.Cookie } -// ListProperties sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() -func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} -} - -// ListPropertiesUnchecked sends an unchecked request. +// FillPoly sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} +func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} } -// ListPropertiesReply represents the data returned from a ListProperties request. -type ListPropertiesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - AtomsLen uint16 - // padding: 22 bytes - Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) +// FillPolyChecked sends a checked request. +// If an error occurs, it can be retrieved using FillPolyCookie.Check() +func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} } -// Reply blocks and returns the reply data for a ListProperties request. -func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listPropertiesReply(buf), nil +// 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 FillPolyCookie) Check() error { + return cook.Cookie.Check() } -// listPropertiesReply reads a byte slice into a ListPropertiesReply value. -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) - b := 1 // skip reply determinant +// Write request to wire for FillPoly +// fillPolyRequest writes a FillPoly request to a byte slice. +func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 69 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - v.AtomsLen = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - b += 22 // padding + buf[b] = Shape + b += 1 - v.Atoms = make([]Atom, v.AtomsLen) - for i := 0; i < int(v.AtomsLen); i++ { - v.Atoms[i] = Atom(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + buf[b] = CoordinateMode + b += 1 - return v + b += 2 // padding + + b += PointListBytes(buf[b:], Points) + + return buf } -// Write request to wire for ListProperties -// listPropertiesRequest writes a ListProperties request to a byte slice. -func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. +type ForceScreenSaverCookie struct { + *xgb.Cookie +} + +// ForceScreenSaver sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} +} + +// ForceScreenSaverChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check() +func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{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 ForceScreenSaverCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ForceScreenSaver +// forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice. +func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 21 // request opcode + buf[b] = 115 // request opcode b += 1 - b += 1 // padding + buf[b] = Mode + 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 } -// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. -type SetSelectionOwnerCookie struct { +// FreeColormapCookie is a cookie used only for FreeColormap requests. +type FreeColormapCookie struct { *xgb.Cookie } -// SetSelectionOwner sends an unchecked request. +// FreeColormap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { +func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} } -// SetSelectionOwnerChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionOwnerCookie.Check() -func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { +// FreeColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColormapCookie.Check() +func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{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 SetSelectionOwnerCookie) Check() error { +func (cook FreeColormapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetSelectionOwner -// setSelectionOwnerRequest writes a SetSelectionOwner request to a byte slice. -func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { - size := 16 +// Write request to wire for FreeColormap +// freeColormapRequest writes a FreeColormap request to a byte slice. +func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 22 // request opcode + buf[b] = 79 // request opcode b += 1 b += 1 // padding @@ -7946,86 +8717,104 @@ func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Ti xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Owner)) - b += 4 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 return buf } -// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. -type GetSelectionOwnerCookie struct { +// FreeColorsCookie is a cookie used only for FreeColors requests. +type FreeColorsCookie struct { *xgb.Cookie } -// GetSelectionOwner sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() -func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -// GetSelectionOwnerUnchecked sends an unchecked request. +// FreeColors sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) - return GetSelectionOwnerCookie{cookie} +func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} } -// GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. -type GetSelectionOwnerReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Owner Window +// FreeColorsChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColorsCookie.Check() +func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} } -// Reply blocks and returns the reply data for a GetSelectionOwner request. -func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectionOwnerReply(buf), nil +// 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 FreeColorsCookie) Check() error { + return cook.Cookie.Check() } -// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. -func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { - v := new(GetSelectionOwnerReply) - b := 1 // skip reply determinant +// Write request to wire for FreeColors +// freeColorsRequest writes a FreeColors request to a byte slice. +func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 88 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 - v.Owner = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], PlaneMask) b += 4 - return v + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf } -// Write request to wire for GetSelectionOwner -// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. -func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { +// FreeCursorCookie is a cookie used only for FreeCursor requests. +type FreeCursorCookie struct { + *xgb.Cookie +} + +// FreeCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{cookie} +} + +// FreeCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeCursorCookie.Check() +func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{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 FreeCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeCursor +// freeCursorRequest writes a FreeCursor request to a byte slice. +func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 23 // request opcode + buf[b] = 95 // request opcode b += 1 b += 1 // padding @@ -8033,47 +8822,47 @@ func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Selection)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 return buf } -// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. -type ConvertSelectionCookie struct { +// FreeGCCookie is a cookie used only for FreeGC requests. +type FreeGCCookie struct { *xgb.Cookie } -// ConvertSelection sends an unchecked request. +// FreeGC sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { +func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { cookie := c.NewCookie(false, false) - c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} } -// ConvertSelectionChecked sends a checked request. -// If an error occurs, it can be retrieved using ConvertSelectionCookie.Check() -func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { +// FreeGCChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGCCookie.Check() +func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { cookie := c.NewCookie(true, false) - c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{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 ConvertSelectionCookie) Check() error { +func (cook FreeGCCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ConvertSelection -// convertSelectionRequest writes a ConvertSelection request to a byte slice. -func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { - size := 24 +// Write request to wire for FreeGC +// freeGCRequest writes a FreeGC request to a byte slice. +func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 24 // request opcode + buf[b] = 60 // request opcode b += 1 b += 1 // padding @@ -8081,113 +8870,93 @@ func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Targ xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Requestor)) - b += 4 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], uint32(Target)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 return buf } -// SendEventCookie is a cookie used only for SendEvent requests. -type SendEventCookie struct { +// FreePixmapCookie is a cookie used only for FreePixmap requests. +type FreePixmapCookie struct { *xgb.Cookie } -// SendEvent sends an unchecked request. +// FreePixmap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { +func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { cookie := c.NewCookie(false, false) - c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} } -// SendEventChecked sends a checked request. -// If an error occurs, it can be retrieved using SendEventCookie.Check() -func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { +// FreePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreePixmapCookie.Check() +func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { cookie := c.NewCookie(true, false) - c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{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 SendEventCookie) Check() error { +func (cook FreePixmapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SendEvent -// sendEventRequest writes a SendEvent request to a byte slice. -func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { - size := 44 +// Write request to wire for FreePixmap +// freePixmapRequest writes a FreePixmap request to a byte slice. +func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 25 // request opcode + buf[b] = 54 // request opcode b += 1 - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - - xgb.Put32(buf[b:], EventMask) + xgb.Put32(buf[b:], uint32(Pixmap)) b += 4 - copy(buf[b:], Event[:32]) - b += xgb.Pad(int(32)) - return buf } -// GrabPointerCookie is a cookie used only for GrabPointer requests. -type GrabPointerCookie struct { +// GetAtomNameCookie is a cookie used only for GetAtomName requests. +type GetAtomNameCookie struct { *xgb.Cookie } -// GrabPointer sends a checked request. -// If an error occurs, it will be returned with the reply by calling GrabPointerCookie.Reply() -func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { +// GetAtomName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetAtomNameCookie.Reply() +func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { cookie := c.NewCookie(true, true) - c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} } -// GrabPointerUnchecked sends an unchecked request. +// GetAtomNameUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { +func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { cookie := c.NewCookie(false, true) - c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} } -// GrabPointerReply represents the data returned from a GrabPointer request. -type GrabPointerReply struct { +// GetAtomNameReply represents the data returned from a GetAtomName request. +type GetAtomNameReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - Status byte + // padding: 1 bytes + NameLen uint16 + // padding: 22 bytes + Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Reply blocks and returns the reply data for a GrabPointer request. -func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { +// Reply blocks and returns the reply data for a GetAtomName request. +func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8195,16 +8964,15 @@ func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { if buf == nil { return nil, nil } - return grabPointerReply(buf), nil + return getAtomNameReply(buf), nil } -// grabPointerReply reads a byte slice into a GrabPointerReply value. -func grabPointerReply(buf []byte) *GrabPointerReply { - v := new(GrabPointerReply) +// getAtomNameReply reads a byte slice into a GetAtomNameReply value. +func getAtomNameReply(buf []byte) *GetAtomNameReply { + v := new(GetAtomNameReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -8212,317 +8980,368 @@ func grabPointerReply(buf []byte) *GrabPointerReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + return v } -// Write request to wire for GrabPointer -// grabPointerRequest writes a GrabPointer request to a byte slice. -func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { - size := 24 +// Write request to wire for GetAtomName +// getAtomNameRequest writes a GetAtomName request to a byte slice. +func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 26 // request opcode + buf[b] = 17 // request opcode b += 1 - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], EventMask) - b += 2 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - xgb.Put32(buf[b:], uint32(ConfineTo)) - b += 4 - - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Atom)) b += 4 return buf } -// UngrabPointerCookie is a cookie used only for UngrabPointer requests. -type UngrabPointerCookie struct { +// GetFontPathCookie is a cookie used only for GetFontPath requests. +type GetFontPathCookie struct { *xgb.Cookie } -// UngrabPointer sends an unchecked request. +// GetFontPath sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply() +func GetFontPath(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} +} + +// GetFontPathUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabPointerRequest(c, Time), cookie) - return UngrabPointerCookie{cookie} +func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} } -// UngrabPointerChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabPointerCookie.Check() -func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabPointerRequest(c, Time), cookie) - return UngrabPointerCookie{cookie} +// GetFontPathReply represents the data returned from a GetFontPath request. +type GetFontPathReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + PathLen uint16 + // padding: 22 bytes + Path []Str // size: StrListSize(Path) } -// 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 UngrabPointerCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a GetFontPath request. +func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFontPathReply(buf), nil } -// Write request to wire for UngrabPointer -// ungrabPointerRequest writes a UngrabPointer request to a byte slice. -func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { - size := 8 +// getFontPathReply reads a byte slice into a GetFontPathReply value. +func getFontPathReply(buf []byte) *GetFontPathReply { + v := new(GetFontPathReply) + 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.PathLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Path = make([]Str, v.PathLen) + b += StrReadList(buf[b:], v.Path) + + return v +} + +// Write request to wire for GetFontPath +// getFontPathRequest writes a GetFontPath request to a byte slice. +func getFontPathRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 27 // request opcode + buf[b] = 52 // request opcode b += 1 - b += 1 // padding - + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 - return buf } -// GrabButtonCookie is a cookie used only for GrabButton requests. -type GrabButtonCookie struct { +// GetGeometryCookie is a cookie used only for GetGeometry requests. +type GetGeometryCookie struct { *xgb.Cookie } -// GrabButton sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} +// GetGeometry sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGeometryCookie.Reply() +func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{cookie} } -// GrabButtonChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabButtonCookie.Check() -func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} +// GetGeometryUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{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 GrabButtonCookie) Check() error { - return cook.Cookie.Check() +// GetGeometryReply represents the data returned from a GetGeometry request. +type GetGeometryReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Depth byte + Root Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + // padding: 2 bytes } -// Write request to wire for GrabButton -// grabButtonRequest writes a GrabButton request to a byte slice. -func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetGeometry request. +func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGeometryReply(buf), nil +} - buf[b] = 28 // request opcode - b += 1 +// getGeometryReply reads a byte slice into a GetGeometryReply value. +func getGeometryReply(buf []byte) *GetGeometryReply { + v := new(GetGeometryReply) + b := 1 // skip reply determinant - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } + v.Depth = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], EventMask) + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - buf[b] = PointerMode - b += 1 + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - buf[b] = KeyboardMode - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(ConfineTo)) - b += 4 + v.Height = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 - buf[b] = Button + b += 2 // padding + + return v +} + +// Write request to wire for GetGeometry +// getGeometryRequest writes a GetGeometry request to a byte slice. +func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 14 // request opcode b += 1 b += 1 // padding - xgb.Put16(buf[b:], Modifiers) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + return buf } -// UngrabButtonCookie is a cookie used only for UngrabButton requests. -type UngrabButtonCookie struct { +// GetImageCookie is a cookie used only for GetImage requests. +type GetImageCookie struct { *xgb.Cookie } -// UngrabButton sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} +// GetImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetImageCookie.Reply() +func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} } -// UngrabButtonChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabButtonCookie.Check() -func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} +// GetImageUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{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 UngrabButtonCookie) Check() error { - return cook.Cookie.Check() +// GetImageReply represents the data returned from a GetImage request. +type GetImageReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Depth byte + Visual Visualid + // padding: 20 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Write request to wire for UngrabButton -// ungrabButtonRequest writes a UngrabButton request to a byte slice. -func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetImage request. +func (cook GetImageCookie) Reply() (*GetImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getImageReply(buf), nil +} - buf[b] = 29 // request opcode - b += 1 +// getImageReply reads a byte slice into a GetImageReply value. +func getImageReply(buf []byte) *GetImageReply { + v := new(GetImageReply) + b := 1 // skip reply determinant - buf[b] = Button + v.Depth = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - - return buf -} - -// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. -type ChangeActivePointerGrabCookie struct { - *xgb.Cookie -} + v.Visual = Visualid(xgb.Get32(buf[b:])) + b += 4 -// ChangeActivePointerGrab sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} + b += 20 // padding -// ChangeActivePointerGrabChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeActivePointerGrabCookie.Check() -func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) -// 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 ChangeActivePointerGrabCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for ChangeActivePointerGrab -// changeActivePointerGrabRequest writes a ChangeActivePointerGrab request to a byte slice. -func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { - size := 16 +// Write request to wire for GetImage +// getImageRequest writes a GetImage request to a byte slice. +func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { + size := 20 b := 0 buf := make([]byte, size) - buf[b] = 30 // request opcode + buf[b] = 73 // request opcode b += 1 - b += 1 // padding + buf[b] = Format + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 + xgb.Put16(buf[b:], uint16(X)) + b += 2 - xgb.Put16(buf[b:], EventMask) + xgb.Put16(buf[b:], uint16(Y)) b += 2 - b += 2 // padding + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], PlaneMask) + b += 4 return buf } -// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. -type GrabKeyboardCookie struct { +// GetInputFocusCookie is a cookie used only for GetInputFocus requests. +type GetInputFocusCookie struct { *xgb.Cookie } -// GrabKeyboard sends a checked request. -// If an error occurs, it will be returned with the reply by calling GrabKeyboardCookie.Reply() -func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { +// GetInputFocus sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetInputFocusCookie.Reply() +func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { cookie := c.NewCookie(true, true) - c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} } -// GrabKeyboardUnchecked sends an unchecked request. +// GetInputFocusUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { +func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { cookie := c.NewCookie(false, true) - c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} } -// GrabKeyboardReply represents the data returned from a GrabKeyboard request. -type GrabKeyboardReply struct { +// GetInputFocusReply represents the data returned from a GetInputFocus request. +type GetInputFocusReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - Status byte + RevertTo byte + Focus Window } -// Reply blocks and returns the reply data for a GrabKeyboard request. -func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { +// Reply blocks and returns the reply data for a GetInputFocus request. +func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8530,15 +9349,15 @@ func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { if buf == nil { return nil, nil } - return grabKeyboardReply(buf), nil + return getInputFocusReply(buf), nil } -// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. -func grabKeyboardReply(buf []byte) *GrabKeyboardReply { - v := new(GrabKeyboardReply) +// getInputFocusReply reads a byte slice into a GetInputFocusReply value. +func getInputFocusReply(buf []byte) *GetInputFocusReply { + v := new(GetInputFocusReply) b := 1 // skip reply determinant - v.Status = buf[b] + v.RevertTo = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -8547,81 +9366,207 @@ func grabKeyboardReply(buf []byte) *GrabKeyboardReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 + v.Focus = Window(xgb.Get32(buf[b:])) + b += 4 + return v } -// Write request to wire for GrabKeyboard -// grabKeyboardRequest writes a GrabKeyboard request to a byte slice. -func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { - size := 16 +// Write request to wire for GetInputFocus +// getInputFocusRequest writes a GetInputFocus request to a byte slice. +func getInputFocusRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 31 // request opcode + buf[b] = 43 // request opcode b += 1 - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. +type GetKeyboardControlCookie struct { + *xgb.Cookie +} + +// GetKeyboardControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() +func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +// GetKeyboardControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +// GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. +type GetKeyboardControlReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + GlobalAutoRepeat byte + LedMask uint32 + KeyClickPercent byte + BellPercent byte + BellPitch uint16 + BellDuration uint16 + // padding: 2 bytes + AutoRepeats []byte // size: 32 +} + +// Reply blocks and returns the reply data for a GetKeyboardControl request. +func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } + if buf == nil { + return nil, nil + } + return getKeyboardControlReply(buf), nil +} + +// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. +func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { + v := new(GetKeyboardControlReply) + b := 1 // skip reply determinant + + v.GlobalAutoRepeat = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Time)) + v.LedMask = xgb.Get32(buf[b:]) b += 4 - buf[b] = PointerMode + v.KeyClickPercent = buf[b] b += 1 - buf[b] = KeyboardMode + v.BellPercent = buf[b] b += 1 + v.BellPitch = xgb.Get16(buf[b:]) + b += 2 + + v.BellDuration = xgb.Get16(buf[b:]) + b += 2 + b += 2 // padding + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v +} + +// Write request to wire for GetKeyboardControl +// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. +func getKeyboardControlRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 103 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + return buf } -// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. -type UngrabKeyboardCookie struct { +// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. +type GetKeyboardMappingCookie struct { *xgb.Cookie } -// UngrabKeyboard sends an unchecked request. +// GetKeyboardMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetKeyboardMappingCookie.Reply() +func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} +} + +// GetKeyboardMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) - return UngrabKeyboardCookie{cookie} +func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} } -// UngrabKeyboardChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabKeyboardCookie.Check() -func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) - return UngrabKeyboardCookie{cookie} +// GetKeyboardMappingReply represents the data returned from a GetKeyboardMapping request. +type GetKeyboardMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + KeysymsPerKeycode byte + // padding: 24 bytes + Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) } -// 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 UngrabKeyboardCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a GetKeyboardMapping request. +func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardMappingReply(buf), nil } -// Write request to wire for UngrabKeyboard -// ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice. -func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { +// getKeyboardMappingReply reads a byte slice into a GetKeyboardMappingReply value. +func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { + v := new(GetKeyboardMappingReply) + b := 1 // skip reply determinant + + v.KeysymsPerKeycode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keysyms = make([]Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetKeyboardMapping +// getKeyboardMappingRequest writes a GetKeyboardMapping request to a byte slice. +func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 32 // request opcode + buf[b] = 101 // request opcode b += 1 b += 1 // padding @@ -8629,217 +9574,273 @@ func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 return buf } -// GrabKeyCookie is a cookie used only for GrabKey requests. -type GrabKeyCookie struct { +// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. +type GetModifierMappingCookie struct { *xgb.Cookie } -// GrabKey sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} +// GetModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetModifierMappingCookie.Reply() +func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} } -// GrabKeyChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabKeyCookie.Check() -func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} +// GetModifierMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{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 GrabKeyCookie) Check() error { - return cook.Cookie.Check() +// GetModifierMappingReply represents the data returned from a GetModifierMapping request. +type GetModifierMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + KeycodesPerModifier byte + // padding: 24 bytes + Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) } -// Write request to wire for GrabKey -// grabKeyRequest writes a GrabKey request to a byte slice. -func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetModifierMapping request. +func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getModifierMappingReply(buf), nil +} - buf[b] = 33 // request opcode - b += 1 +// getModifierMappingReply reads a byte slice into a GetModifierMappingReply value. +func getModifierMappingReply(buf []byte) *GetModifierMappingReply { + v := new(GetModifierMappingReply) + b := 1 // skip reply determinant - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } + v.KeycodesPerModifier = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Modifiers) - b += 2 + b += 24 // padding - buf[b] = byte(Key) - b += 1 + v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) + for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { + v.Keycodes[i] = Keycode(buf[b]) + b += 1 + } + b = xgb.Pad(b) - buf[b] = PointerMode - b += 1 + return v +} - buf[b] = KeyboardMode +// Write request to wire for GetModifierMapping +// getModifierMappingRequest writes a GetModifierMapping request to a byte slice. +func getModifierMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 119 // request opcode b += 1 - b += 3 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 return buf } -// UngrabKeyCookie is a cookie used only for UngrabKey requests. -type UngrabKeyCookie struct { +// GetMotionEventsCookie is a cookie used only for GetMotionEvents requests. +type GetMotionEventsCookie struct { *xgb.Cookie } -// UngrabKey sends an unchecked request. +// GetMotionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMotionEventsCookie.Reply() +func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} +} + +// GetMotionEventsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} +func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} } -// UngrabKeyChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabKeyCookie.Check() -func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} +// GetMotionEventsReply represents the data returned from a GetMotionEvents request. +type GetMotionEventsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + EventsLen uint32 + // padding: 20 bytes + Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) } -// 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 UngrabKeyCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a GetMotionEvents request. +func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMotionEventsReply(buf), nil } -// Write request to wire for UngrabKey -// ungrabKeyRequest writes a UngrabKey request to a byte slice. -func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { - size := 12 +// getMotionEventsReply reads a byte slice into a GetMotionEventsReply value. +func getMotionEventsReply(buf []byte) *GetMotionEventsReply { + v := new(GetMotionEventsReply) + 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.EventsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Events = make([]Timecoord, v.EventsLen) + b += TimecoordReadList(buf[b:], v.Events) + + return v +} + +// Write request to wire for GetMotionEvents +// getMotionEventsRequest writes a GetMotionEvents request to a byte slice. +func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 34 // request opcode + buf[b] = 39 // request opcode b += 1 - buf[b] = byte(Key) - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Modifiers) - b += 2 + xgb.Put32(buf[b:], uint32(Start)) + b += 4 - b += 2 // padding + xgb.Put32(buf[b:], uint32(Stop)) + b += 4 return buf } -// AllowEventsCookie is a cookie used only for AllowEvents requests. -type AllowEventsCookie struct { +// GetPointerControlCookie is a cookie used only for GetPointerControl requests. +type GetPointerControlCookie struct { *xgb.Cookie } -// AllowEvents sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) - return AllowEventsCookie{cookie} +// GetPointerControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPointerControlCookie.Reply() +func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} } -// AllowEventsChecked sends a checked request. -// If an error occurs, it can be retrieved using AllowEventsCookie.Check() -func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) - return AllowEventsCookie{cookie} +// GetPointerControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{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 AllowEventsCookie) Check() error { - return cook.Cookie.Check() +// GetPointerControlReply represents the data returned from a GetPointerControl request. +type GetPointerControlReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + AccelerationNumerator uint16 + AccelerationDenominator uint16 + Threshold uint16 + // padding: 18 bytes } -// Write request to wire for AllowEvents -// allowEventsRequest writes a AllowEvents request to a byte slice. -func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetPointerControl request. +func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerControlReply(buf), nil +} - buf[b] = 35 // request opcode - b += 1 +// getPointerControlReply reads a byte slice into a GetPointerControlReply value. +func getPointerControlReply(buf []byte) *GetPointerControlReply { + v := new(GetPointerControlReply) + b := 1 // skip reply determinant - buf[b] = Mode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Time)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} + v.AccelerationNumerator = xgb.Get16(buf[b:]) + b += 2 -// GrabServerCookie is a cookie used only for GrabServer requests. -type GrabServerCookie struct { - *xgb.Cookie -} + v.AccelerationDenominator = xgb.Get16(buf[b:]) + b += 2 -// GrabServer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabServer(c *xgb.Conn) GrabServerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(grabServerRequest(c), cookie) - return GrabServerCookie{cookie} -} + v.Threshold = xgb.Get16(buf[b:]) + b += 2 -// GrabServerChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabServerCookie.Check() -func GrabServerChecked(c *xgb.Conn) GrabServerCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(grabServerRequest(c), cookie) - return GrabServerCookie{cookie} -} + b += 18 // padding -// 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 GrabServerCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for GrabServer -// grabServerRequest writes a GrabServer request to a byte slice. -func grabServerRequest(c *xgb.Conn) []byte { +// Write request to wire for GetPointerControl +// getPointerControlRequest writes a GetPointerControl request to a byte slice. +func getPointerControlRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 36 // request opcode + buf[b] = 106 // request opcode b += 1 b += 1 // padding @@ -8849,41 +9850,79 @@ func grabServerRequest(c *xgb.Conn) []byte { return buf } -// UngrabServerCookie is a cookie used only for UngrabServer requests. -type UngrabServerCookie struct { +// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. +type GetPointerMappingCookie struct { *xgb.Cookie } -// UngrabServer sends an unchecked request. +// GetPointerMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPointerMappingCookie.Reply() +func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} +} + +// GetPointerMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabServer(c *xgb.Conn) UngrabServerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabServerRequest(c), cookie) - return UngrabServerCookie{cookie} +func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} } -// UngrabServerChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabServerCookie.Check() -func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabServerRequest(c), cookie) - return UngrabServerCookie{cookie} +// GetPointerMappingReply represents the data returned from a GetPointerMapping request. +type GetPointerMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + MapLen byte + // padding: 24 bytes + Map []byte // size: xgb.Pad((int(MapLen) * 1)) } -// 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 UngrabServerCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a GetPointerMapping request. +func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerMappingReply(buf), nil } -// Write request to wire for UngrabServer -// ungrabServerRequest writes a UngrabServer request to a byte slice. -func ungrabServerRequest(c *xgb.Conn) []byte { +// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. +func getPointerMappingReply(buf []byte) *GetPointerMappingReply { + v := new(GetPointerMappingReply) + b := 1 // skip reply determinant + + v.MapLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Map = make([]byte, v.MapLen) + copy(v.Map[:v.MapLen], buf[b:]) + b += xgb.Pad(int(v.MapLen)) + + return v +} + +// Write request to wire for GetPointerMapping +// getPointerMappingRequest writes a GetPointerMapping request to a byte slice. +func getPointerMappingRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 37 // request opcode + buf[b] = 117 // request opcode b += 1 b += 1 // padding @@ -8893,44 +9932,41 @@ func ungrabServerRequest(c *xgb.Conn) []byte { return buf } -// QueryPointerCookie is a cookie used only for QueryPointer requests. -type QueryPointerCookie struct { +// GetPropertyCookie is a cookie used only for GetProperty requests. +type GetPropertyCookie struct { *xgb.Cookie } -// QueryPointer sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryPointerCookie.Reply() -func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { +// GetProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyCookie.Reply() +func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} } -// QueryPointerUnchecked sends an unchecked request. +// GetPropertyUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { +func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} } -// QueryPointerReply represents the data returned from a QueryPointer request. -type QueryPointerReply struct { +// GetPropertyReply represents the data returned from a GetProperty request. +type GetPropertyReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - SameScreen bool - Root Window - Child Window - RootX int16 - RootY int16 - WinX int16 - WinY int16 - Mask uint16 - // padding: 2 bytes + Format byte + Type Atom + BytesAfter uint32 + ValueLen uint32 + // padding: 12 bytes + Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) } -// Reply blocks and returns the reply data for a QueryPointer request. -func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { +// Reply blocks and returns the reply data for a GetProperty request. +func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8938,19 +9974,15 @@ func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { if buf == nil { return nil, nil } - return queryPointerReply(buf), nil + return getPropertyReply(buf), nil } -// queryPointerReply reads a byte slice into a QueryPointerReply value. -func queryPointerReply(buf []byte) *QueryPointerReply { - v := new(QueryPointerReply) +// getPropertyReply reads a byte slice into a GetPropertyReply value. +func getPropertyReply(buf []byte) *GetPropertyReply { + v := new(GetPropertyReply) b := 1 // skip reply determinant - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } + v.Format = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -8959,43 +9991,40 @@ func queryPointerReply(buf []byte) *QueryPointerReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Root = Window(xgb.Get32(buf[b:])) + v.Type = Atom(xgb.Get32(buf[b:])) b += 4 - v.Child = Window(xgb.Get32(buf[b:])) + v.BytesAfter = xgb.Get32(buf[b:]) b += 4 - v.RootX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RootY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.WinX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.WinY = int16(xgb.Get16(buf[b:])) - b += 2 + v.ValueLen = xgb.Get32(buf[b:]) + b += 4 - v.Mask = xgb.Get16(buf[b:]) - b += 2 + b += 12 // padding - b += 2 // padding + v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) + copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) return v } -// Write request to wire for QueryPointer -// queryPointerRequest writes a QueryPointer request to a byte slice. -func queryPointerRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for GetProperty +// getPropertyRequest writes a GetProperty request to a byte slice. +func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 38 // request opcode + buf[b] = 20 // request opcode b += 1 - b += 1 // padding + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -9003,42 +10032,56 @@ func queryPointerRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + xgb.Put32(buf[b:], LongOffset) + b += 4 + + xgb.Put32(buf[b:], LongLength) + b += 4 + return buf } -// GetMotionEventsCookie is a cookie used only for GetMotionEvents requests. -type GetMotionEventsCookie struct { +// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. +type GetScreenSaverCookie struct { *xgb.Cookie } -// GetMotionEvents sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMotionEventsCookie.Reply() -func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { +// GetScreenSaver sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenSaverCookie.Reply() +func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} } -// GetMotionEventsUnchecked sends an unchecked request. +// GetScreenSaverUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { +func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} } -// GetMotionEventsReply represents the data returned from a GetMotionEvents request. -type GetMotionEventsReply struct { +// GetScreenSaverReply represents the data returned from a GetScreenSaver request. +type GetScreenSaverReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - EventsLen uint32 - // padding: 20 bytes - Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) + Timeout uint16 + Interval uint16 + PreferBlanking byte + AllowExposures byte + // padding: 18 bytes } -// Reply blocks and returns the reply data for a GetMotionEvents request. -func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { +// Reply blocks and returns the reply data for a GetScreenSaver request. +func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9046,12 +10089,12 @@ func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { if buf == nil { return nil, nil } - return getMotionEventsReply(buf), nil + return getScreenSaverReply(buf), nil } -// getMotionEventsReply reads a byte slice into a GetMotionEventsReply value. -func getMotionEventsReply(buf []byte) *GetMotionEventsReply { - v := new(GetMotionEventsReply) +// getScreenSaverReply reads a byte slice into a GetScreenSaverReply value. +func getScreenSaverReply(buf []byte) *GetScreenSaverReply { + v := new(GetScreenSaverReply) b := 1 // skip reply determinant b += 1 // padding @@ -9062,77 +10105,166 @@ func getMotionEventsReply(buf []byte) *GetMotionEventsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.EventsLen = xgb.Get32(buf[b:]) - b += 4 + v.Timeout = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding + v.Interval = xgb.Get16(buf[b:]) + b += 2 - v.Events = make([]Timecoord, v.EventsLen) - b += TimecoordReadList(buf[b:], v.Events) + v.PreferBlanking = buf[b] + b += 1 + + v.AllowExposures = buf[b] + b += 1 + + b += 18 // padding return v } -// Write request to wire for GetMotionEvents -// getMotionEventsRequest writes a GetMotionEvents request to a byte slice. -func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { - size := 16 +// Write request to wire for GetScreenSaver +// getScreenSaverRequest writes a GetScreenSaver request to a byte slice. +func getScreenSaverRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 39 // request opcode + buf[b] = 108 // request opcode b += 1 + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. +type GetSelectionOwnerCookie struct { + *xgb.Cookie +} + +// GetSelectionOwner sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() +func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +// GetSelectionOwnerUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +// GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. +type GetSelectionOwnerReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Owner Window +} + +// Reply blocks and returns the reply data for a GetSelectionOwner request. +func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionOwnerReply(buf), nil +} + +// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. +func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { + v := new(GetSelectionOwnerReply) + b := 1 // skip reply determinant + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Window)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Start)) + v.Owner = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], uint32(Stop)) + return v +} + +// Write request to wire for GetSelectionOwner +// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. +func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 23 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) b += 4 return buf } -// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. -type TranslateCoordinatesCookie struct { +// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. +type GetWindowAttributesCookie struct { *xgb.Cookie } -// TranslateCoordinates sends a checked request. -// If an error occurs, it will be returned with the reply by calling TranslateCoordinatesCookie.Reply() -func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { +// GetWindowAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowAttributesCookie.Reply() +func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { cookie := c.NewCookie(true, true) - c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} } -// TranslateCoordinatesUnchecked sends an unchecked request. +// GetWindowAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { +func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { cookie := c.NewCookie(false, true) - c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} } -// TranslateCoordinatesReply represents the data returned from a TranslateCoordinates request. -type TranslateCoordinatesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - SameScreen bool - Child Window - DstX int16 - DstY int16 +// GetWindowAttributesReply represents the data returned from a GetWindowAttributes request. +type GetWindowAttributesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + BackingStore byte + Visual Visualid + Class uint16 + BitGravity byte + WinGravity byte + BackingPlanes uint32 + BackingPixel uint32 + SaveUnder bool + MapIsInstalled bool + MapState byte + OverrideRedirect bool + Colormap Colormap + AllEventMasks uint32 + YourEventMask uint32 + DoNotPropagateMask uint16 + // padding: 2 bytes } -// Reply blocks and returns the reply data for a TranslateCoordinates request. -func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { +// Reply blocks and returns the reply data for a GetWindowAttributes request. +func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9140,19 +10272,15 @@ func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, erro if buf == nil { return nil, nil } - return translateCoordinatesReply(buf), nil + return getWindowAttributesReply(buf), nil } -// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. -func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { - v := new(TranslateCoordinatesReply) +// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. +func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { + v := new(GetWindowAttributesReply) b := 1 // skip reply determinant - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } + v.BackingStore = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -9161,26 +10289,73 @@ func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Child = Window(xgb.Get32(buf[b:])) + v.Visual = Visualid(xgb.Get32(buf[b:])) b += 4 - v.DstX = int16(xgb.Get16(buf[b:])) + v.Class = xgb.Get16(buf[b:]) b += 2 - v.DstY = int16(xgb.Get16(buf[b:])) + v.BitGravity = buf[b] + b += 1 + + v.WinGravity = buf[b] + b += 1 + + v.BackingPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.BackingPixel = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.SaveUnder = true + } else { + v.SaveUnder = false + } + b += 1 + + if buf[b] == 1 { + v.MapIsInstalled = true + } else { + v.MapIsInstalled = false + } + b += 1 + + v.MapState = buf[b] + b += 1 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + v.AllEventMasks = xgb.Get32(buf[b:]) + b += 4 + + v.YourEventMask = xgb.Get32(buf[b:]) + b += 4 + + v.DoNotPropagateMask = xgb.Get16(buf[b:]) b += 2 + b += 2 // padding + return v } -// Write request to wire for TranslateCoordinates -// translateCoordinatesRequest writes a TranslateCoordinates request to a byte slice. -func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { - size := 16 +// Write request to wire for GetWindowAttributes +// getWindowAttributesRequest writes a GetWindowAttributes request to a byte slice. +func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 40 // request opcode + buf[b] = 3 // request opcode b += 1 b += 1 // padding @@ -9188,173 +10363,185 @@ func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstWindow)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - return buf } -// WarpPointerCookie is a cookie used only for WarpPointer requests. -type WarpPointerCookie struct { +// GrabButtonCookie is a cookie used only for GrabButton requests. +type GrabButtonCookie struct { *xgb.Cookie } -// WarpPointer sends an unchecked request. +// GrabButton sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { +func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { cookie := c.NewCookie(false, false) - c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} } -// WarpPointerChecked sends a checked request. -// If an error occurs, it can be retrieved using WarpPointerCookie.Check() -func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { +// GrabButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabButtonCookie.Check() +func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { cookie := c.NewCookie(true, false) - c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{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 WarpPointerCookie) Check() error { +func (cook GrabButtonCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for WarpPointer -// warpPointerRequest writes a WarpPointer request to a byte slice. -func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { +// Write request to wire for GrabButton +// grabButtonRequest writes a GrabButton request to a byte slice. +func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { size := 24 b := 0 buf := make([]byte, size) - buf[b] = 41 // request opcode + buf[b] = 28 // request opcode b += 1 - b += 1 // padding + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstWindow)) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) + xgb.Put16(buf[b:], EventMask) b += 2 - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 + buf[b] = PointerMode + b += 1 - xgb.Put16(buf[b:], SrcWidth) - b += 2 + buf[b] = KeyboardMode + b += 1 - xgb.Put16(buf[b:], SrcHeight) - b += 2 + xgb.Put32(buf[b:], uint32(ConfineTo)) + b += 4 - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 - xgb.Put16(buf[b:], uint16(DstY)) + buf[b] = Button + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], Modifiers) b += 2 return buf } -// SetInputFocusCookie is a cookie used only for SetInputFocus requests. -type SetInputFocusCookie struct { +// GrabKeyCookie is a cookie used only for GrabKey requests. +type GrabKeyCookie struct { *xgb.Cookie } -// SetInputFocus sends an unchecked request. +// GrabKey sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { +func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} } -// SetInputFocusChecked sends a checked request. -// If an error occurs, it can be retrieved using SetInputFocusCookie.Check() -func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { +// GrabKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabKeyCookie.Check() +func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { cookie := c.NewCookie(true, false) - c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{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 SetInputFocusCookie) Check() error { +func (cook GrabKeyCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetInputFocus -// setInputFocusRequest writes a SetInputFocus request to a byte slice. -func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { - size := 12 +// Write request to wire for GrabKey +// grabKeyRequest writes a GrabKey request to a byte slice. +func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 42 // request opcode + buf[b] = 33 // request opcode b += 1 - buf[b] = RevertTo + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Focus)) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = byte(Key) + b += 1 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 3 // padding return buf } -// GetInputFocusCookie is a cookie used only for GetInputFocus requests. -type GetInputFocusCookie struct { +// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. +type GrabKeyboardCookie struct { *xgb.Cookie } -// GetInputFocus sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetInputFocusCookie.Reply() -func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { +// GrabKeyboard sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabKeyboardCookie.Reply() +func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getInputFocusRequest(c), cookie) - return GetInputFocusCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} } -// GetInputFocusUnchecked sends an unchecked request. +// GrabKeyboardUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { +func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getInputFocusRequest(c), cookie) - return GetInputFocusCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} } -// GetInputFocusReply represents the data returned from a GetInputFocus request. -type GetInputFocusReply struct { +// GrabKeyboardReply represents the data returned from a GrabKeyboard request. +type GrabKeyboardReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - RevertTo byte - Focus Window + Status byte } -// Reply blocks and returns the reply data for a GetInputFocus request. -func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { +// Reply blocks and returns the reply data for a GrabKeyboard request. +func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9362,15 +10549,15 @@ func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { if buf == nil { return nil, nil } - return getInputFocusReply(buf), nil + return grabKeyboardReply(buf), nil } -// getInputFocusReply reads a byte slice into a GetInputFocusReply value. -func getInputFocusReply(buf []byte) *GetInputFocusReply { - v := new(GetInputFocusReply) +// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. +func grabKeyboardReply(buf []byte) *GrabKeyboardReply { + v := new(GrabKeyboardReply) b := 1 // skip reply determinant - v.RevertTo = buf[b] + v.Status = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -9379,60 +10566,76 @@ func getInputFocusReply(buf []byte) *GetInputFocusReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Focus = Window(xgb.Get32(buf[b:])) - b += 4 - return v } -// Write request to wire for GetInputFocus -// getInputFocusRequest writes a GetInputFocus request to a byte slice. -func getInputFocusRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GrabKeyboard +// grabKeyboardRequest writes a GrabKeyboard request to a byte slice. +func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 43 // request opcode + buf[b] = 31 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 2 // padding + return buf } -// QueryKeymapCookie is a cookie used only for QueryKeymap requests. -type QueryKeymapCookie struct { +// GrabPointerCookie is a cookie used only for GrabPointer requests. +type GrabPointerCookie struct { *xgb.Cookie } -// QueryKeymap sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryKeymapCookie.Reply() -func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { +// GrabPointer sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabPointerCookie.Reply() +func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} } -// QueryKeymapUnchecked sends an unchecked request. +// GrabPointerUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { +func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} } -// QueryKeymapReply represents the data returned from a QueryKeymap request. -type QueryKeymapReply struct { +// GrabPointerReply represents the data returned from a GrabPointer request. +type GrabPointerReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - // padding: 1 bytes - Keys []byte // size: 32 + Status byte } -// Reply blocks and returns the reply data for a QueryKeymap request. -func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { +// Reply blocks and returns the reply data for a GrabPointer request. +func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9440,15 +10643,16 @@ func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { if buf == nil { return nil, nil } - return queryKeymapReply(buf), nil + return grabPointerReply(buf), nil } -// queryKeymapReply reads a byte slice into a QueryKeymapReply value. -func queryKeymapReply(buf []byte) *QueryKeymapReply { - v := new(QueryKeymapReply) +// grabPointerReply reads a byte slice into a GrabPointerReply value. +func grabPointerReply(buf []byte) *GrabPointerReply { + v := new(GrabPointerReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -9456,21 +10660,88 @@ func queryKeymapReply(buf []byte) *QueryKeymapReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += xgb.Pad(int(32)) - return v } -// Write request to wire for QueryKeymap -// queryKeymapRequest writes a QueryKeymap request to a byte slice. -func queryKeymapRequest(c *xgb.Conn) []byte { +// Write request to wire for GrabPointer +// grabPointerRequest writes a GrabPointer request to a byte slice. +func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 26 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + xgb.Put32(buf[b:], uint32(ConfineTo)) + b += 4 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// GrabServerCookie is a cookie used only for GrabServer requests. +type GrabServerCookie struct { + *xgb.Cookie +} + +// GrabServer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GrabServer(c *xgb.Conn) GrabServerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{cookie} +} + +// GrabServerChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabServerCookie.Check() +func GrabServerChecked(c *xgb.Conn) GrabServerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{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 GrabServerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabServer +// grabServerRequest writes a GrabServer request to a byte slice. +func grabServerRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 44 // request opcode + buf[b] = 36 // request opcode b += 1 b += 1 // padding @@ -9480,97 +10751,162 @@ func queryKeymapRequest(c *xgb.Conn) []byte { return buf } -// OpenFontCookie is a cookie used only for OpenFont requests. -type OpenFontCookie struct { +// ImageText16Cookie is a cookie used only for ImageText16 requests. +type ImageText16Cookie struct { *xgb.Cookie } -// OpenFont sends an unchecked request. +// ImageText16 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { +func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { cookie := c.NewCookie(false, false) - c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} } -// OpenFontChecked sends a checked request. -// If an error occurs, it can be retrieved using OpenFontCookie.Check() -func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { +// ImageText16Checked sends a checked request. +// If an error occurs, it can be retrieved using ImageText16Cookie.Check() +func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { cookie := c.NewCookie(true, false) - c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{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 OpenFontCookie) Check() error { +func (cook ImageText16Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for OpenFont -// openFontRequest writes a OpenFont request to a byte slice. -func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for ImageText16 +// imageText16Request writes a ImageText16 request to a byte slice. +func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) b := 0 buf := make([]byte, size) - buf[b] = 45 // request opcode + buf[b] = 77 // request opcode b += 1 - b += 1 // padding + buf[b] = StringLen + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Fid)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], NameLen) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) b += 2 - b += 2 // padding + xgb.Put16(buf[b:], uint16(Y)) + b += 2 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += Char2bListBytes(buf[b:], String) return buf } -// CloseFontCookie is a cookie used only for CloseFont requests. -type CloseFontCookie struct { +// ImageText8Cookie is a cookie used only for ImageText8 requests. +type ImageText8Cookie struct { *xgb.Cookie } -// CloseFont sends an unchecked request. +// ImageText8 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { +func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { cookie := c.NewCookie(false, false) - c.NewRequest(closeFontRequest(c, Font), cookie) - return CloseFontCookie{cookie} + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} } -// CloseFontChecked sends a checked request. -// If an error occurs, it can be retrieved using CloseFontCookie.Check() -func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { +// ImageText8Checked sends a checked request. +// If an error occurs, it can be retrieved using ImageText8Cookie.Check() +func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { cookie := c.NewCookie(true, false) - c.NewRequest(closeFontRequest(c, Font), cookie) - return CloseFontCookie{cookie} + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{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 CloseFontCookie) Check() error { +func (cook ImageText8Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CloseFont -// closeFontRequest writes a CloseFont request to a byte slice. -func closeFontRequest(c *xgb.Conn, Font Font) []byte { +// Write request to wire for ImageText8 +// imageText8Request writes a ImageText8 request to a byte slice. +func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 76 // request opcode + b += 1 + + buf[b] = StringLen + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], String[:StringLen]) + b += xgb.Pad(int(StringLen)) + + return buf +} + +// InstallColormapCookie is a cookie used only for InstallColormap requests. +type InstallColormapCookie struct { + *xgb.Cookie +} + +// InstallColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} +} + +// InstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using InstallColormapCookie.Check() +func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{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 InstallColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for InstallColormap +// installColormapRequest writes a InstallColormap request to a byte slice. +func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 46 // request opcode + buf[b] = 81 // request opcode b += 1 b += 1 // padding @@ -9578,59 +10914,43 @@ func closeFontRequest(c *xgb.Conn, Font Font) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Font)) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 return buf } -// QueryFontCookie is a cookie used only for QueryFont requests. -type QueryFontCookie struct { +// InternAtomCookie is a cookie used only for InternAtom requests. +type InternAtomCookie struct { *xgb.Cookie } -// QueryFont sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryFontCookie.Reply() -func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { +// InternAtom sends a checked request. +// If an error occurs, it will be returned with the reply by calling InternAtomCookie.Reply() +func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} } -// QueryFontUnchecked sends an unchecked request. +// InternAtomUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { +func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} } -// QueryFontReply represents the data returned from a QueryFont request. -type QueryFontReply struct { +// InternAtomReply represents the data returned from a InternAtom request. +type InternAtomReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MinBounds Charinfo - // padding: 4 bytes - MaxBounds Charinfo - // padding: 4 bytes - MinCharOrByte2 uint16 - MaxCharOrByte2 uint16 - DefaultChar uint16 - PropertiesLen uint16 - DrawDirection byte - MinByte1 byte - MaxByte1 byte - AllCharsExist bool - FontAscent int16 - FontDescent int16 - CharInfosLen uint32 - Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) - CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) + Atom Atom } -// Reply blocks and returns the reply data for a QueryFont request. -func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { +// Reply blocks and returns the reply data for a InternAtom request. +func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9638,12 +10958,12 @@ func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { if buf == nil { return nil, nil } - return queryFontReply(buf), nil + return internAtomReply(buf), nil } -// queryFontReply reads a byte slice into a QueryFontReply value. -func queryFontReply(buf []byte) *QueryFontReply { - v := new(QueryFontReply) +// internAtomReply reads a byte slice into a InternAtomReply value. +func internAtomReply(buf []byte) *InternAtomReply { + v := new(InternAtomReply) b := 1 // skip reply determinant b += 1 // padding @@ -9654,70 +10974,78 @@ func queryFontReply(buf []byte) *QueryFontReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MinBounds = Charinfo{} - b += CharinfoRead(buf[b:], &v.MinBounds) - - b += 4 // padding - - v.MaxBounds = Charinfo{} - b += CharinfoRead(buf[b:], &v.MaxBounds) - - b += 4 // padding - - v.MinCharOrByte2 = xgb.Get16(buf[b:]) - b += 2 - - v.MaxCharOrByte2 = xgb.Get16(buf[b:]) - b += 2 - - v.DefaultChar = xgb.Get16(buf[b:]) - b += 2 - - v.PropertiesLen = xgb.Get16(buf[b:]) - b += 2 + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 - v.DrawDirection = buf[b] - b += 1 + return v +} - v.MinByte1 = buf[b] - b += 1 +// Write request to wire for InternAtom +// internAtomRequest writes a InternAtom request to a byte slice. +func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) - v.MaxByte1 = buf[b] + buf[b] = 16 // request opcode b += 1 - if buf[b] == 1 { - v.AllCharsExist = true + if OnlyIfExists { + buf[b] = 1 } else { - v.AllCharsExist = false + buf[b] = 0 } b += 1 - v.FontAscent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.FontDescent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], NameLen) b += 2 - v.CharInfosLen = xgb.Get32(buf[b:]) - b += 4 + b += 2 // padding - v.Properties = make([]Fontprop, v.PropertiesLen) - b += FontpropReadList(buf[b:], v.Properties) + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) - v.CharInfos = make([]Charinfo, v.CharInfosLen) - b += CharinfoReadList(buf[b:], v.CharInfos) + return buf +} - return v +// KillClientCookie is a cookie used only for KillClient requests. +type KillClientCookie struct { + *xgb.Cookie } -// Write request to wire for QueryFont -// queryFontRequest writes a QueryFont request to a byte slice. -func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { +// KillClient sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{cookie} +} + +// KillClientChecked sends a checked request. +// If an error occurs, it can be retrieved using KillClientCookie.Check() +func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{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 KillClientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for KillClient +// killClientRequest writes a KillClient request to a byte slice. +func killClientRequest(c *xgb.Conn, Resource uint32) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 47 // request opcode + buf[b] = 113 // request opcode b += 1 b += 1 // padding @@ -9725,49 +11053,44 @@ func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Font)) + xgb.Put32(buf[b:], Resource) b += 4 return buf } -// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. -type QueryTextExtentsCookie struct { +// ListExtensionsCookie is a cookie used only for ListExtensions requests. +type ListExtensionsCookie struct { *xgb.Cookie } -// QueryTextExtents sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryTextExtentsCookie.Reply() -func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { +// ListExtensions sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListExtensionsCookie.Reply() +func ListExtensions(c *xgb.Conn) ListExtensionsCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} } -// QueryTextExtentsUnchecked sends an unchecked request. +// ListExtensionsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { +func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} } -// QueryTextExtentsReply represents the data returned from a QueryTextExtents request. -type QueryTextExtentsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - DrawDirection byte - FontAscent int16 - FontDescent int16 - OverallAscent int16 - OverallDescent int16 - OverallWidth int32 - OverallLeft int32 - OverallRight int32 +// ListExtensionsReply represents the data returned from a ListExtensions request. +type ListExtensionsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + NamesLen byte + // padding: 24 bytes + Names []Str // size: StrListSize(Names) } -// Reply blocks and returns the reply data for a QueryTextExtents request. -func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { +// Reply blocks and returns the reply data for a ListExtensions request. +func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9775,15 +11098,15 @@ func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { if buf == nil { return nil, nil } - return queryTextExtentsReply(buf), nil + return listExtensionsReply(buf), nil } -// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. -func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { - v := new(QueryTextExtentsReply) +// listExtensionsReply reads a byte slice into a ListExtensionsReply value. +func listExtensionsReply(buf []byte) *ListExtensionsReply { + v := new(ListExtensionsReply) b := 1 // skip reply determinant - v.DrawDirection = buf[b] + v.NamesLen = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -9792,53 +11115,28 @@ func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.FontAscent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.OverallAscent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.OverallDescent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.OverallWidth = int32(xgb.Get32(buf[b:])) - b += 4 - - v.OverallLeft = int32(xgb.Get32(buf[b:])) - b += 4 + b += 24 // padding - v.OverallRight = int32(xgb.Get32(buf[b:])) - b += 4 + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) return v } -// Write request to wire for QueryTextExtents -// queryTextExtentsRequest writes a QueryTextExtents request to a byte slice. -func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { - size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) +// Write request to wire for ListExtensions +// listExtensionsRequest writes a ListExtensions request to a byte slice. +func listExtensionsRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 48 // request opcode - b += 1 - - buf[b] = byte((int(StringLen) & 1)) + buf[b] = 99 // request opcode b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Font)) - b += 4 - - b += Char2bListBytes(buf[b:], String) - - // skip writing local field: StringLen (2) :: uint16 - return buf } @@ -10094,91 +11392,39 @@ func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, P return buf } -// SetFontPathCookie is a cookie used only for SetFontPath requests. -type SetFontPathCookie struct { - *xgb.Cookie -} - -// SetFontPath sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -// SetFontPathChecked sends a checked request. -// If an error occurs, it can be retrieved using SetFontPathCookie.Check() -func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) - return SetFontPathCookie{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 SetFontPathCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetFontPath -// setFontPathRequest writes a SetFontPath request to a byte slice. -func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { - size := xgb.Pad((8 + StrListSize(Font))) - b := 0 - buf := make([]byte, size) - - buf[b] = 51 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], FontQty) - b += 2 - - b += 2 // padding - - b += StrListBytes(buf[b:], Font) - - return buf -} - -// GetFontPathCookie is a cookie used only for GetFontPath requests. -type GetFontPathCookie struct { +// ListHostsCookie is a cookie used only for ListHosts requests. +type ListHostsCookie struct { *xgb.Cookie } -// GetFontPath sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply() -func GetFontPath(c *xgb.Conn) GetFontPathCookie { +// ListHosts sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply() +func ListHosts(c *xgb.Conn) ListHostsCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} } -// GetFontPathUnchecked sends an unchecked request. +// ListHostsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { +func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} } -// GetFontPathReply represents the data returned from a GetFontPath request. -type GetFontPathReply struct { +// ListHostsReply represents the data returned from a ListHosts request. +type ListHostsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - // padding: 1 bytes - PathLen uint16 + Mode byte + HostsLen uint16 // padding: 22 bytes - Path []Str // size: StrListSize(Path) + Hosts []Host // size: HostListSize(Hosts) } -// Reply blocks and returns the reply data for a GetFontPath request. -func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { +// Reply blocks and returns the reply data for a ListHosts request. +func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -10186,15 +11432,16 @@ func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { if buf == nil { return nil, nil } - return getFontPathReply(buf), nil + return listHostsReply(buf), nil } -// getFontPathReply reads a byte slice into a GetFontPathReply value. -func getFontPathReply(buf []byte) *GetFontPathReply { - v := new(GetFontPathReply) +// listHostsReply reads a byte slice into a ListHostsReply value. +func listHostsReply(buf []byte) *ListHostsReply { + v := new(ListHostsReply) b := 1 // skip reply determinant - b += 1 // padding + v.Mode = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -10202,25 +11449,25 @@ func getFontPathReply(buf []byte) *GetFontPathReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PathLen = xgb.Get16(buf[b:]) + v.HostsLen = xgb.Get16(buf[b:]) b += 2 b += 22 // padding - v.Path = make([]Str, v.PathLen) - b += StrReadList(buf[b:], v.Path) + v.Hosts = make([]Host, v.HostsLen) + b += HostReadList(buf[b:], v.Hosts) return v } -// Write request to wire for GetFontPath -// getFontPathRequest writes a GetFontPath request to a byte slice. -func getFontPathRequest(c *xgb.Conn) []byte { +// Write request to wire for ListHosts +// listHostsRequest writes a ListHosts request to a byte slice. +func listHostsRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 52 // request opcode + buf[b] = 110 // request opcode b += 1 b += 1 // padding @@ -10230,206 +11477,85 @@ func getFontPathRequest(c *xgb.Conn) []byte { return buf } -// CreatePixmapCookie is a cookie used only for CreatePixmap requests. -type CreatePixmapCookie struct { +// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. +type ListInstalledColormapsCookie struct { *xgb.Cookie } -// CreatePixmap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{cookie} -} - -// CreatePixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() -func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{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 CreatePixmapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreatePixmap -// createPixmapRequest writes a CreatePixmap request to a byte slice. -func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 53 // request opcode - b += 1 - - buf[b] = Depth - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Pid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - return buf -} - -// FreePixmapCookie is a cookie used only for FreePixmap requests. -type FreePixmapCookie struct { - *xgb.Cookie +// ListInstalledColormaps sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListInstalledColormapsCookie.Reply() +func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} } -// FreePixmap sends an unchecked request. +// ListInstalledColormapsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} +func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} } -// FreePixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using FreePixmapCookie.Check() -func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} +// ListInstalledColormapsReply represents the data returned from a ListInstalledColormaps request. +type ListInstalledColormapsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + CmapsLen uint16 + // padding: 22 bytes + Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) } -// 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 FreePixmapCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a ListInstalledColormaps request. +func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listInstalledColormapsReply(buf), nil } -// Write request to wire for FreePixmap -// freePixmapRequest writes a FreePixmap request to a byte slice. -func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 54 // request opcode - b += 1 +// listInstalledColormapsReply reads a byte slice into a ListInstalledColormapsReply value. +func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { + v := new(ListInstalledColormapsReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Pixmap)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} - -// CreateGCCookie is a cookie used only for CreateGC requests. -type CreateGCCookie struct { - *xgb.Cookie -} - -// CreateGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} -} - -// CreateGCChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateGCCookie.Check() -func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{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 CreateGCCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateGC -// createGCRequest writes a CreateGC request to a byte slice. -func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 55 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.CmapsLen = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 + b += 22 // padding - xgb.Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) + v.Cmaps = make([]Colormap, v.CmapsLen) + for i := 0; i < int(v.CmapsLen); i++ { + v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) - return buf -} - -// ChangeGCCookie is a cookie used only for ChangeGC requests. -type ChangeGCCookie struct { - *xgb.Cookie -} - -// ChangeGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} -} - -// ChangeGCChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeGCCookie.Check() -func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{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 ChangeGCCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for ChangeGC -// changeGCRequest writes a ChangeGC request to a byte slice. -func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for ListInstalledColormaps +// listInstalledColormapsRequest writes a ListInstalledColormaps request to a byte slice. +func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 56 // request opcode + buf[b] = 83 // request opcode b += 1 b += 1 // padding @@ -10437,223 +11563,91 @@ func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uin xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) return buf } -// CopyGCCookie is a cookie used only for CopyGC requests. -type CopyGCCookie struct { +// ListPropertiesCookie is a cookie used only for ListProperties requests. +type ListPropertiesCookie struct { *xgb.Cookie } -// CopyGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -// CopyGCChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyGCCookie.Check() -func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{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 CopyGCCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CopyGC -// copyGCRequest writes a CopyGC request to a byte slice. -func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 57 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(SrcGc)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstGc)) - b += 4 - - xgb.Put32(buf[b:], ValueMask) - b += 4 - - return buf -} - -// SetDashesCookie is a cookie used only for SetDashes requests. -type SetDashesCookie struct { - *xgb.Cookie +// ListProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() +func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// SetDashes sends an unchecked request. +// ListPropertiesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} +func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// SetDashesChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDashesCookie.Check() -func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} +// ListPropertiesReply represents the data returned from a ListProperties request. +type ListPropertiesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + AtomsLen uint16 + // padding: 22 bytes + Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) } -// 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 SetDashesCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a ListProperties request. +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listPropertiesReply(buf), nil } -// Write request to wire for SetDashes -// setDashesRequest writes a SetDashes request to a byte slice. -func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { - size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 58 // request opcode - b += 1 +// listPropertiesReply reads a byte slice into a ListPropertiesReply value. +func listPropertiesReply(buf []byte) *ListPropertiesReply { + v := new(ListPropertiesReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], DashOffset) - b += 2 - - xgb.Put16(buf[b:], DashesLen) - b += 2 - - copy(buf[b:], Dashes[:DashesLen]) - b += xgb.Pad(int(DashesLen)) - - return buf -} - -// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. -type SetClipRectanglesCookie struct { - *xgb.Cookie -} - -// SetClipRectangles sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} -} - -// SetClipRectanglesChecked sends a checked request. -// If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() -func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{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 SetClipRectanglesCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetClipRectangles -// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. -func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 59 // request opcode - b += 1 - - buf[b] = Ordering - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Gc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(ClipYOrigin)) + v.AtomsLen = xgb.Get16(buf[b:]) b += 2 - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// FreeGCCookie is a cookie used only for FreeGC requests. -type FreeGCCookie struct { - *xgb.Cookie -} - -// FreeGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeGCRequest(c, Gc), cookie) - return FreeGCCookie{cookie} -} + b += 22 // padding -// FreeGCChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeGCCookie.Check() -func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freeGCRequest(c, Gc), cookie) - return FreeGCCookie{cookie} -} + v.Atoms = make([]Atom, v.AtomsLen) + for i := 0; i < int(v.AtomsLen); i++ { + v.Atoms[i] = Atom(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) -// 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 FreeGCCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for FreeGC -// freeGCRequest writes a FreeGC request to a byte slice. -func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { +// Write request to wire for ListProperties +// listPropertiesRequest writes a ListProperties request to a byte slice. +func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 60 // request opcode + buf[b] = 21 // request opcode b += 1 b += 1 // padding @@ -10661,184 +11655,100 @@ func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// ClearAreaCookie is a cookie used only for ClearArea requests. -type ClearAreaCookie struct { +// LookupColorCookie is a cookie used only for LookupColor requests. +type LookupColorCookie struct { *xgb.Cookie } -// ClearArea sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} -} - -// ClearAreaChecked sends a checked request. -// If an error occurs, it can be retrieved using ClearAreaCookie.Check() -func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{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 ClearAreaCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ClearArea -// clearAreaRequest writes a ClearArea request to a byte slice. -func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 61 // request opcode - b += 1 - - if Exposures { - buf[b] = 1 - } else { - buf[b] = 0 - } - 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.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - return buf -} - -// CopyAreaCookie is a cookie used only for CopyArea requests. -type CopyAreaCookie struct { - *xgb.Cookie +// LookupColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply() +func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} } -// CopyArea sends an unchecked request. +// LookupColorUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} +func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} } -// CopyAreaChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyAreaCookie.Check() -func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} +// LookupColorReply represents the data returned from a LookupColor request. +type LookupColorReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 } -// 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 CopyAreaCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a LookupColor request. +func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return lookupColorReply(buf), nil } -// Write request to wire for CopyArea -// copyAreaRequest writes a CopyArea request to a byte slice. -func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = 62 // request opcode - b += 1 +// lookupColorReply reads a byte slice into a LookupColorReply value. +func lookupColorReply(buf []byte) *LookupColorReply { + v := new(LookupColorReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(SrcDrawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstDrawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) + v.ExactRed = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(SrcY)) + v.ExactGreen = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(DstX)) + v.ExactBlue = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(DstY)) + v.VisualRed = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Width) + v.VisualGreen = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Height) + v.VisualBlue = xgb.Get16(buf[b:]) b += 2 - return buf -} - -// CopyPlaneCookie is a cookie used only for CopyPlane requests. -type CopyPlaneCookie struct { - *xgb.Cookie -} - -// CopyPlane sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} -} - -// CopyPlaneChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyPlaneCookie.Check() -func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{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 CopyPlaneCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for CopyPlane -// copyPlaneRequest writes a CopyPlane request to a byte slice. -func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { - size := 32 +// Write request to wire for LookupColor +// lookupColorRequest writes a LookupColor request to a byte slice. +func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 63 // request opcode + buf[b] = 92 // request opcode b += 1 b += 1 // padding @@ -10846,235 +11756,195 @@ func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, G xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(SrcDrawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstDrawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstY)) - b += 2 - - xgb.Put16(buf[b:], Width) + xgb.Put16(buf[b:], NameLen) b += 2 - xgb.Put16(buf[b:], Height) - b += 2 + b += 2 // padding - xgb.Put32(buf[b:], BitPlane) - b += 4 + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// PolyPointCookie is a cookie used only for PolyPoint requests. -type PolyPointCookie struct { +// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. +type MapSubwindowsCookie struct { *xgb.Cookie } -// PolyPoint sends an unchecked request. +// MapSubwindows sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { +func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{cookie} } -// PolyPointChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyPointCookie.Check() -func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { +// MapSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using MapSubwindowsCookie.Check() +func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{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 PolyPointCookie) Check() error { +func (cook MapSubwindowsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyPoint -// polyPointRequest writes a PolyPoint request to a byte slice. -func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +// Write request to wire for MapSubwindows +// mapSubwindowsRequest writes a MapSubwindows request to a byte slice. +func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 64 // request opcode + buf[b] = 9 // request opcode b += 1 - buf[b] = CoordinateMode - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - b += PointListBytes(buf[b:], Points) - return buf } -// PolyLineCookie is a cookie used only for PolyLine requests. -type PolyLineCookie struct { +// MapWindowCookie is a cookie used only for MapWindow requests. +type MapWindowCookie struct { *xgb.Cookie } -// PolyLine sends an unchecked request. +// MapWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { +func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} } -// PolyLineChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyLineCookie.Check() -func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { +// MapWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using MapWindowCookie.Check() +func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{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 PolyLineCookie) Check() error { +func (cook MapWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyLine -// polyLineRequest writes a PolyLine request to a byte slice. -func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +// Write request to wire for MapWindow +// mapWindowRequest writes a MapWindow request to a byte slice. +func mapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 65 // request opcode + buf[b] = 8 // request opcode b += 1 - buf[b] = CoordinateMode - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - b += PointListBytes(buf[b:], Points) - return buf } -// PolySegmentCookie is a cookie used only for PolySegment requests. -type PolySegmentCookie struct { +// NoOperationCookie is a cookie used only for NoOperation requests. +type NoOperationCookie struct { *xgb.Cookie } -// PolySegment sends an unchecked request. +// NoOperation sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { +func NoOperation(c *xgb.Conn) NoOperationCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} } -// PolySegmentChecked sends a checked request. -// If an error occurs, it can be retrieved using PolySegmentCookie.Check() -func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { +// NoOperationChecked sends a checked request. +// If an error occurs, it can be retrieved using NoOperationCookie.Check() +func NoOperationChecked(c *xgb.Conn) NoOperationCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{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 PolySegmentCookie) Check() error { +func (cook NoOperationCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolySegment -// polySegmentRequest writes a PolySegment request to a byte slice. -func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) +// Write request to wire for NoOperation +// noOperationRequest writes a NoOperation request to a byte slice. +func noOperationRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 66 // request opcode + buf[b] = 127 // request opcode b += 1 - b += 1 // padding - + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += SegmentListBytes(buf[b:], Segments) - return buf } -// PolyRectangleCookie is a cookie used only for PolyRectangle requests. -type PolyRectangleCookie struct { +// OpenFontCookie is a cookie used only for OpenFont requests. +type OpenFontCookie struct { *xgb.Cookie } -// PolyRectangle sends an unchecked request. +// OpenFont sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { +func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} } -// PolyRectangleChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyRectangleCookie.Check() -func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { +// OpenFontChecked sends a checked request. +// If an error occurs, it can be retrieved using OpenFontCookie.Check() +func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{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 PolyRectangleCookie) Check() error { +func (cook OpenFontCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyRectangle -// polyRectangleRequest writes a PolyRectangle request to a byte slice. -func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +// Write request to wire for OpenFont +// openFontRequest writes a OpenFont request to a byte slice. +func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 67 // request opcode + buf[b] = 45 // request opcode b += 1 b += 1 // padding @@ -11082,13 +11952,16 @@ func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangle xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Fid)) b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + xgb.Put16(buf[b:], NameLen) + b += 2 - b += RectangleListBytes(buf[b:], Rectangles) + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } @@ -11146,41 +12019,41 @@ func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []b return buf } -// FillPolyCookie is a cookie used only for FillPoly requests. -type FillPolyCookie struct { +// PolyFillArcCookie is a cookie used only for PolyFillArc requests. +type PolyFillArcCookie struct { *xgb.Cookie } -// FillPoly sends an unchecked request. +// PolyFillArc sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { +func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { cookie := c.NewCookie(false, false) - c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} } -// FillPolyChecked sends a checked request. -// If an error occurs, it can be retrieved using FillPolyCookie.Check() -func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { +// PolyFillArcChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyFillArcCookie.Check() +func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { cookie := c.NewCookie(true, false) - c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{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 FillPolyCookie) Check() error { +func (cook PolyFillArcCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FillPoly -// fillPolyRequest writes a FillPoly request to a byte slice. -func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) +// Write request to wire for PolyFillArc +// polyFillArcRequest writes a PolyFillArc request to a byte slice. +func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) b := 0 buf := make([]byte, size) - buf[b] = 69 // request opcode + buf[b] = 71 // request opcode b += 1 b += 1 // padding @@ -11194,15 +12067,7 @@ func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, Co xgb.Put32(buf[b:], uint32(Gc)) b += 4 - buf[b] = Shape - b += 1 - - buf[b] = CoordinateMode - b += 1 - - b += 2 // padding - - b += PointListBytes(buf[b:], Points) + b += ArcListBytes(buf[b:], Arcs) return buf } @@ -11260,44 +12125,45 @@ func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Recta return buf } -// PolyFillArcCookie is a cookie used only for PolyFillArc requests. -type PolyFillArcCookie struct { +// PolyLineCookie is a cookie used only for PolyLine requests. +type PolyLineCookie struct { *xgb.Cookie } -// PolyFillArc sends an unchecked request. +// PolyLine sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { +func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{cookie} } -// PolyFillArcChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyFillArcCookie.Check() -func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { +// PolyLineChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyLineCookie.Check() +func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{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 PolyFillArcCookie) Check() error { +func (cook PolyLineCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyFillArc -// polyFillArcRequest writes a PolyFillArc request to a byte slice. -func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +// Write request to wire for PolyLine +// polyLineRequest writes a PolyLine request to a byte slice. +func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 71 // request opcode + buf[b] = 65 // request opcode b += 1 - b += 1 // padding + buf[b] = CoordinateMode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -11308,49 +12174,49 @@ func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) xgb.Put32(buf[b:], uint32(Gc)) b += 4 - b += ArcListBytes(buf[b:], Arcs) + b += PointListBytes(buf[b:], Points) return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// PolyPointCookie is a cookie used only for PolyPoint requests. +type PolyPointCookie struct { *xgb.Cookie } -// PutImage sends an unchecked request. +// PolyPoint sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutImage(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { +func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { cookie := c.NewCookie(false, false) - c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{cookie} } -// PutImageChecked sends a checked request. -// If an error occurs, it can be retrieved using PutImageCookie.Check() -func PutImageChecked(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { +// PolyPointChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyPointCookie.Check() +func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { cookie := c.NewCookie(true, false) - c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{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 PutImageCookie) Check() error { +func (cook PolyPointCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutImage -// putImageRequest writes a PutImage request to a byte slice. -func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { - size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) +// Write request to wire for PolyPoint +// polyPointRequest writes a PolyPoint request to a byte slice. +func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 72 // request opcode + buf[b] = 64 // request opcode b += 1 - buf[b] = Format + buf[b] = CoordinateMode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -11362,113 +12228,49 @@ func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, W xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstY)) - b += 2 - - buf[b] = LeftPad - b += 1 - - buf[b] = Depth - b += 1 - - b += 2 // padding - - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += PointListBytes(buf[b:], Points) return buf } -// GetImageCookie is a cookie used only for GetImage requests. -type GetImageCookie struct { +// PolyRectangleCookie is a cookie used only for PolyRectangle requests. +type PolyRectangleCookie struct { *xgb.Cookie } -// GetImage sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetImageCookie.Reply() -func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -// GetImageUnchecked sends an unchecked request. +// PolyRectangle sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -// GetImageReply represents the data returned from a GetImage request. -type GetImageReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Depth byte - Visual Visualid - // padding: 20 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} } -// Reply blocks and returns the reply data for a GetImage request. -func (cook GetImageCookie) Reply() (*GetImageReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getImageReply(buf), nil +// PolyRectangleChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyRectangleCookie.Check() +func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} } -// getImageReply reads a byte slice into a GetImageReply value. -func getImageReply(buf []byte) *GetImageReply { - v := new(GetImageReply) - b := 1 // skip reply determinant - - v.Depth = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Visual = Visualid(xgb.Get32(buf[b:])) - b += 4 - - b += 20 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 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 PolyRectangleCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetImage -// getImageRequest writes a GetImage request to a byte slice. -func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { - size := 20 +// Write request to wire for PolyRectangle +// polyRectangleRequest writes a PolyRectangle request to a byte slice. +func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) - buf[b] = 73 // request opcode + buf[b] = 67 // request opcode b += 1 - buf[b] = Format - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -11476,59 +12278,49 @@ func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - xgb.Put32(buf[b:], PlaneMask) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += RectangleListBytes(buf[b:], Rectangles) + return buf } -// PolyText8Cookie is a cookie used only for PolyText8 requests. -type PolyText8Cookie struct { +// PolySegmentCookie is a cookie used only for PolySegment requests. +type PolySegmentCookie struct { *xgb.Cookie } -// PolyText8 sends an unchecked request. +// PolySegment sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { +func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} } -// PolyText8Checked sends a checked request. -// If an error occurs, it can be retrieved using PolyText8Cookie.Check() -func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { +// PolySegmentChecked sends a checked request. +// If an error occurs, it can be retrieved using PolySegmentCookie.Check() +func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{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 PolyText8Cookie) Check() error { +func (cook PolySegmentCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyText8 -// polyText8Request writes a PolyText8 request to a byte slice. -func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +// Write request to wire for PolySegment +// polySegmentRequest writes a PolySegment request to a byte slice. +func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) b := 0 buf := make([]byte, size) - buf[b] = 74 // request opcode + buf[b] = 66 // request opcode b += 1 b += 1 // padding @@ -11542,14 +12334,7 @@ func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y in xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], Items[:len(Items)]) - b += xgb.Pad(int(len(Items))) + b += SegmentListBytes(buf[b:], Segments) return buf } @@ -11614,45 +12399,44 @@ func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y i return buf } -// ImageText8Cookie is a cookie used only for ImageText8 requests. -type ImageText8Cookie struct { +// PolyText8Cookie is a cookie used only for PolyText8 requests. +type PolyText8Cookie struct { *xgb.Cookie } -// ImageText8 sends an unchecked request. +// PolyText8 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { +func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { cookie := c.NewCookie(false, false) - c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} } -// ImageText8Checked sends a checked request. -// If an error occurs, it can be retrieved using ImageText8Cookie.Check() -func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { +// PolyText8Checked sends a checked request. +// If an error occurs, it can be retrieved using PolyText8Cookie.Check() +func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { cookie := c.NewCookie(true, false) - c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{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 ImageText8Cookie) Check() error { +func (cook PolyText8Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ImageText8 -// imageText8Request writes a ImageText8 request to a byte slice. -func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { - size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) +// Write request to wire for PolyText8 +// polyText8Request writes a PolyText8 request to a byte slice. +func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 76 // request opcode + buf[b] = 74 // request opcode b += 1 - buf[b] = StringLen - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -11669,50 +12453,50 @@ func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gconte xgb.Put16(buf[b:], uint16(Y)) b += 2 - copy(buf[b:], String[:StringLen]) - b += xgb.Pad(int(StringLen)) + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) return buf } -// ImageText16Cookie is a cookie used only for ImageText16 requests. -type ImageText16Cookie struct { +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { *xgb.Cookie } -// ImageText16 sends an unchecked request. +// PutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { +func PutImage(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { cookie := c.NewCookie(false, false) - c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{cookie} } -// ImageText16Checked sends a checked request. -// If an error occurs, it can be retrieved using ImageText16Cookie.Check() -func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() +func PutImageChecked(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { cookie := c.NewCookie(true, false) - c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{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 ImageText16Cookie) Check() error { +func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ImageText16 -// imageText16Request writes a ImageText16 request to a byte slice. -func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { - size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) +// Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. +func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 77 // request opcode + buf[b] = 72 // request opcode b += 1 - buf[b] = StringLen + buf[b] = Format b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -11724,300 +12508,157 @@ func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcont xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], uint16(X)) + xgb.Put16(buf[b:], Width) b += 2 - xgb.Put16(buf[b:], uint16(Y)) + xgb.Put16(buf[b:], Height) b += 2 - b += Char2bListBytes(buf[b:], String) - - return buf -} - -// CreateColormapCookie is a cookie used only for CreateColormap requests. -type CreateColormapCookie struct { - *xgb.Cookie -} - -// CreateColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} -} - -// CreateColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateColormapCookie.Check() -func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{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 CreateColormapCookie) Check() error { - return cook.Cookie.Check() -} + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 -// Write request to wire for CreateColormap -// createColormapRequest writes a CreateColormap request to a byte slice. -func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { - size := 16 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 - buf[b] = 78 // request opcode + buf[b] = LeftPad b += 1 - buf[b] = Alloc + buf[b] = Depth b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Mid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 + b += 2 // padding - xgb.Put32(buf[b:], uint32(Visual)) - b += 4 + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) return buf } -// FreeColormapCookie is a cookie used only for FreeColormap requests. -type FreeColormapCookie struct { +// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. +type QueryBestSizeCookie struct { *xgb.Cookie } -// FreeColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{cookie} -} - -// FreeColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeColormapCookie.Check() -func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{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 FreeColormapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FreeColormap -// freeColormapRequest writes a FreeColormap request to a byte slice. -func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 79 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. -type CopyColormapAndFreeCookie struct { - *xgb.Cookie +// QueryBestSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() +func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} } -// CopyColormapAndFree sends an unchecked request. +// QueryBestSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} +func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} } -// CopyColormapAndFreeChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() -func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} +// QueryBestSizeReply represents the data returned from a QueryBestSize request. +type QueryBestSizeReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Width uint16 + Height uint16 } -// 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 CopyColormapAndFreeCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a QueryBestSize request. +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryBestSizeReply(buf), nil } -// Write request to wire for CopyColormapAndFree -// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. -func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 80 // request opcode - b += 1 +// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. +func queryBestSizeReply(buf []byte) *QueryBestSizeReply { + v := new(QueryBestSizeReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Mid)) - b += 4 - - xgb.Put32(buf[b:], uint32(SrcCmap)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} - -// InstallColormapCookie is a cookie used only for InstallColormap requests. -type InstallColormapCookie struct { - *xgb.Cookie -} - -// InstallColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} -} + v.Width = xgb.Get16(buf[b:]) + b += 2 -// InstallColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using InstallColormapCookie.Check() -func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} -} + v.Height = xgb.Get16(buf[b:]) + b += 2 -// 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 InstallColormapCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for InstallColormap -// installColormapRequest writes a InstallColormap request to a byte slice. -func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 +// Write request to wire for QueryBestSize +// queryBestSizeRequest writes a QueryBestSize request to a byte slice. +func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 81 // request opcode + buf[b] = 97 // request opcode b += 1 - b += 1 // padding + buf[b] = Class + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - return buf -} - -// UninstallColormapCookie is a cookie used only for UninstallColormap requests. -type UninstallColormapCookie struct { - *xgb.Cookie -} - -// UninstallColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -// UninstallColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using UninstallColormapCookie.Check() -func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{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 UninstallColormapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for UninstallColormap -// uninstallColormapRequest writes a UninstallColormap request to a byte slice. -func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 82 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Width) b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 + xgb.Put16(buf[b:], Height) + b += 2 return buf } -// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. -type ListInstalledColormapsCookie struct { +// QueryColorsCookie is a cookie used only for QueryColors requests. +type QueryColorsCookie struct { *xgb.Cookie } -// ListInstalledColormaps sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListInstalledColormapsCookie.Reply() -func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { +// QueryColors sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryColorsCookie.Reply() +func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { cookie := c.NewCookie(true, true) - c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) - return ListInstalledColormapsCookie{cookie} + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} } -// ListInstalledColormapsUnchecked sends an unchecked request. +// QueryColorsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { +func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) - return ListInstalledColormapsCookie{cookie} + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} } -// ListInstalledColormapsReply represents the data returned from a ListInstalledColormaps request. -type ListInstalledColormapsReply struct { +// QueryColorsReply represents the data returned from a QueryColors request. +type QueryColorsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - CmapsLen uint16 + ColorsLen uint16 // padding: 22 bytes - Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) + Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) } -// Reply blocks and returns the reply data for a ListInstalledColormaps request. -func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { +// Reply blocks and returns the reply data for a QueryColors request. +func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12025,12 +12666,12 @@ func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, if buf == nil { return nil, nil } - return listInstalledColormapsReply(buf), nil + return queryColorsReply(buf), nil } -// listInstalledColormapsReply reads a byte slice into a ListInstalledColormapsReply value. -func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { - v := new(ListInstalledColormapsReply) +// queryColorsReply reads a byte slice into a QueryColorsReply value. +func queryColorsReply(buf []byte) *QueryColorsReply { + v := new(QueryColorsReply) b := 1 // skip reply determinant b += 1 // padding @@ -12041,29 +12682,25 @@ func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.CmapsLen = xgb.Get16(buf[b:]) + v.ColorsLen = xgb.Get16(buf[b:]) b += 2 b += 22 // padding - v.Cmaps = make([]Colormap, v.CmapsLen) - for i := 0; i < int(v.CmapsLen); i++ { - v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) + v.Colors = make([]Rgb, v.ColorsLen) + b += RgbReadList(buf[b:], v.Colors) return v } -// Write request to wire for ListInstalledColormaps -// listInstalledColormapsRequest writes a ListInstalledColormaps request to a byte slice. -func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for QueryColors +// queryColorsRequest writes a QueryColors request to a byte slice. +func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 83 // request opcode + buf[b] = 91 // request opcode b += 1 b += 1 // padding @@ -12071,47 +12708,52 @@ func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// AllocColorCookie is a cookie used only for AllocColor requests. -type AllocColorCookie struct { +// QueryExtensionCookie is a cookie used only for QueryExtension requests. +type QueryExtensionCookie struct { *xgb.Cookie } -// AllocColor sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocColorCookie.Reply() -func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { +// QueryExtension sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() +func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { cookie := c.NewCookie(true, true) - c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} } -// AllocColorUnchecked sends an unchecked request. +// QueryExtensionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { +func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} } -// AllocColorReply represents the data returned from a AllocColor request. -type AllocColorReply struct { +// QueryExtensionReply represents the data returned from a QueryExtension request. +type QueryExtensionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes - Pixel uint32 + Present bool + MajorOpcode byte + FirstEvent byte + FirstError byte } -// Reply blocks and returns the reply data for a AllocColor request. -func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { +// Reply blocks and returns the reply data for a QueryExtension request. +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12119,12 +12761,12 @@ func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { if buf == nil { return nil, nil } - return allocColorReply(buf), nil + return queryExtensionReply(buf), nil } -// allocColorReply reads a byte slice into a AllocColorReply value. -func allocColorReply(buf []byte) *AllocColorReply { - v := new(AllocColorReply) +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) b := 1 // skip reply determinant b += 1 // padding @@ -12135,31 +12777,33 @@ func allocColorReply(buf []byte) *AllocColorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 - v.Blue = xgb.Get16(buf[b:]) - b += 2 + v.MajorOpcode = buf[b] + b += 1 - b += 2 // padding + v.FirstEvent = buf[b] + b += 1 - v.Pixel = xgb.Get32(buf[b:]) - b += 4 + v.FirstError = buf[b] + b += 1 return v } -// Write request to wire for AllocColor -// allocColorRequest writes a AllocColor request to a byte slice. -func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { - size := 16 +// Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. +func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 84 // request opcode + buf[b] = 98 // request opcode b += 1 b += 1 // padding @@ -12167,60 +12811,64 @@ func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blu xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put16(buf[b:], Red) - b += 2 - - xgb.Put16(buf[b:], Green) - b += 2 - - xgb.Put16(buf[b:], Blue) + xgb.Put16(buf[b:], NameLen) b += 2 b += 2 // padding + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + return buf } -// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. -type AllocNamedColorCookie struct { +// QueryFontCookie is a cookie used only for QueryFont requests. +type QueryFontCookie struct { *xgb.Cookie } -// AllocNamedColor sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocNamedColorCookie.Reply() -func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { +// QueryFont sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFontCookie.Reply() +func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { cookie := c.NewCookie(true, true) - c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} } -// AllocNamedColorUnchecked sends an unchecked request. +// QueryFontUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { +func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} } -// AllocNamedColorReply represents the data returned from a AllocNamedColor request. -type AllocNamedColorReply struct { +// QueryFontReply represents the data returned from a QueryFont request. +type QueryFontReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Pixel uint32 - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + CharInfosLen uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) } -// Reply blocks and returns the reply data for a AllocNamedColor request. -func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { +// Reply blocks and returns the reply data for a QueryFont request. +func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12228,12 +12876,12 @@ func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { if buf == nil { return nil, nil } - return allocNamedColorReply(buf), nil + return queryFontReply(buf), nil } -// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. -func allocNamedColorReply(buf []byte) *AllocNamedColorReply { - v := new(AllocNamedColorReply) +// queryFontReply reads a byte slice into a QueryFontReply value. +func queryFontReply(buf []byte) *QueryFontReply { + v := new(QueryFontReply) b := 1 // skip reply determinant b += 1 // padding @@ -12244,38 +12892,70 @@ func allocNamedColorReply(buf []byte) *AllocNamedColorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Pixel = xgb.Get32(buf[b:]) - b += 4 + v.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) - v.ExactRed = xgb.Get16(buf[b:]) + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = xgb.Get16(buf[b:]) b += 2 - v.ExactGreen = xgb.Get16(buf[b:]) + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) b += 2 - v.ExactBlue = xgb.Get16(buf[b:]) + v.DefaultChar = xgb.Get16(buf[b:]) b += 2 - v.VisualRed = xgb.Get16(buf[b:]) + v.PropertiesLen = xgb.Get16(buf[b:]) b += 2 - v.VisualGreen = xgb.Get16(buf[b:]) + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(xgb.Get16(buf[b:])) b += 2 - v.VisualBlue = xgb.Get16(buf[b:]) + v.FontDescent = int16(xgb.Get16(buf[b:])) b += 2 + v.CharInfosLen = xgb.Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) + + v.CharInfos = make([]Charinfo, v.CharInfosLen) + b += CharinfoReadList(buf[b:], v.CharInfos) + return v } -// Write request to wire for AllocNamedColor -// allocNamedColorRequest writes a AllocNamedColor request to a byte slice. -func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for QueryFont +// queryFontRequest writes a QueryFont request to a byte slice. +func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 85 // request opcode + buf[b] = 47 // request opcode b += 1 b += 1 // padding @@ -12283,55 +12963,43 @@ func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name str xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Font)) b += 4 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - return buf } -// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. -type AllocColorCellsCookie struct { +// QueryKeymapCookie is a cookie used only for QueryKeymap requests. +type QueryKeymapCookie struct { *xgb.Cookie } -// AllocColorCells sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocColorCellsCookie.Reply() -func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { +// QueryKeymap sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryKeymapCookie.Reply() +func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { cookie := c.NewCookie(true, true) - c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} } -// AllocColorCellsUnchecked sends an unchecked request. +// QueryKeymapUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { +func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} } -// AllocColorCellsReply represents the data returned from a AllocColorCells request. -type AllocColorCellsReply struct { +// QueryKeymapReply represents the data returned from a QueryKeymap request. +type QueryKeymapReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - PixelsLen uint16 - MasksLen uint16 - // padding: 20 bytes - Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) - Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) + Keys []byte // size: 32 } -// Reply blocks and returns the reply data for a AllocColorCells request. -func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { +// Reply blocks and returns the reply data for a QueryKeymap request. +func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12339,12 +13007,12 @@ func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { if buf == nil { return nil, nil } - return allocColorCellsReply(buf), nil + return queryKeymapReply(buf), nil } -// allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. -func allocColorCellsReply(buf []byte) *AllocColorCellsReply { - v := new(AllocColorCellsReply) +// queryKeymapReply reads a byte slice into a QueryKeymapReply value. +func queryKeymapReply(buf []byte) *QueryKeymapReply { + v := new(QueryKeymapReply) b := 1 // skip reply determinant b += 1 // padding @@ -12355,100 +13023,68 @@ func allocColorCellsReply(buf []byte) *AllocColorCellsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PixelsLen = xgb.Get16(buf[b:]) - b += 2 - - v.MasksLen = xgb.Get16(buf[b:]) - b += 2 - - b += 20 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - v.Masks = make([]uint32, v.MasksLen) - for i := 0; i < int(v.MasksLen); i++ { - v.Masks[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) return v } -// Write request to wire for AllocColorCells -// allocColorCellsRequest writes a AllocColorCells request to a byte slice. -func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { - size := 12 +// Write request to wire for QueryKeymap +// queryKeymapRequest writes a QueryKeymap request to a byte slice. +func queryKeymapRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 86 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } + buf[b] = 44 // request opcode b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put16(buf[b:], Colors) - b += 2 - - xgb.Put16(buf[b:], Planes) - b += 2 - return buf } -// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. -type AllocColorPlanesCookie struct { +// QueryPointerCookie is a cookie used only for QueryPointer requests. +type QueryPointerCookie struct { *xgb.Cookie } -// AllocColorPlanes sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocColorPlanesCookie.Reply() -func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { +// QueryPointer sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPointerCookie.Reply() +func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { cookie := c.NewCookie(true, true) - c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} } -// AllocColorPlanesUnchecked sends an unchecked request. +// QueryPointerUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { +func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} } -// AllocColorPlanesReply represents the data returned from a AllocColorPlanes request. -type AllocColorPlanesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - PixelsLen uint16 +// QueryPointerReply represents the data returned from a QueryPointer request. +type QueryPointerReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + SameScreen bool + Root Window + Child Window + RootX int16 + RootY int16 + WinX int16 + WinY int16 + Mask uint16 // padding: 2 bytes - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 8 bytes - Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) } -// Reply blocks and returns the reply data for a AllocColorPlanes request. -func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { +// Reply blocks and returns the reply data for a QueryPointer request. +func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12456,15 +13092,20 @@ func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { if buf == nil { return nil, nil } - return allocColorPlanesReply(buf), nil + return queryPointerReply(buf), nil } -// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. -func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { - v := new(AllocColorPlanesReply) +// queryPointerReply reads a byte slice into a QueryPointerReply value. +func queryPointerReply(buf []byte) *QueryPointerReply { + v := new(QueryPointerReply) b := 1 // skip reply determinant - b += 1 // padding + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -12472,162 +13113,40 @@ func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PixelsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.RedMask = xgb.Get32(buf[b:]) - b += 4 - - v.GreenMask = xgb.Get32(buf[b:]) - b += 4 - - v.BlueMask = xgb.Get32(buf[b:]) + v.Root = Window(xgb.Get32(buf[b:])) b += 4 - b += 8 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for AllocColorPlanes -// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. -func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 87 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) + v.Child = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], Colors) + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], Reds) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], Greens) + v.WinX = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], Blues) + v.WinY = int16(xgb.Get16(buf[b:])) b += 2 - return buf -} - -// FreeColorsCookie is a cookie used only for FreeColors requests. -type FreeColorsCookie struct { - *xgb.Cookie -} - -// FreeColors sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} -} - -// FreeColorsChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeColorsCookie.Check() -func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{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 FreeColorsCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FreeColors -// freeColorsRequest writes a FreeColors request to a byte slice. -func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 88 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Mask = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put32(buf[b:], PlaneMask) - b += 4 - - for i := 0; i < int(len(Pixels)); i++ { - xgb.Put32(buf[b:], Pixels[i]) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// StoreColorsCookie is a cookie used only for StoreColors requests. -type StoreColorsCookie struct { - *xgb.Cookie -} - -// StoreColors sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} - -// StoreColorsChecked sends a checked request. -// If an error occurs, it can be retrieved using StoreColorsCookie.Check() -func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} + b += 2 // padding -// 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 StoreColorsCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for StoreColors -// storeColorsRequest writes a StoreColors request to a byte slice. -func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) +// Write request to wire for QueryPointer +// queryPointerRequest writes a QueryPointer request to a byte slice. +func queryPointerRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 89 // request opcode + buf[b] = 38 // request opcode b += 1 b += 1 // padding @@ -12635,107 +13154,49 @@ func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - b += ColoritemListBytes(buf[b:], Items) - - return buf -} - -// StoreNamedColorCookie is a cookie used only for StoreNamedColor requests. -type StoreNamedColorCookie struct { - *xgb.Cookie -} - -// StoreNamedColor sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{cookie} -} - -// StoreNamedColorChecked sends a checked request. -// If an error occurs, it can be retrieved using StoreNamedColorCookie.Check() -func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{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 StoreNamedColorCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for StoreNamedColor -// storeNamedColorRequest writes a StoreNamedColor request to a byte slice. -func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { - size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 90 // request opcode - b += 1 - - buf[b] = Flags - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put32(buf[b:], Pixel) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - return buf } -// QueryColorsCookie is a cookie used only for QueryColors requests. -type QueryColorsCookie struct { +// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. +type QueryTextExtentsCookie struct { *xgb.Cookie } -// QueryColors sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryColorsCookie.Reply() -func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { +// QueryTextExtents sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryTextExtentsCookie.Reply() +func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} } -// QueryColorsUnchecked sends an unchecked request. +// QueryTextExtentsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { +func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} } -// QueryColorsReply represents the data returned from a QueryColors request. -type QueryColorsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ColorsLen uint16 - // padding: 22 bytes - Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) +// QueryTextExtentsReply represents the data returned from a QueryTextExtents request. +type QueryTextExtentsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + DrawDirection byte + FontAscent int16 + FontDescent int16 + OverallAscent int16 + OverallDescent int16 + OverallWidth int32 + OverallLeft int32 + OverallRight int32 } -// Reply blocks and returns the reply data for a QueryColors request. -func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { +// Reply blocks and returns the reply data for a QueryTextExtents request. +func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12743,15 +13204,16 @@ func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { if buf == nil { return nil, nil } - return queryColorsReply(buf), nil + return queryTextExtentsReply(buf), nil } -// queryColorsReply reads a byte slice into a QueryColorsReply value. -func queryColorsReply(buf []byte) *QueryColorsReply { - v := new(QueryColorsReply) +// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. +func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { + v := new(QueryTextExtentsReply) b := 1 // skip reply determinant - b += 1 // padding + v.DrawDirection = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -12759,80 +13221,91 @@ func queryColorsReply(buf []byte) *QueryColorsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ColorsLen = xgb.Get16(buf[b:]) + v.FontAscent = int16(xgb.Get16(buf[b:])) b += 2 - b += 22 // padding + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 - v.Colors = make([]Rgb, v.ColorsLen) - b += RgbReadList(buf[b:], v.Colors) + v.OverallAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallWidth = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallLeft = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallRight = int32(xgb.Get32(buf[b:])) + b += 4 return v } -// Write request to wire for QueryColors -// queryColorsRequest writes a QueryColors request to a byte slice. -func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) +// Write request to wire for QueryTextExtents +// queryTextExtentsRequest writes a QueryTextExtents request to a byte slice. +func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { + size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) b := 0 buf := make([]byte, size) - buf[b] = 91 // request opcode + buf[b] = 48 // request opcode b += 1 - b += 1 // padding + buf[b] = byte((int(StringLen) & 1)) + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Font)) b += 4 - for i := 0; i < int(len(Pixels)); i++ { - xgb.Put32(buf[b:], Pixels[i]) - b += 4 - } - b = xgb.Pad(b) + b += Char2bListBytes(buf[b:], String) + + // skip writing local field: StringLen (2) :: uint16 return buf } -// LookupColorCookie is a cookie used only for LookupColor requests. -type LookupColorCookie struct { +// QueryTreeCookie is a cookie used only for QueryTree requests. +type QueryTreeCookie struct { *xgb.Cookie } -// LookupColor sends a checked request. -// If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply() -func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { +// QueryTree sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryTreeCookie.Reply() +func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { cookie := c.NewCookie(true, true) - c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} } -// LookupColorUnchecked sends an unchecked request. +// QueryTreeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { +func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { cookie := c.NewCookie(false, true) - c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} } -// LookupColorReply represents the data returned from a LookupColor request. -type LookupColorReply struct { +// QueryTreeReply represents the data returned from a QueryTree request. +type QueryTreeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 + Root Window + Parent Window + ChildrenLen uint16 + // padding: 14 bytes + Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) } -// Reply blocks and returns the reply data for a LookupColor request. -func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { +// Reply blocks and returns the reply data for a QueryTree request. +func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12840,12 +13313,12 @@ func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { if buf == nil { return nil, nil } - return lookupColorReply(buf), nil + return queryTreeReply(buf), nil } -// lookupColorReply reads a byte slice into a LookupColorReply value. -func lookupColorReply(buf []byte) *LookupColorReply { - v := new(LookupColorReply) +// queryTreeReply reads a byte slice into a QueryTreeReply value. +func queryTreeReply(buf []byte) *QueryTreeReply { + v := new(QueryTreeReply) b := 1 // skip reply determinant b += 1 // padding @@ -12856,35 +13329,35 @@ func lookupColorReply(buf []byte) *LookupColorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ExactRed = xgb.Get16(buf[b:]) - b += 2 - - v.ExactGreen = xgb.Get16(buf[b:]) - b += 2 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - v.ExactBlue = xgb.Get16(buf[b:]) - b += 2 + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 - v.VisualRed = xgb.Get16(buf[b:]) + v.ChildrenLen = xgb.Get16(buf[b:]) b += 2 - v.VisualGreen = xgb.Get16(buf[b:]) - b += 2 + b += 14 // padding - v.VisualBlue = xgb.Get16(buf[b:]) - b += 2 + v.Children = make([]Window, v.ChildrenLen) + for i := 0; i < int(v.ChildrenLen); i++ { + v.Children[i] = Window(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for LookupColor -// lookupColorRequest writes a LookupColor request to a byte slice. -func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for QueryTree +// queryTreeRequest writes a QueryTree request to a byte slice. +func queryTreeRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 92 // request opcode + buf[b] = 15 // request opcode b += 1 b += 1 // padding @@ -12892,55 +13365,47 @@ func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - return buf } -// CreateCursorCookie is a cookie used only for CreateCursor requests. -type CreateCursorCookie struct { +// RecolorCursorCookie is a cookie used only for RecolorCursor requests. +type RecolorCursorCookie struct { *xgb.Cookie } -// CreateCursor sends an unchecked request. +// RecolorCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateCursor(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { +func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { cookie := c.NewCookie(false, false) - c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{cookie} } -// CreateCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateCursorCookie.Check() -func CreateCursorChecked(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { +// RecolorCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using RecolorCursorCookie.Check() +func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { cookie := c.NewCookie(true, false) - c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{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 CreateCursorCookie) Check() error { +func (cook RecolorCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateCursor -// createCursorRequest writes a CreateCursor request to a byte slice. -func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { - size := 32 +// Write request to wire for RecolorCursor +// recolorCursorRequest writes a RecolorCursor request to a byte slice. +func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { + size := 20 b := 0 buf := make([]byte, size) - buf[b] = 93 // request opcode + buf[b] = 96 // request opcode b += 1 b += 1 // padding @@ -12948,13 +13413,7 @@ func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, Fo xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mask)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 xgb.Put16(buf[b:], ForeRed) @@ -12975,50 +13434,44 @@ func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, Fo xgb.Put16(buf[b:], BackBlue) b += 2 - xgb.Put16(buf[b:], X) - b += 2 - - xgb.Put16(buf[b:], Y) - b += 2 - return buf } -// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. -type CreateGlyphCursorCookie struct { +// ReparentWindowCookie is a cookie used only for ReparentWindow requests. +type ReparentWindowCookie struct { *xgb.Cookie } -// CreateGlyphCursor sends an unchecked request. +// ReparentWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateGlyphCursor(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { +func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{cookie} } -// CreateGlyphCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateGlyphCursorCookie.Check() -func CreateGlyphCursorChecked(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { +// ReparentWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ReparentWindowCookie.Check() +func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { cookie := c.NewCookie(true, false) - c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{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 CreateGlyphCursorCookie) Check() error { +func (cook ReparentWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateGlyphCursor -// createGlyphCursorRequest writes a CreateGlyphCursor request to a byte slice. -func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { - size := 32 +// Write request to wire for ReparentWindow +// reparentWindowRequest writes a ReparentWindow request to a byte slice. +func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 94 // request opcode + buf[b] = 7 // request opcode b += 1 b += 1 // padding @@ -13026,77 +13479,56 @@ func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(SourceFont)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(MaskFont)) + xgb.Put32(buf[b:], uint32(Parent)) b += 4 - xgb.Put16(buf[b:], SourceChar) - b += 2 - - xgb.Put16(buf[b:], MaskChar) - b += 2 - - xgb.Put16(buf[b:], ForeRed) - b += 2 - - xgb.Put16(buf[b:], ForeGreen) - b += 2 - - xgb.Put16(buf[b:], ForeBlue) - b += 2 - - xgb.Put16(buf[b:], BackRed) - b += 2 - - xgb.Put16(buf[b:], BackGreen) + xgb.Put16(buf[b:], uint16(X)) b += 2 - xgb.Put16(buf[b:], BackBlue) + xgb.Put16(buf[b:], uint16(Y)) b += 2 return buf } -// FreeCursorCookie is a cookie used only for FreeCursor requests. -type FreeCursorCookie struct { +// RotatePropertiesCookie is a cookie used only for RotateProperties requests. +type RotatePropertiesCookie struct { *xgb.Cookie } -// FreeCursor sends an unchecked request. +// RotateProperties sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { +func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(freeCursorRequest(c, Cursor), cookie) - return FreeCursorCookie{cookie} + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} } -// FreeCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeCursorCookie.Check() -func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { +// RotatePropertiesChecked sends a checked request. +// If an error occurs, it can be retrieved using RotatePropertiesCookie.Check() +func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { cookie := c.NewCookie(true, false) - c.NewRequest(freeCursorRequest(c, Cursor), cookie) - return FreeCursorCookie{cookie} + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{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 FreeCursorCookie) Check() error { +func (cook RotatePropertiesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FreeCursor -// freeCursorRequest writes a FreeCursor request to a byte slice. -func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { - size := 8 +// Write request to wire for RotateProperties +// rotatePropertiesRequest writes a RotateProperties request to a byte slice. +func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { + size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 95 // request opcode + buf[b] = 114 // request opcode b += 1 b += 1 // padding @@ -13104,489 +13536,324 @@ func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put16(buf[b:], AtomsLen) + b += 2 + + xgb.Put16(buf[b:], uint16(Delta)) + b += 2 + + for i := 0; i < int(AtomsLen); i++ { + xgb.Put32(buf[b:], uint32(Atoms[i])) + b += 4 + } + b = xgb.Pad(b) + return buf } -// RecolorCursorCookie is a cookie used only for RecolorCursor requests. -type RecolorCursorCookie struct { +// SendEventCookie is a cookie used only for SendEvent requests. +type SendEventCookie struct { *xgb.Cookie } -// RecolorCursor sends an unchecked request. +// SendEvent sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { +func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { cookie := c.NewCookie(false, false) - c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{cookie} } -// RecolorCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using RecolorCursorCookie.Check() -func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { +// SendEventChecked sends a checked request. +// If an error occurs, it can be retrieved using SendEventCookie.Check() +func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { cookie := c.NewCookie(true, false) - c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{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 RecolorCursorCookie) Check() error { +func (cook SendEventCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RecolorCursor -// recolorCursorRequest writes a RecolorCursor request to a byte slice. -func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { - size := 20 +// Write request to wire for SendEvent +// sendEventRequest writes a SendEvent request to a byte slice. +func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { + size := 44 b := 0 buf := make([]byte, size) - buf[b] = 96 // request opcode + buf[b] = 25 // request opcode b += 1 - b += 1 // padding + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - xgb.Put16(buf[b:], ForeRed) - b += 2 - - xgb.Put16(buf[b:], ForeGreen) - b += 2 - - xgb.Put16(buf[b:], ForeBlue) - b += 2 - - xgb.Put16(buf[b:], BackRed) - b += 2 - - xgb.Put16(buf[b:], BackGreen) - b += 2 + xgb.Put32(buf[b:], EventMask) + b += 4 - xgb.Put16(buf[b:], BackBlue) - b += 2 + copy(buf[b:], Event[:32]) + b += xgb.Pad(int(32)) return buf } -// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. -type QueryBestSizeCookie struct { +// SetAccessControlCookie is a cookie used only for SetAccessControl requests. +type SetAccessControlCookie struct { *xgb.Cookie } -// QueryBestSize sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() -func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -// QueryBestSizeUnchecked sends an unchecked request. +// SetAccessControl sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -// QueryBestSizeReply represents the data returned from a QueryBestSize request. -type QueryBestSizeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Width uint16 - Height uint16 +func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} } -// Reply blocks and returns the reply data for a QueryBestSize request. -func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryBestSizeReply(buf), nil +// SetAccessControlChecked sends a checked request. +// If an error occurs, it can be retrieved using SetAccessControlCookie.Check() +func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} } -// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. -func queryBestSizeReply(buf []byte) *QueryBestSizeReply { - v := new(QueryBestSizeReply) - 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.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - 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 SetAccessControlCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryBestSize -// queryBestSizeRequest writes a QueryBestSize request to a byte slice. -func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 12 +// Write request to wire for SetAccessControl +// setAccessControlRequest writes a SetAccessControl request to a byte slice. +func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 97 // request opcode + buf[b] = 111 // request opcode b += 1 - buf[b] = Class + buf[b] = Mode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - return buf } -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { +// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. +type SetClipRectanglesCookie struct { *xgb.Cookie } -// QueryExtension sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() -func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -// QueryExtensionUnchecked sends an unchecked request. +// SetClipRectangles sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -// QueryExtensionReply represents the data returned from a QueryExtension request. -type QueryExtensionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Present bool - MajorOpcode byte - FirstEvent byte - FirstError byte +func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} } -// Reply blocks and returns the reply data for a QueryExtension request. -func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryExtensionReply(buf), nil +// SetClipRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() +func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} } -// queryExtensionReply reads a byte slice into a QueryExtensionReply value. -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) - 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.Present = true - } else { - v.Present = false - } - b += 1 - - v.MajorOpcode = buf[b] - b += 1 - - v.FirstEvent = buf[b] - b += 1 - - v.FirstError = buf[b] - 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 SetClipRectanglesCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryExtension -// queryExtensionRequest writes a QueryExtension request to a byte slice. -func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for SetClipRectangles +// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. +func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) - buf[b] = 98 // request opcode + buf[b] = 59 // request opcode b += 1 - b += 1 // padding + buf[b] = Ordering + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], NameLen) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(ClipXOrigin)) b += 2 - b += 2 // padding + xgb.Put16(buf[b:], uint16(ClipYOrigin)) + b += 2 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += RectangleListBytes(buf[b:], Rectangles) return buf } -// ListExtensionsCookie is a cookie used only for ListExtensions requests. -type ListExtensionsCookie struct { +// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. +type SetCloseDownModeCookie struct { *xgb.Cookie } -// ListExtensions sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListExtensionsCookie.Reply() -func ListExtensions(c *xgb.Conn) ListExtensionsCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(listExtensionsRequest(c), cookie) - return ListExtensionsCookie{cookie} -} - -// ListExtensionsUnchecked sends an unchecked request. +// SetCloseDownMode sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(listExtensionsRequest(c), cookie) - return ListExtensionsCookie{cookie} -} - -// ListExtensionsReply represents the data returned from a ListExtensions request. -type ListExtensionsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - NamesLen byte - // padding: 24 bytes - Names []Str // size: StrListSize(Names) +func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} } -// Reply blocks and returns the reply data for a ListExtensions request. -func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listExtensionsReply(buf), nil +// SetCloseDownModeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCloseDownModeCookie.Check() +func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} } -// listExtensionsReply reads a byte slice into a ListExtensionsReply value. -func listExtensionsReply(buf []byte) *ListExtensionsReply { - v := new(ListExtensionsReply) - b := 1 // skip reply determinant - - v.NamesLen = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Names = make([]Str, v.NamesLen) - b += StrReadList(buf[b:], v.Names) - - 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 SetCloseDownModeCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for ListExtensions -// listExtensionsRequest writes a ListExtensions request to a byte slice. -func listExtensionsRequest(c *xgb.Conn) []byte { +// Write request to wire for SetCloseDownMode +// setCloseDownModeRequest writes a SetCloseDownMode request to a byte slice. +func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 99 // request opcode + buf[b] = 112 // request opcode + b += 1 + + buf[b] = Mode b += 1 - b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 return buf } -// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. -type ChangeKeyboardMappingCookie struct { +// SetDashesCookie is a cookie used only for SetDashes requests. +type SetDashesCookie struct { *xgb.Cookie } -// ChangeKeyboardMapping sends an unchecked request. +// SetDashes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { +func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{cookie} } -// ChangeKeyboardMappingChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() -func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { +// SetDashesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDashesCookie.Check() +func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{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 ChangeKeyboardMappingCookie) Check() error { +func (cook SetDashesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeKeyboardMapping -// changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice. -func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { - size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +// Write request to wire for SetDashes +// setDashesRequest writes a SetDashes request to a byte slice. +func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 100 // request opcode + buf[b] = 58 // request opcode b += 1 - buf[b] = KeycodeCount - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = byte(FirstKeycode) - b += 1 + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - buf[b] = KeysymsPerKeycode - b += 1 + xgb.Put16(buf[b:], DashOffset) + b += 2 - b += 2 // padding + xgb.Put16(buf[b:], DashesLen) + b += 2 - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - xgb.Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = xgb.Pad(b) + copy(buf[b:], Dashes[:DashesLen]) + b += xgb.Pad(int(DashesLen)) return buf } -// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. -type GetKeyboardMappingCookie struct { +// SetFontPathCookie is a cookie used only for SetFontPath requests. +type SetFontPathCookie struct { *xgb.Cookie } -// GetKeyboardMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetKeyboardMappingCookie.Reply() -func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -// GetKeyboardMappingUnchecked sends an unchecked request. +// SetFontPath sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -// GetKeyboardMappingReply represents the data returned from a GetKeyboardMapping request. -type GetKeyboardMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - KeysymsPerKeycode byte - // padding: 24 bytes - Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) +func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} } -// Reply blocks and returns the reply data for a GetKeyboardMapping request. -func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardMappingReply(buf), nil +// SetFontPathChecked sends a checked request. +// If an error occurs, it can be retrieved using SetFontPathCookie.Check() +func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} } -// getKeyboardMappingReply reads a byte slice into a GetKeyboardMappingReply value. -func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { - v := new(GetKeyboardMappingReply) - b := 1 // skip reply determinant - - v.KeysymsPerKeycode = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keysyms = make([]Keysym, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - 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 SetFontPathCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetKeyboardMapping -// getKeyboardMappingRequest writes a GetKeyboardMapping request to a byte slice. -func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { - size := 8 +// Write request to wire for SetFontPath +// setFontPathRequest writes a SetFontPath request to a byte slice. +func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { + size := xgb.Pad((8 + StrListSize(Font))) b := 0 buf := make([]byte, size) - buf[b] = 101 // request opcode + buf[b] = 51 // request opcode b += 1 b += 1 // padding @@ -13594,105 +13861,98 @@ func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) [] xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = byte(FirstKeycode) - b += 1 + xgb.Put16(buf[b:], FontQty) + b += 2 - buf[b] = Count - b += 1 + b += 2 // padding + + b += StrListBytes(buf[b:], Font) return buf } -// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. -type ChangeKeyboardControlCookie struct { +// SetInputFocusCookie is a cookie used only for SetInputFocus requests. +type SetInputFocusCookie struct { *xgb.Cookie } -// ChangeKeyboardControl sends an unchecked request. +// SetInputFocus sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { +func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{cookie} } -// ChangeKeyboardControlChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeKeyboardControlCookie.Check() -func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { +// SetInputFocusChecked sends a checked request. +// If an error occurs, it can be retrieved using SetInputFocusCookie.Check() +func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{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 ChangeKeyboardControlCookie) Check() error { +func (cook SetInputFocusCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeKeyboardControl -// changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice. -func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for SetInputFocus +// setInputFocusRequest writes a SetInputFocus request to a byte slice. +func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 102 // request opcode + buf[b] = 42 // request opcode b += 1 - b += 1 // padding + buf[b] = RevertTo + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) return buf } -// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. -type GetKeyboardControlCookie struct { +// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. +type SetModifierMappingCookie struct { *xgb.Cookie } -// GetKeyboardControl sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() -func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { +// SetModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetModifierMappingCookie.Reply() +func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getKeyboardControlRequest(c), cookie) - return GetKeyboardControlCookie{cookie} + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} } -// GetKeyboardControlUnchecked sends an unchecked request. +// SetModifierMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { +func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getKeyboardControlRequest(c), cookie) - return GetKeyboardControlCookie{cookie} + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} } -// GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. -type GetKeyboardControlReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - GlobalAutoRepeat byte - LedMask uint32 - KeyClickPercent byte - BellPercent byte - BellPitch uint16 - BellDuration uint16 - // padding: 2 bytes - AutoRepeats []byte // size: 32 +// SetModifierMappingReply represents the data returned from a SetModifierMapping request. +type SetModifierMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte } -// Reply blocks and returns the reply data for a GetKeyboardControl request. -func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { +// Reply blocks and returns the reply data for a SetModifierMapping request. +func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -13700,15 +13960,15 @@ func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { if buf == nil { return nil, nil } - return getKeyboardControlReply(buf), nil + return setModifierMappingReply(buf), nil } -// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. -func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { - v := new(GetKeyboardControlReply) +// setModifierMappingReply reads a byte slice into a SetModifierMappingReply value. +func setModifierMappingReply(buf []byte) *SetModifierMappingReply { + v := new(SetModifierMappingReply) b := 1 // skip reply determinant - v.GlobalAutoRepeat = buf[b] + v.Status = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -13717,195 +13977,64 @@ func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.LedMask = xgb.Get32(buf[b:]) - b += 4 - - v.KeyClickPercent = buf[b] - b += 1 - - v.BellPercent = buf[b] - b += 1 - - v.BellPitch = xgb.Get16(buf[b:]) - b += 2 - - v.BellDuration = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += xgb.Pad(int(32)) - return v } -// Write request to wire for GetKeyboardControl -// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. -func getKeyboardControlRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 103 // request opcode - b += 1 - - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// BellCookie is a cookie used only for Bell requests. -type BellCookie struct { - *xgb.Cookie -} - -// Bell sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Bell(c *xgb.Conn, Percent int8) BellCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(bellRequest(c, Percent), cookie) - return BellCookie{cookie} -} - -// BellChecked sends a checked request. -// If an error occurs, it can be retrieved using BellCookie.Check() -func BellChecked(c *xgb.Conn, Percent int8) BellCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(bellRequest(c, Percent), cookie) - return BellCookie{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 BellCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for Bell -// bellRequest writes a Bell request to a byte slice. -func bellRequest(c *xgb.Conn, Percent int8) []byte { - size := 4 +// Write request to wire for SetModifierMapping +// setModifierMappingRequest writes a SetModifierMapping request to a byte slice. +func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { + size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 104 // request opcode - b += 1 - - buf[b] = byte(Percent) + buf[b] = 118 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. -type ChangePointerControlCookie struct { - *xgb.Cookie -} - -// ChangePointerControl sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} -} - -// ChangePointerControlChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangePointerControlCookie.Check() -func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{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 ChangePointerControlCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ChangePointerControl -// changePointerControlRequest writes a ChangePointerControl request to a byte slice. -func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 105 // request opcode + buf[b] = KeycodesPerModifier b += 1 - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], uint16(AccelerationNumerator)) - b += 2 - - xgb.Put16(buf[b:], uint16(AccelerationDenominator)) - b += 2 - - xgb.Put16(buf[b:], uint16(Threshold)) - b += 2 - - if DoAcceleration { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if DoThreshold { - buf[b] = 1 - } else { - buf[b] = 0 + for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { + buf[b] = byte(Keycodes[i]) + b += 1 } - b += 1 + b = xgb.Pad(b) return buf } -// GetPointerControlCookie is a cookie used only for GetPointerControl requests. -type GetPointerControlCookie struct { +// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. +type SetPointerMappingCookie struct { *xgb.Cookie } -// GetPointerControl sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPointerControlCookie.Reply() -func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { +// SetPointerMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetPointerMappingCookie.Reply() +func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getPointerControlRequest(c), cookie) - return GetPointerControlCookie{cookie} + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} } -// GetPointerControlUnchecked sends an unchecked request. +// SetPointerMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { +func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getPointerControlRequest(c), cookie) - return GetPointerControlCookie{cookie} + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} } -// GetPointerControlReply represents the data returned from a GetPointerControl request. -type GetPointerControlReply struct { +// SetPointerMappingReply represents the data returned from a SetPointerMapping request. +type SetPointerMappingReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - // padding: 1 bytes - AccelerationNumerator uint16 - AccelerationDenominator uint16 - Threshold uint16 - // padding: 18 bytes + Status byte } -// Reply blocks and returns the reply data for a GetPointerControl request. -func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { +// Reply blocks and returns the reply data for a SetPointerMapping request. +func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -13913,15 +14042,16 @@ func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { if buf == nil { return nil, nil } - return getPointerControlReply(buf), nil + return setPointerMappingReply(buf), nil } -// getPointerControlReply reads a byte slice into a GetPointerControlReply value. -func getPointerControlReply(buf []byte) *GetPointerControlReply { - v := new(GetPointerControlReply) +// setPointerMappingReply reads a byte slice into a SetPointerMappingReply value. +func setPointerMappingReply(buf []byte) *SetPointerMappingReply { + v := new(SetPointerMappingReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -13929,34 +14059,28 @@ func getPointerControlReply(buf []byte) *GetPointerControlReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.AccelerationNumerator = xgb.Get16(buf[b:]) - b += 2 - - v.AccelerationDenominator = xgb.Get16(buf[b:]) - b += 2 - - v.Threshold = xgb.Get16(buf[b:]) - b += 2 - - b += 18 // padding - return v } -// Write request to wire for GetPointerControl -// getPointerControlRequest writes a GetPointerControl request to a byte slice. -func getPointerControlRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for SetPointerMapping +// setPointerMappingRequest writes a SetPointerMapping request to a byte slice. +func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { + size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 106 // request opcode + buf[b] = 116 // request opcode + b += 1 + + buf[b] = MapLen b += 1 - b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + copy(buf[b:], Map[:MapLen]) + b += xgb.Pad(int(MapLen)) + return buf } @@ -14017,188 +14141,203 @@ func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBla return buf } -// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. -type GetScreenSaverCookie struct { +// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. +type SetSelectionOwnerCookie struct { *xgb.Cookie } -// GetScreenSaver sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetScreenSaverCookie.Reply() -func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getScreenSaverRequest(c), cookie) - return GetScreenSaverCookie{cookie} -} - -// GetScreenSaverUnchecked sends an unchecked request. +// SetSelectionOwner sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getScreenSaverRequest(c), cookie) - return GetScreenSaverCookie{cookie} +func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} } -// GetScreenSaverReply represents the data returned from a GetScreenSaver request. -type GetScreenSaverReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Timeout uint16 - Interval uint16 - PreferBlanking byte - AllowExposures byte - // padding: 18 bytes +// SetSelectionOwnerChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionOwnerCookie.Check() +func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} } -// Reply blocks and returns the reply data for a GetScreenSaver request. -func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getScreenSaverReply(buf), nil +// 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 SetSelectionOwnerCookie) Check() error { + return cook.Cookie.Check() } -// getScreenSaverReply reads a byte slice into a GetScreenSaverReply value. -func getScreenSaverReply(buf []byte) *GetScreenSaverReply { - v := new(GetScreenSaverReply) - b := 1 // skip reply determinant +// Write request to wire for SetSelectionOwner +// setSelectionOwnerRequest writes a SetSelectionOwner request to a byte slice. +func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 22 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Owner)) b += 4 - v.Timeout = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 - v.Interval = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 - v.PreferBlanking = buf[b] - b += 1 + return buf +} - v.AllowExposures = buf[b] - b += 1 +// StoreColorsCookie is a cookie used only for StoreColors requests. +type StoreColorsCookie struct { + *xgb.Cookie +} - b += 18 // padding +// StoreColors sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} +} - return v +// StoreColorsChecked sends a checked request. +// If an error occurs, it can be retrieved using StoreColorsCookie.Check() +func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} } -// Write request to wire for GetScreenSaver -// getScreenSaverRequest writes a GetScreenSaver request to a byte slice. -func getScreenSaverRequest(c *xgb.Conn) []byte { - size := 4 +// 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 StoreColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StoreColors +// storeColorsRequest writes a StoreColors request to a byte slice. +func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) b := 0 buf := make([]byte, size) - buf[b] = 108 // request opcode + buf[b] = 89 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + b += ColoritemListBytes(buf[b:], Items) + return buf } -// ChangeHostsCookie is a cookie used only for ChangeHosts requests. -type ChangeHostsCookie struct { +// StoreNamedColorCookie is a cookie used only for StoreNamedColor requests. +type StoreNamedColorCookie struct { *xgb.Cookie } -// ChangeHosts sends an unchecked request. +// StoreNamedColor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { +func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{cookie} } -// ChangeHostsChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeHostsCookie.Check() -func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { +// StoreNamedColorChecked sends a checked request. +// If an error occurs, it can be retrieved using StoreNamedColorCookie.Check() +func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{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 ChangeHostsCookie) Check() error { +func (cook StoreNamedColorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeHosts -// changeHostsRequest writes a ChangeHosts request to a byte slice. -func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { - size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) +// Write request to wire for StoreNamedColor +// storeNamedColorRequest writes a StoreNamedColor request to a byte slice. +func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 109 // request opcode + buf[b] = 90 // request opcode b += 1 - buf[b] = Mode + buf[b] = Flags b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = Family - b += 1 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 - b += 1 // padding + xgb.Put32(buf[b:], Pixel) + b += 4 - xgb.Put16(buf[b:], AddressLen) + xgb.Put16(buf[b:], NameLen) b += 2 - copy(buf[b:], Address[:AddressLen]) - b += xgb.Pad(int(AddressLen)) + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// ListHostsCookie is a cookie used only for ListHosts requests. -type ListHostsCookie struct { +// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. +type TranslateCoordinatesCookie struct { *xgb.Cookie } -// ListHosts sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply() -func ListHosts(c *xgb.Conn) ListHostsCookie { +// TranslateCoordinates sends a checked request. +// If an error occurs, it will be returned with the reply by calling TranslateCoordinatesCookie.Reply() +func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { cookie := c.NewCookie(true, true) - c.NewRequest(listHostsRequest(c), cookie) - return ListHostsCookie{cookie} + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} } -// ListHostsUnchecked sends an unchecked request. +// TranslateCoordinatesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { +func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { cookie := c.NewCookie(false, true) - c.NewRequest(listHostsRequest(c), cookie) - return ListHostsCookie{cookie} + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} } -// ListHostsReply represents the data returned from a ListHosts request. -type ListHostsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Mode byte - HostsLen uint16 - // padding: 22 bytes - Hosts []Host // size: HostListSize(Hosts) +// TranslateCoordinatesReply represents the data returned from a TranslateCoordinates request. +type TranslateCoordinatesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + SameScreen bool + Child Window + DstX int16 + DstY int16 } -// Reply blocks and returns the reply data for a ListHosts request. -func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { +// Reply blocks and returns the reply data for a TranslateCoordinates request. +func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -14206,15 +14345,19 @@ func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { if buf == nil { return nil, nil } - return listHostsReply(buf), nil + return translateCoordinatesReply(buf), nil } -// listHostsReply reads a byte slice into a ListHostsReply value. -func listHostsReply(buf []byte) *ListHostsReply { - v := new(ListHostsReply) +// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. +func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { + v := new(TranslateCoordinatesReply) b := 1 // skip reply determinant - v.Mode = buf[b] + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -14223,161 +14366,191 @@ func listHostsReply(buf []byte) *ListHostsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.HostsLen = xgb.Get16(buf[b:]) - b += 2 + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 - b += 22 // padding + v.DstX = int16(xgb.Get16(buf[b:])) + b += 2 - v.Hosts = make([]Host, v.HostsLen) - b += HostReadList(buf[b:], v.Hosts) + v.DstY = int16(xgb.Get16(buf[b:])) + b += 2 return v } -// Write request to wire for ListHosts -// listHostsRequest writes a ListHosts request to a byte slice. -func listHostsRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for TranslateCoordinates +// translateCoordinatesRequest writes a TranslateCoordinates request to a byte slice. +func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 110 // request opcode + buf[b] = 40 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + return buf } -// SetAccessControlCookie is a cookie used only for SetAccessControl requests. -type SetAccessControlCookie struct { +// UngrabButtonCookie is a cookie used only for UngrabButton requests. +type UngrabButtonCookie struct { *xgb.Cookie } -// SetAccessControl sends an unchecked request. +// UngrabButton sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { +func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setAccessControlRequest(c, Mode), cookie) - return SetAccessControlCookie{cookie} + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{cookie} } -// SetAccessControlChecked sends a checked request. -// If an error occurs, it can be retrieved using SetAccessControlCookie.Check() -func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { +// UngrabButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabButtonCookie.Check() +func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(true, false) - c.NewRequest(setAccessControlRequest(c, Mode), cookie) - return SetAccessControlCookie{cookie} + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{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 SetAccessControlCookie) Check() error { +func (cook UngrabButtonCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetAccessControl -// setAccessControlRequest writes a SetAccessControl request to a byte slice. -func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { - size := 4 +// Write request to wire for UngrabButton +// ungrabButtonRequest writes a UngrabButton request to a byte slice. +func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 111 // request opcode + buf[b] = 29 // request opcode b += 1 - buf[b] = Mode + buf[b] = Button b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + return buf } -// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. -type SetCloseDownModeCookie struct { +// UngrabKeyCookie is a cookie used only for UngrabKey requests. +type UngrabKeyCookie struct { *xgb.Cookie } -// SetCloseDownMode sends an unchecked request. +// UngrabKey sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { +func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{cookie} + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} } -// SetCloseDownModeChecked sends a checked request. -// If an error occurs, it can be retrieved using SetCloseDownModeCookie.Check() -func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { +// UngrabKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabKeyCookie.Check() +func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(true, false) - c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{cookie} + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{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 SetCloseDownModeCookie) Check() error { +func (cook UngrabKeyCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetCloseDownMode -// setCloseDownModeRequest writes a SetCloseDownMode request to a byte slice. -func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { - size := 4 +// Write request to wire for UngrabKey +// ungrabKeyRequest writes a UngrabKey request to a byte slice. +func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 112 // request opcode + buf[b] = 34 // request opcode b += 1 - buf[b] = Mode + buf[b] = byte(Key) b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + return buf } -// KillClientCookie is a cookie used only for KillClient requests. -type KillClientCookie struct { +// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. +type UngrabKeyboardCookie struct { *xgb.Cookie } -// KillClient sends an unchecked request. +// UngrabKeyboard sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { +func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(false, false) - c.NewRequest(killClientRequest(c, Resource), cookie) - return KillClientCookie{cookie} + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{cookie} } -// KillClientChecked sends a checked request. -// If an error occurs, it can be retrieved using KillClientCookie.Check() -func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { +// UngrabKeyboardChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabKeyboardCookie.Check() +func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(true, false) - c.NewRequest(killClientRequest(c, Resource), cookie) - return KillClientCookie{cookie} + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{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 KillClientCookie) Check() error { +func (cook UngrabKeyboardCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for KillClient -// killClientRequest writes a KillClient request to a byte slice. -func killClientRequest(c *xgb.Conn, Resource uint32) []byte { +// Write request to wire for UngrabKeyboard +// ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice. +func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 113 // request opcode + buf[b] = 32 // request opcode b += 1 b += 1 // padding @@ -14385,47 +14558,47 @@ func killClientRequest(c *xgb.Conn, Resource uint32) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Resource) + xgb.Put32(buf[b:], uint32(Time)) b += 4 return buf } -// RotatePropertiesCookie is a cookie used only for RotateProperties requests. -type RotatePropertiesCookie struct { +// UngrabPointerCookie is a cookie used only for UngrabPointer requests. +type UngrabPointerCookie struct { *xgb.Cookie } -// RotateProperties sends an unchecked request. +// UngrabPointer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { +func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} } -// RotatePropertiesChecked sends a checked request. -// If an error occurs, it can be retrieved using RotatePropertiesCookie.Check() -func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { +// UngrabPointerChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPointerCookie.Check() +func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(true, false) - c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{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 RotatePropertiesCookie) Check() error { +func (cook UngrabPointerCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RotateProperties -// rotatePropertiesRequest writes a RotateProperties request to a byte slice. -func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { - size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) +// Write request to wire for UngrabPointer +// ungrabPointerRequest writes a UngrabPointer request to a byte slice. +func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 114 // request opcode + buf[b] = 27 // request opcode b += 1 b += 1 // padding @@ -14433,437 +14606,264 @@ func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Time)) b += 4 - xgb.Put16(buf[b:], AtomsLen) - b += 2 - - xgb.Put16(buf[b:], uint16(Delta)) - b += 2 - - for i := 0; i < int(AtomsLen); i++ { - xgb.Put32(buf[b:], uint32(Atoms[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. -type ForceScreenSaverCookie struct { +// UngrabServerCookie is a cookie used only for UngrabServer requests. +type UngrabServerCookie struct { *xgb.Cookie } -// ForceScreenSaver sends an unchecked request. +// UngrabServer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { +func UngrabServer(c *xgb.Conn) UngrabServerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{cookie} + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{cookie} } -// ForceScreenSaverChecked sends a checked request. -// If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check() -func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { +// UngrabServerChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabServerCookie.Check() +func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { cookie := c.NewCookie(true, false) - c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{cookie} + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{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 ForceScreenSaverCookie) Check() error { +func (cook UngrabServerCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ForceScreenSaver -// forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice. -func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { +// Write request to wire for UngrabServer +// ungrabServerRequest writes a UngrabServer request to a byte slice. +func ungrabServerRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 115 // request opcode - b += 1 - - buf[b] = Mode + buf[b] = 37 // request opcode b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 return buf } -// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. -type SetPointerMappingCookie struct { +// UninstallColormapCookie is a cookie used only for UninstallColormap requests. +type UninstallColormapCookie struct { *xgb.Cookie } -// SetPointerMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetPointerMappingCookie.Reply() -func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -// SetPointerMappingUnchecked sends an unchecked request. +// UninstallColormap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -// SetPointerMappingReply represents the data returned from a SetPointerMapping request. -type SetPointerMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte +func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} } -// Reply blocks and returns the reply data for a SetPointerMapping request. -func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setPointerMappingReply(buf), nil +// UninstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using UninstallColormapCookie.Check() +func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} } -// setPointerMappingReply reads a byte slice into a SetPointerMappingReply value. -func setPointerMappingReply(buf []byte) *SetPointerMappingReply { - v := new(SetPointerMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - 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 UninstallColormapCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for SetPointerMapping -// setPointerMappingRequest writes a SetPointerMapping request to a byte slice. -func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { - size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) +// Write request to wire for UninstallColormap +// uninstallColormapRequest writes a UninstallColormap request to a byte slice. +func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 116 // request opcode + buf[b] = 82 // request opcode b += 1 - buf[b] = MapLen - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - copy(buf[b:], Map[:MapLen]) - b += xgb.Pad(int(MapLen)) + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 return buf } -// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. -type GetPointerMappingCookie struct { +// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. +type UnmapSubwindowsCookie struct { *xgb.Cookie } -// GetPointerMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPointerMappingCookie.Reply() -func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getPointerMappingRequest(c), cookie) - return GetPointerMappingCookie{cookie} -} - -// GetPointerMappingUnchecked sends an unchecked request. +// UnmapSubwindows sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getPointerMappingRequest(c), cookie) - return GetPointerMappingCookie{cookie} -} - -// GetPointerMappingReply represents the data returned from a GetPointerMapping request. -type GetPointerMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - MapLen byte - // padding: 24 bytes - Map []byte // size: xgb.Pad((int(MapLen) * 1)) +func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} } -// Reply blocks and returns the reply data for a GetPointerMapping request. -func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPointerMappingReply(buf), nil +// UnmapSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnmapSubwindowsCookie.Check() +func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} } -// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. -func getPointerMappingReply(buf []byte) *GetPointerMappingReply { - v := new(GetPointerMappingReply) - b := 1 // skip reply determinant - - v.MapLen = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Map = make([]byte, v.MapLen) - copy(v.Map[:v.MapLen], buf[b:]) - b += xgb.Pad(int(v.MapLen)) - - 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 UnmapSubwindowsCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetPointerMapping -// getPointerMappingRequest writes a GetPointerMapping request to a byte slice. -func getPointerMappingRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for UnmapSubwindows +// unmapSubwindowsRequest writes a UnmapSubwindows request to a byte slice. +func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 117 // request opcode + buf[b] = 11 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + 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 } -// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. -type SetModifierMappingCookie struct { +// UnmapWindowCookie is a cookie used only for UnmapWindow requests. +type UnmapWindowCookie struct { *xgb.Cookie } -// SetModifierMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetModifierMappingCookie.Reply() -func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -// SetModifierMappingUnchecked sends an unchecked request. +// UnmapWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -// SetModifierMappingReply represents the data returned from a SetModifierMapping request. -type SetModifierMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte +func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} } -// Reply blocks and returns the reply data for a SetModifierMapping request. -func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setModifierMappingReply(buf), nil +// UnmapWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using UnmapWindowCookie.Check() +func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} } -// setModifierMappingReply reads a byte slice into a SetModifierMappingReply value. -func setModifierMappingReply(buf []byte) *SetModifierMappingReply { - v := new(SetModifierMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - 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 UnmapWindowCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for SetModifierMapping -// setModifierMappingRequest writes a SetModifierMapping request to a byte slice. -func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { - size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +// Write request to wire for UnmapWindow +// unmapWindowRequest writes a UnmapWindow request to a byte slice. +func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 118 // request opcode + buf[b] = 10 // request opcode b += 1 - buf[b] = KeycodesPerModifier - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { - buf[b] = byte(Keycodes[i]) - b += 1 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(Window)) + b += 4 return buf } -// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. -type GetModifierMappingCookie struct { +// WarpPointerCookie is a cookie used only for WarpPointer requests. +type WarpPointerCookie struct { *xgb.Cookie } -// GetModifierMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetModifierMappingCookie.Reply() -func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getModifierMappingRequest(c), cookie) - return GetModifierMappingCookie{cookie} -} - -// GetModifierMappingUnchecked sends an unchecked request. +// WarpPointer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getModifierMappingRequest(c), cookie) - return GetModifierMappingCookie{cookie} -} - -// GetModifierMappingReply represents the data returned from a GetModifierMapping request. -type GetModifierMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - KeycodesPerModifier byte - // padding: 24 bytes - Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) +func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} } -// Reply blocks and returns the reply data for a GetModifierMapping request. -func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getModifierMappingReply(buf), nil +// WarpPointerChecked sends a checked request. +// If an error occurs, it can be retrieved using WarpPointerCookie.Check() +func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} } -// getModifierMappingReply reads a byte slice into a GetModifierMappingReply value. -func getModifierMappingReply(buf []byte) *GetModifierMappingReply { - v := new(GetModifierMappingReply) - b := 1 // skip reply determinant - - v.KeycodesPerModifier = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) - for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { - v.Keycodes[i] = Keycode(buf[b]) - b += 1 - } - b = xgb.Pad(b) - - 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 WarpPointerCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetModifierMapping -// getModifierMappingRequest writes a GetModifierMapping request to a byte slice. -func getModifierMappingRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for WarpPointer +// warpPointerRequest writes a WarpPointer request to a byte slice. +func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 119 // request opcode + buf[b] = 41 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return buf -} + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 -// NoOperationCookie is a cookie used only for NoOperation requests. -type NoOperationCookie struct { - *xgb.Cookie -} + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 -// NoOperation sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func NoOperation(c *xgb.Conn) NoOperationCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(noOperationRequest(c), cookie) - return NoOperationCookie{cookie} -} + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 -// NoOperationChecked sends a checked request. -// If an error occurs, it can be retrieved using NoOperationCookie.Check() -func NoOperationChecked(c *xgb.Conn) NoOperationCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(noOperationRequest(c), cookie) - return NoOperationCookie{cookie} -} + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 -// 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 NoOperationCookie) Check() error { - return cook.Cookie.Check() -} + xgb.Put16(buf[b:], SrcWidth) + b += 2 -// Write request to wire for NoOperation -// noOperationRequest writes a NoOperation request to a byte slice. -func noOperationRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], SrcHeight) + b += 2 - buf[b] = 127 // request opcode - b += 1 + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], uint16(DstY)) b += 2 return buf diff --git a/nexgb/xselinux/xselinux.go b/nexgb/xselinux/xselinux.go index 6024d65..c7183bf 100644 --- a/nexgb/xselinux/xselinux.go +++ b/nexgb/xselinux/xselinux.go @@ -2,7 +2,7 @@ package xselinux /* - This file was generated by xselinux.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xselinux.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["SELinux"] = 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' - -// 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 ListItem struct { Name xproto.Atom ObjectContextLen uint32 @@ -156,188 +132,59 @@ func ListItemListSize(list []ListItem) int { return size } -// 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, ClientMajor byte, ClientMinor byte) QueryVersionCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), 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, ClientMajor byte, ClientMinor byte) QueryVersionCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), 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 - ServerMajor uint16 - ServerMinor 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.ServerMajor = xgb.Get16(buf[b:]) - b += 2 - - v.ServerMinor = 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, ClientMajor byte, ClientMinor byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - 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] = ClientMajor - b += 1 - - buf[b] = ClientMinor - b += 1 - - return buf -} +// Skipping definition for base type 'Bool' -// SetDeviceCreateContextCookie is a cookie used only for SetDeviceCreateContext requests. -type SetDeviceCreateContextCookie struct { - *xgb.Cookie -} +// Skipping definition for base type 'Byte' -// SetDeviceCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) - return SetDeviceCreateContextCookie{cookie} -} +// Skipping definition for base type 'Card8' -// SetDeviceCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDeviceCreateContextCookie.Check() -func SetDeviceCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) - return SetDeviceCreateContextCookie{cookie} -} +// Skipping definition for base type 'Char' -// 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 SetDeviceCreateContextCookie) Check() error { - return cook.Cookie.Check() -} +// Skipping definition for base type 'Void' -// Write request to wire for SetDeviceCreateContext -// setDeviceCreateContextRequest writes a SetDeviceCreateContext request to a byte slice. -func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Double' - buf[b] = c.Extensions["SELINUX"] - b += 1 +// Skipping definition for base type 'Float' - buf[b] = 1 // request opcode - b += 1 +// Skipping definition for base type 'Int16' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Int32' - xgb.Put32(buf[b:], ContextLen) - b += 4 +// Skipping definition for base type 'Int8' - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' -// GetDeviceCreateContextCookie is a cookie used only for GetDeviceCreateContext requests. -type GetDeviceCreateContextCookie struct { +// GetClientContextCookie is a cookie used only for GetClientContext requests. +type GetClientContextCookie struct { *xgb.Cookie } -// GetDeviceCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceCreateContextCookie.Reply() -func GetDeviceCreateContext(c *xgb.Conn) GetDeviceCreateContextCookie { +// GetClientContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClientContextCookie.Reply() +func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceCreateContextRequest(c), cookie) - return GetDeviceCreateContextCookie{cookie} + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} } -// GetDeviceCreateContextUnchecked sends an unchecked request. +// GetClientContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceCreateContextUnchecked(c *xgb.Conn) GetDeviceCreateContextCookie { +func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceCreateContextRequest(c), cookie) - return GetDeviceCreateContextCookie{cookie} + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} } -// GetDeviceCreateContextReply represents the data returned from a GetDeviceCreateContext request. -type GetDeviceCreateContextReply struct { +// GetClientContextReply represents the data returned from a GetClientContext request. +type GetClientContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -346,8 +193,8 @@ type GetDeviceCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceCreateContext request. -func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetClientContext request. +func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -355,12 +202,12 @@ func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, if buf == nil { return nil, nil } - return getDeviceCreateContextReply(buf), nil + return getClientContextReply(buf), nil } -// getDeviceCreateContextReply reads a byte slice into a GetDeviceCreateContextReply value. -func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { - v := new(GetDeviceCreateContextReply) +// getClientContextReply reads a byte slice into a GetClientContextReply value. +func getClientContextReply(buf []byte) *GetClientContextReply { + v := new(GetClientContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -386,83 +233,25 @@ func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { return v } -// Write request to wire for GetDeviceCreateContext -// getDeviceCreateContextRequest writes a GetDeviceCreateContext request to a byte slice. -func getDeviceCreateContextRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - 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 - - return buf -} - -// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. -type SetDeviceContextCookie struct { - *xgb.Cookie -} - -// SetDeviceContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{cookie} -} - -// SetDeviceContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDeviceContextCookie.Check() -func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{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 SetDeviceContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetDeviceContext -// setDeviceContextRequest writes a SetDeviceContext request to a byte slice. -func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) +// Write request to wire for GetClientContext +// getClientContextRequest writes a GetClientContext request to a byte slice. +func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 22 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Device) - b += 4 - - xgb.Put32(buf[b:], ContextLen) + xgb.Put32(buf[b:], Resource) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } @@ -565,93 +354,35 @@ func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { return buf } -// SetWindowCreateContextCookie is a cookie used only for SetWindowCreateContext requests. -type SetWindowCreateContextCookie struct { - *xgb.Cookie -} - -// SetWindowCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) - return SetWindowCreateContextCookie{cookie} -} - -// SetWindowCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetWindowCreateContextCookie.Check() -func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) - return SetWindowCreateContextCookie{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 SetWindowCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetWindowCreateContext -// setWindowCreateContextRequest writes a SetWindowCreateContext request to a byte slice. -func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - 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:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. -type GetWindowCreateContextCookie struct { +// GetDeviceCreateContextCookie is a cookie used only for GetDeviceCreateContext requests. +type GetDeviceCreateContextCookie struct { *xgb.Cookie } -// GetWindowCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetWindowCreateContextCookie.Reply() -func GetWindowCreateContext(c *xgb.Conn) GetWindowCreateContextCookie { +// GetDeviceCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceCreateContextCookie.Reply() +func GetDeviceCreateContext(c *xgb.Conn) GetDeviceCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getWindowCreateContextRequest(c), cookie) - return GetWindowCreateContextCookie{cookie} + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} } -// GetWindowCreateContextUnchecked sends an unchecked request. +// GetDeviceCreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { +func GetDeviceCreateContextUnchecked(c *xgb.Conn) GetDeviceCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getWindowCreateContextRequest(c), cookie) - return GetWindowCreateContextCookie{cookie} + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} } -// GetWindowCreateContextReply represents the data returned from a GetWindowCreateContext request. -type GetWindowCreateContextReply struct { +// GetDeviceCreateContextReply represents the data returned from a GetDeviceCreateContext request. +type GetDeviceCreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -660,8 +391,8 @@ type GetWindowCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetWindowCreateContext request. -func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetDeviceCreateContext request. +func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -669,12 +400,12 @@ func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, if buf == nil { return nil, nil } - return getWindowCreateContextReply(buf), nil + return getDeviceCreateContextReply(buf), nil } -// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. -func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { - v := new(GetWindowCreateContextReply) +// getDeviceCreateContextReply reads a byte slice into a GetDeviceCreateContextReply value. +func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { + v := new(GetDeviceCreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -700,9 +431,9 @@ func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { return v } -// Write request to wire for GetWindowCreateContext -// getWindowCreateContextRequest writes a GetWindowCreateContext request to a byte slice. -func getWindowCreateContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetDeviceCreateContext +// getDeviceCreateContextRequest writes a GetDeviceCreateContext request to a byte slice. +func getDeviceCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -710,7 +441,7 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -719,35 +450,35 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { return buf } -// GetWindowContextCookie is a cookie used only for GetWindowContext requests. -type GetWindowContextCookie struct { +// GetPropertyContextCookie is a cookie used only for GetPropertyContext requests. +type GetPropertyContextCookie struct { *xgb.Cookie } -// GetWindowContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetWindowContextCookie.Reply() -func GetWindowContext(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { +// GetPropertyContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyContextCookie.Reply() +func GetPropertyContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getWindowContextRequest(c, Window), cookie) - return GetWindowContextCookie{cookie} + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{cookie} } -// GetWindowContextUnchecked sends an unchecked request. +// GetPropertyContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { +func GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getWindowContextRequest(c, Window), cookie) - return GetWindowContextCookie{cookie} + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{cookie} } -// GetWindowContextReply represents the data returned from a GetWindowContext request. -type GetWindowContextReply struct { +// GetPropertyContextReply represents the data returned from a GetPropertyContext request. +type GetPropertyContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -756,8 +487,8 @@ type GetWindowContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetWindowContext request. -func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { +// Reply blocks and returns the reply data for a GetPropertyContext request. +func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -765,12 +496,12 @@ func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { if buf == nil { return nil, nil } - return getWindowContextReply(buf), nil + return getPropertyContextReply(buf), nil } -// getWindowContextReply reads a byte slice into a GetWindowContextReply value. -func getWindowContextReply(buf []byte) *GetWindowContextReply { - v := new(GetWindowContextReply) +// getPropertyContextReply reads a byte slice into a GetPropertyContextReply value. +func getPropertyContextReply(buf []byte) *GetPropertyContextReply { + v := new(GetPropertyContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -796,17 +527,17 @@ func getWindowContextReply(buf []byte) *GetWindowContextReply { return v } -// Write request to wire for GetWindowContext -// getWindowContextRequest writes a GetWindowContext request to a byte slice. -func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for GetPropertyContext +// getPropertyContextRequest writes a GetPropertyContext request to a byte slice. +func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -815,64 +546,9 @@ func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 - return buf -} - -// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. -type SetPropertyCreateContextCookie struct { - *xgb.Cookie -} - -// SetPropertyCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) - return SetPropertyCreateContextCookie{cookie} -} - -// SetPropertyCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPropertyCreateContextCookie.Check() -func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) - return SetPropertyCreateContextCookie{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 SetPropertyCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPropertyCreateContext -// setPropertyCreateContextRequest writes a SetPropertyCreateContext request to a byte slice. -func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - 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:], ContextLen) + xgb.Put32(buf[b:], uint32(Property)) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } @@ -972,60 +648,104 @@ func getPropertyCreateContextRequest(c *xgb.Conn) []byte { return buf } -// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. -type SetPropertyUseContextCookie struct { +// GetPropertyDataContextCookie is a cookie used only for GetPropertyDataContext requests. +type GetPropertyDataContextCookie struct { *xgb.Cookie } -// SetPropertyUseContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { +// GetPropertyDataContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyDataContextCookie.Reply() +func GetPropertyDataContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) - return SetPropertyUseContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} } -// SetPropertyUseContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPropertyUseContextCookie.Check() -func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { +// GetPropertyDataContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) - return SetPropertyUseContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{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 SetPropertyUseContextCookie) Check() error { - return cook.Cookie.Check() +// GetPropertyDataContextReply represents the data returned from a GetPropertyDataContext request. +type GetPropertyDataContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Write request to wire for SetPropertyUseContext -// setPropertyUseContextRequest writes a SetPropertyUseContext request to a byte slice. -func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// Reply blocks and returns the reply data for a GetPropertyDataContext request. +func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyDataContextReply(buf), nil +} + +// getPropertyDataContextReply reads a byte slice into a GetPropertyDataContextReply value. +func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { + v := new(GetPropertyDataContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyDataContext +// getPropertyDataContextRequest writes a GetPropertyDataContext request to a byte slice. +func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ContextLen) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + xgb.Put32(buf[b:], uint32(Property)) + b += 4 return buf } @@ -1126,35 +846,35 @@ func getPropertyUseContextRequest(c *xgb.Conn) []byte { return buf } -// GetPropertyContextCookie is a cookie used only for GetPropertyContext requests. -type GetPropertyContextCookie struct { +// GetSelectionContextCookie is a cookie used only for GetSelectionContext requests. +type GetSelectionContextCookie struct { *xgb.Cookie } -// GetPropertyContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyContextCookie.Reply() -func GetPropertyContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { +// GetSelectionContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionContextCookie.Reply() +func GetSelectionContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) - return GetPropertyContextCookie{cookie} + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{cookie} } -// GetPropertyContextUnchecked sends an unchecked request. +// GetSelectionContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { +func GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) - return GetPropertyContextCookie{cookie} + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{cookie} } -// GetPropertyContextReply represents the data returned from a GetPropertyContext request. -type GetPropertyContextReply struct { +// GetSelectionContextReply represents the data returned from a GetSelectionContext request. +type GetSelectionContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1163,8 +883,8 @@ type GetPropertyContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyContext request. -func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { +// Reply blocks and returns the reply data for a GetSelectionContext request. +func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1172,12 +892,12 @@ func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { if buf == nil { return nil, nil } - return getPropertyContextReply(buf), nil + return getSelectionContextReply(buf), nil } -// getPropertyContextReply reads a byte slice into a GetPropertyContextReply value. -func getPropertyContextReply(buf []byte) *GetPropertyContextReply { - v := new(GetPropertyContextReply) +// getSelectionContextReply reads a byte slice into a GetSelectionContextReply value. +func getSelectionContextReply(buf []byte) *GetSelectionContextReply { + v := new(GetSelectionContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1203,60 +923,57 @@ func getPropertyContextReply(buf []byte) *GetPropertyContextReply { return v } -// Write request to wire for GetPropertyContext -// getPropertyContextRequest writes a GetPropertyContext request to a byte slice. -func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { - size := 12 +// Write request to wire for GetSelectionContext +// getSelectionContextRequest writes a GetSelectionContext request to a byte slice. +func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 return buf } -// GetPropertyDataContextCookie is a cookie used only for GetPropertyDataContext requests. -type GetPropertyDataContextCookie struct { +// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. +type GetSelectionCreateContextCookie struct { *xgb.Cookie } -// GetPropertyDataContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyDataContextCookie.Reply() -func GetPropertyDataContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { +// GetSelectionCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionCreateContextCookie.Reply() +func GetSelectionCreateContext(c *xgb.Conn) GetSelectionCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) - return GetPropertyDataContextCookie{cookie} + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} } -// GetPropertyDataContextUnchecked sends an unchecked request. +// GetSelectionCreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { +func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) - return GetPropertyDataContextCookie{cookie} + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} } -// GetPropertyDataContextReply represents the data returned from a GetPropertyDataContext request. -type GetPropertyDataContextReply struct { +// GetSelectionCreateContextReply represents the data returned from a GetSelectionCreateContext request. +type GetSelectionCreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1265,8 +982,8 @@ type GetPropertyDataContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyDataContext request. -func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { +// Reply blocks and returns the reply data for a GetSelectionCreateContext request. +func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1274,12 +991,12 @@ func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, if buf == nil { return nil, nil } - return getPropertyDataContextReply(buf), nil + return getSelectionCreateContextReply(buf), nil } -// getPropertyDataContextReply reads a byte slice into a GetPropertyDataContextReply value. -func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { - v := new(GetPropertyDataContextReply) +// getSelectionCreateContextReply reads a byte slice into a GetSelectionCreateContextReply value. +func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { + v := new(GetSelectionCreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1305,70 +1022,64 @@ func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { return v } -// Write request to wire for GetPropertyDataContext -// getPropertyDataContextRequest writes a GetPropertyDataContext request to a byte slice. -func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { - size := 12 +// Write request to wire for GetSelectionCreateContext +// getSelectionCreateContextRequest writes a GetSelectionCreateContext request to a byte slice. +func getSelectionCreateContextRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - return buf } -// ListPropertiesCookie is a cookie used only for ListProperties requests. -type ListPropertiesCookie struct { +// GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. +type GetSelectionDataContextCookie struct { *xgb.Cookie } -// ListProperties sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() -func ListProperties(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { +// GetSelectionDataContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionDataContextCookie.Reply() +func GetSelectionDataContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} } -// ListPropertiesUnchecked sends an unchecked request. +// GetSelectionDataContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { +func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} } -// ListPropertiesReply represents the data returned from a ListProperties request. -type ListPropertiesReply struct { +// GetSelectionDataContextReply represents the data returned from a GetSelectionDataContext request. +type GetSelectionDataContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - PropertiesLen uint32 + ContextLen uint32 // padding: 20 bytes - Properties []ListItem // size: ListItemListSize(Properties) + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a ListProperties request. -func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { +// Reply blocks and returns the reply data for a GetSelectionDataContext request. +func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1376,12 +1087,12 @@ func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { if buf == nil { return nil, nil } - return listPropertiesReply(buf), nil + return getSelectionDataContextReply(buf), nil } -// listPropertiesReply reads a byte slice into a ListPropertiesReply value. -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) +// getSelectionDataContextReply reads a byte slice into a GetSelectionDataContextReply value. +func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { + v := new(GetSelectionDataContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1392,20 +1103,24 @@ func listPropertiesReply(buf []byte) *ListPropertiesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PropertiesLen = xgb.Get32(buf[b:]) + v.ContextLen = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - v.Properties = make([]ListItem, v.PropertiesLen) - b += ListItemReadList(buf[b:], v.Properties) + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } return v } -// Write request to wire for ListProperties -// listPropertiesRequest writes a ListProperties request to a byte slice. -func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetSelectionDataContext +// getSelectionDataContextRequest writes a GetSelectionDataContext request to a byte slice. +func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1413,105 +1128,47 @@ func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 14 // 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 -} - -// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. -type SetSelectionCreateContextCookie struct { - *xgb.Cookie -} - -// SetSelectionCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{cookie} -} - -// SetSelectionCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionCreateContextCookie.Check() -func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{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 SetSelectionCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetSelectionCreateContext -// setSelectionCreateContextRequest writes a SetSelectionCreateContext request to a byte slice. -func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 15 // request opcode + buf[b] = 20 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ContextLen) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } -// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. -type GetSelectionCreateContextCookie struct { +// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. +type GetSelectionUseContextCookie struct { *xgb.Cookie } -// GetSelectionCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionCreateContextCookie.Reply() -func GetSelectionCreateContext(c *xgb.Conn) GetSelectionCreateContextCookie { +// GetSelectionUseContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionUseContextCookie.Reply() +func GetSelectionUseContext(c *xgb.Conn) GetSelectionUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionCreateContextRequest(c), cookie) - return GetSelectionCreateContextCookie{cookie} + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} } -// GetSelectionCreateContextUnchecked sends an unchecked request. +// GetSelectionUseContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { +func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionCreateContextRequest(c), cookie) - return GetSelectionCreateContextCookie{cookie} + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} } -// GetSelectionCreateContextReply represents the data returned from a GetSelectionCreateContext request. -type GetSelectionCreateContextReply struct { +// GetSelectionUseContextReply represents the data returned from a GetSelectionUseContext request. +type GetSelectionUseContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1520,8 +1177,8 @@ type GetSelectionCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetSelectionCreateContext request. -func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetSelectionUseContext request. +func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1529,12 +1186,12 @@ func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextR if buf == nil { return nil, nil } - return getSelectionCreateContextReply(buf), nil + return getSelectionUseContextReply(buf), nil } -// getSelectionCreateContextReply reads a byte slice into a GetSelectionCreateContextReply value. -func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { - v := new(GetSelectionCreateContextReply) +// getSelectionUseContextReply reads a byte slice into a GetSelectionUseContextReply value. +func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { + v := new(GetSelectionUseContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1560,9 +1217,9 @@ func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply return v } -// Write request to wire for GetSelectionCreateContext -// getSelectionCreateContextRequest writes a GetSelectionCreateContext request to a byte slice. -func getSelectionCreateContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetSelectionUseContext +// getSelectionUseContextRequest writes a GetSelectionUseContext request to a byte slice. +func getSelectionUseContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -1570,102 +1227,44 @@ func getSelectionCreateContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 16 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// SetSelectionUseContextCookie is a cookie used only for SetSelectionUseContext requests. -type SetSelectionUseContextCookie struct { - *xgb.Cookie -} - -// SetSelectionUseContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) - return SetSelectionUseContextCookie{cookie} -} - -// SetSelectionUseContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionUseContextCookie.Check() -func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) - return SetSelectionUseContextCookie{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 SetSelectionUseContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetSelectionUseContext -// setSelectionUseContextRequest writes a SetSelectionUseContext request to a byte slice. -func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 17 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } -// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. -type GetSelectionUseContextCookie struct { +// GetWindowContextCookie is a cookie used only for GetWindowContext requests. +type GetWindowContextCookie struct { *xgb.Cookie } -// GetSelectionUseContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionUseContextCookie.Reply() -func GetSelectionUseContext(c *xgb.Conn) GetSelectionUseContextCookie { +// GetWindowContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowContextCookie.Reply() +func GetWindowContext(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionUseContextRequest(c), cookie) - return GetSelectionUseContextCookie{cookie} + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} } -// GetSelectionUseContextUnchecked sends an unchecked request. +// GetWindowContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { +func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionUseContextRequest(c), cookie) - return GetSelectionUseContextCookie{cookie} + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} } -// GetSelectionUseContextReply represents the data returned from a GetSelectionUseContext request. -type GetSelectionUseContextReply struct { +// GetWindowContextReply represents the data returned from a GetWindowContext request. +type GetWindowContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1674,8 +1273,8 @@ type GetSelectionUseContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetSelectionUseContext request. -func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { +// Reply blocks and returns the reply data for a GetWindowContext request. +func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1683,12 +1282,12 @@ func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, if buf == nil { return nil, nil } - return getSelectionUseContextReply(buf), nil + return getWindowContextReply(buf), nil } -// getSelectionUseContextReply reads a byte slice into a GetSelectionUseContextReply value. -func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { - v := new(GetSelectionUseContextReply) +// getWindowContextReply reads a byte slice into a GetWindowContextReply value. +func getWindowContextReply(buf []byte) *GetWindowContextReply { + v := new(GetWindowContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1714,54 +1313,57 @@ func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { return v } -// Write request to wire for GetSelectionUseContext -// getSelectionUseContextRequest writes a GetSelectionUseContext request to a byte slice. -func getSelectionUseContextRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GetWindowContext +// getWindowContextRequest writes a GetWindowContext request to a byte slice. +func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 18 // request opcode + 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:], uint32(Window)) + b += 4 + return buf } -// GetSelectionContextCookie is a cookie used only for GetSelectionContext requests. -type GetSelectionContextCookie struct { +// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. +type GetWindowCreateContextCookie struct { *xgb.Cookie } -// GetSelectionContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionContextCookie.Reply() -func GetSelectionContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { +// GetWindowCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowCreateContextCookie.Reply() +func GetWindowCreateContext(c *xgb.Conn) GetWindowCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionContextRequest(c, Selection), cookie) - return GetSelectionContextCookie{cookie} + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{cookie} } -// GetSelectionContextUnchecked sends an unchecked request. +// GetWindowCreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { +func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionContextRequest(c, Selection), cookie) - return GetSelectionContextCookie{cookie} + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{cookie} } -// GetSelectionContextReply represents the data returned from a GetSelectionContext request. -type GetSelectionContextReply struct { +// GetWindowCreateContextReply represents the data returned from a GetWindowCreateContext request. +type GetWindowCreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1770,8 +1372,8 @@ type GetSelectionContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetSelectionContext request. -func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { +// Reply blocks and returns the reply data for a GetWindowCreateContext request. +func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1779,12 +1381,12 @@ func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) if buf == nil { return nil, nil } - return getSelectionContextReply(buf), nil + return getWindowCreateContextReply(buf), nil } -// getSelectionContextReply reads a byte slice into a GetSelectionContextReply value. -func getSelectionContextReply(buf []byte) *GetSelectionContextReply { - v := new(GetSelectionContextReply) +// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. +func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { + v := new(GetWindowCreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1810,67 +1412,64 @@ func getSelectionContextReply(buf []byte) *GetSelectionContextReply { return v } -// Write request to wire for GetSelectionContext -// getSelectionContextRequest writes a GetSelectionContext request to a byte slice. -func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { - size := 8 +// Write request to wire for GetWindowCreateContext +// getWindowCreateContextRequest writes a GetWindowCreateContext request to a byte slice. +func getWindowCreateContextRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 19 // request opcode + 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:], uint32(Selection)) - b += 4 - return buf } -// GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. -type GetSelectionDataContextCookie struct { +// ListPropertiesCookie is a cookie used only for ListProperties requests. +type ListPropertiesCookie struct { *xgb.Cookie } -// GetSelectionDataContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionDataContextCookie.Reply() -func GetSelectionDataContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { +// ListProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() +func ListProperties(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) - return GetSelectionDataContextCookie{cookie} + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// GetSelectionDataContextUnchecked sends an unchecked request. +// ListPropertiesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { +func ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) - return GetSelectionDataContextCookie{cookie} + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// GetSelectionDataContextReply represents the data returned from a GetSelectionDataContext request. -type GetSelectionDataContextReply struct { +// ListPropertiesReply represents the data returned from a ListProperties request. +type ListPropertiesReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ContextLen uint32 + PropertiesLen uint32 // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) + Properties []ListItem // size: ListItemListSize(Properties) } -// Reply blocks and returns the reply data for a GetSelectionDataContext request. -func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { +// Reply blocks and returns the reply data for a ListProperties request. +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1878,12 +1477,12 @@ func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply if buf == nil { return nil, nil } - return getSelectionDataContextReply(buf), nil + return listPropertiesReply(buf), nil } -// getSelectionDataContextReply reads a byte slice into a GetSelectionDataContextReply value. -func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { - v := new(GetSelectionDataContextReply) +// listPropertiesReply reads a byte slice into a ListPropertiesReply value. +func listPropertiesReply(buf []byte) *ListPropertiesReply { + v := new(ListPropertiesReply) b := 1 // skip reply determinant b += 1 // padding @@ -1894,24 +1493,20 @@ func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) + v.PropertiesLen = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) - } + v.Properties = make([]ListItem, v.PropertiesLen) + b += ListItemReadList(buf[b:], v.Properties) return v } -// Write request to wire for GetSelectionDataContext -// getSelectionDataContextRequest writes a GetSelectionDataContext request to a byte slice. -func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { +// Write request to wire for ListProperties +// listPropertiesRequest writes a ListProperties request to a byte slice. +func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1919,13 +1514,13 @@ func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 14 // 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(Selection)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf @@ -2023,45 +1618,44 @@ func listSelectionsRequest(c *xgb.Conn) []byte { return buf } -// GetClientContextCookie is a cookie used only for GetClientContext requests. -type GetClientContextCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// GetClientContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetClientContextCookie.Reply() -func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { +// 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, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getClientContextRequest(c, Resource), cookie) - return GetClientContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetClientContextUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getClientContextRequest(c, Resource), cookie) - return GetClientContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetClientContextReply represents the data returned from a GetClientContext request. -type GetClientContextReply struct { +// 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 - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) + ServerMajor uint16 + ServerMinor uint16 } -// Reply blocks and returns the reply data for a GetClientContext request. -func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { +// 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 @@ -2069,12 +1663,12 @@ func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { if buf == nil { return nil, nil } - return getClientContextReply(buf), nil + return queryVersionReply(buf), nil } -// getClientContextReply reads a byte slice into a GetClientContextReply value. -func getClientContextReply(buf []byte) *GetClientContextReply { - v := new(GetClientContextReply) +// 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 @@ -2085,39 +1679,445 @@ func getClientContextReply(buf []byte) *GetClientContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinor = 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, ClientMajor byte, ClientMinor byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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] = ClientMajor + b += 1 + + buf[b] = ClientMinor + b += 1 + + return buf +} + +// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. +type SetDeviceContextCookie struct { + *xgb.Cookie +} + +// SetDeviceContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} +} + +// SetDeviceContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceContextCookie.Check() +func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{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 SetDeviceContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceContext +// setDeviceContextRequest writes a SetDeviceContext request to a byte slice. +func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], Device) b += 4 - b += 20 // padding + xgb.Put32(buf[b:], ContextLen) + b += 4 - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetDeviceCreateContextCookie is a cookie used only for SetDeviceCreateContext requests. +type SetDeviceCreateContextCookie struct { + *xgb.Cookie +} + +// SetDeviceCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} +} - return v +// SetDeviceCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceCreateContextCookie.Check() +func SetDeviceCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} } -// Write request to wire for GetClientContext -// getClientContextRequest writes a GetClientContext request to a byte slice. -func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { - size := 8 +// 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 SetDeviceCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceCreateContext +// setDeviceCreateContextRequest writes a SetDeviceCreateContext request to a byte slice. +func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 22 // request opcode + 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:], Resource) + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. +type SetPropertyCreateContextCookie struct { + *xgb.Cookie +} + +// SetPropertyCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} +} + +// SetPropertyCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyCreateContextCookie.Check() +func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{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 SetPropertyCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyCreateContext +// setPropertyCreateContextRequest writes a SetPropertyCreateContext request to a byte slice. +func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. +type SetPropertyUseContextCookie struct { + *xgb.Cookie +} + +// SetPropertyUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} +} + +// SetPropertyUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyUseContextCookie.Check() +func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{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 SetPropertyUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyUseContext +// setPropertyUseContextRequest writes a SetPropertyUseContext request to a byte slice. +func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], ContextLen) b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. +type SetSelectionCreateContextCookie struct { + *xgb.Cookie +} + +// SetSelectionCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} +} + +// SetSelectionCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionCreateContextCookie.Check() +func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{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 SetSelectionCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionCreateContext +// setSelectionCreateContextRequest writes a SetSelectionCreateContext request to a byte slice. +func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetSelectionUseContextCookie is a cookie used only for SetSelectionUseContext requests. +type SetSelectionUseContextCookie struct { + *xgb.Cookie +} + +// SetSelectionUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +// SetSelectionUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionUseContextCookie.Check() +func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{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 SetSelectionUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionUseContext +// setSelectionUseContextRequest writes a SetSelectionUseContext request to a byte slice. +func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetWindowCreateContextCookie is a cookie used only for SetWindowCreateContext requests. +type SetWindowCreateContextCookie struct { + *xgb.Cookie +} + +// SetWindowCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} + +// SetWindowCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetWindowCreateContextCookie.Check() +func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{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 SetWindowCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetWindowCreateContext +// setWindowCreateContextRequest writes a SetWindowCreateContext request to a byte slice. +func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + return buf } diff --git a/nexgb/xtest/xtest.go b/nexgb/xtest/xtest.go index 30d96ec..505622a 100644 --- a/nexgb/xtest/xtest.go +++ b/nexgb/xtest/xtest.go @@ -2,7 +2,7 @@ package xtest /* - This file was generated by xtest.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xtest.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,128 +40,34 @@ func init() { xgb.NewExtErrorFuncs["XTEST"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Void' +const ( + CursorNone = 0 + CursorCurrent = 1 +) -// Skipping definition for base type 'Byte' +// Skipping definition for base type 'Bool' -// Skipping definition for base type 'Int8' +// Skipping definition for base type 'Byte' -// Skipping definition for base type 'Card16' +// Skipping definition for base type 'Card8' // Skipping definition for base type 'Char' -// Skipping definition for base type 'Card32' +// Skipping definition for base type 'Void' // 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' -const ( - CursorNone = 0 - CursorCurrent = 1 -) - -// GetVersionCookie is a cookie used only for GetVersion requests. -type GetVersionCookie struct { - *xgb.Cookie -} - -// GetVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() -func GetVersion(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { - if _, ok := c.Extensions["XTEST"]; !ok { - panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) - return GetVersionCookie{cookie} -} - -// GetVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetVersionUnchecked(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { - if _, ok := c.Extensions["XTEST"]; !ok { - panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) - return GetVersionCookie{cookie} -} - -// GetVersionReply represents the data returned from a GetVersion request. -type GetVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - MajorVersion byte - MinorVersion uint16 -} - -// Reply blocks and returns the reply data for a GetVersion request. -func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getVersionReply(buf), nil -} - -// getVersionReply reads a byte slice into a GetVersionReply value. -func getVersionReply(buf []byte) *GetVersionReply { - v := new(GetVersionReply) - b := 1 // skip reply determinant - - v.MajorVersion = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// Write request to wire for GetVersion -// getVersionRequest writes a GetVersion request to a byte slice. -func getVersionRequest(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XTEST"] - 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] = MajorVersion - b += 1 - - b += 1 // padding +// Skipping definition for base type 'Int8' - xgb.Put16(buf[b:], MinorVersion) - b += 2 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // CompareCursorCookie is a cookie used only for CompareCursor requests. type CompareCursorCookie struct { @@ -334,6 +240,100 @@ func fakeInputRequest(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xpr return buf } +// GetVersionCookie is a cookie used only for GetVersion requests. +type GetVersionCookie struct { + *xgb.Cookie +} + +// GetVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() +func GetVersion(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) + return GetVersionCookie{cookie} +} + +// GetVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetVersionUnchecked(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) + return GetVersionCookie{cookie} +} + +// GetVersionReply represents the data returned from a GetVersion request. +type GetVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + MajorVersion byte + MinorVersion uint16 +} + +// Reply blocks and returns the reply data for a GetVersion request. +func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVersionReply(buf), nil +} + +// getVersionReply reads a byte slice into a GetVersionReply value. +func getVersionReply(buf []byte) *GetVersionReply { + v := new(GetVersionReply) + b := 1 // skip reply determinant + + v.MajorVersion = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for GetVersion +// getVersionRequest writes a GetVersion request to a byte slice. +func getVersionRequest(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XTEST"] + 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] = MajorVersion + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], MinorVersion) + b += 2 + + return buf +} + // GrabControlCookie is a cookie used only for GrabControl requests. type GrabControlCookie struct { *xgb.Cookie diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index ed10b3b..f5539b3 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xv.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,139 +41,186 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' +type AdaptorInfo struct { + BaseId Port + NameSize uint16 + NumPorts uint16 + NumFormats uint16 + Type byte + // padding: 1 bytes + Name string // size: xgb.Pad((int(NameSize) * 1)) + Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) +} -// Skipping definition for base type 'Int16' +// AdaptorInfoRead reads a byte slice into a AdaptorInfo value. +func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { + b := 0 -// Skipping definition for base type 'Int32' + v.BaseId = Port(xgb.Get32(buf[b:])) + b += 4 -// Skipping definition for base type 'Void' + v.NameSize = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Byte' + v.NumPorts = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Int8' + v.NumFormats = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card16' + v.Type = buf[b] + b += 1 -// Skipping definition for base type 'Char' + b += 1 // padding -// Skipping definition for base type 'Card32' + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } -// Skipping definition for base type 'Double' + v.Formats = make([]Format, v.NumFormats) + b += FormatReadList(buf[b:], v.Formats) -// Skipping definition for base type 'Bool' + return b +} -// Skipping definition for base type 'Float' +// AdaptorInfoReadList reads a byte slice into a list of AdaptorInfo values. +func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AdaptorInfo{} + b += AdaptorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} -const ( - TypeInputMask = 1 - TypeOutputMask = 2 - TypeVideoMask = 4 - TypeStillMask = 8 - TypeImageMask = 16 -) +// Bytes writes a AdaptorInfo value to a byte slice. +func (v AdaptorInfo) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.NameSize) * 1))) + xgb.Pad((int(v.NumFormats) * 8)))) + b := 0 -const ( - ImageFormatInfoTypeRgb = 0 - ImageFormatInfoTypeYuv = 1 -) + xgb.Put32(buf[b:], uint32(v.BaseId)) + b += 4 -const ( - ImageFormatInfoFormatPacked = 0 - ImageFormatInfoFormatPlanar = 1 -) + xgb.Put16(buf[b:], v.NameSize) + b += 2 -const ( - AttributeFlagGettable = 1 - AttributeFlagSettable = 2 -) + xgb.Put16(buf[b:], v.NumPorts) + b += 2 -const ( - VideoNotifyReasonStarted = 0 - VideoNotifyReasonStopped = 1 - VideoNotifyReasonBusy = 2 - VideoNotifyReasonPreempted = 3 - VideoNotifyReasonHardError = 4 -) + xgb.Put16(buf[b:], v.NumFormats) + b += 2 -const ( - ScanlineOrderTopToBottom = 0 - ScanlineOrderBottomToTop = 1 -) + buf[b] = v.Type + b += 1 -const ( - GrabPortStatusSuccess = 0 - GrabPortStatusBadExtension = 1 - GrabPortStatusAlreadyGrabbed = 2 - GrabPortStatusInvalidTime = 3 - GrabPortStatusBadReply = 4 - GrabPortStatusBadAlloc = 5 -) + b += 1 // padding -type Port uint32 + copy(buf[b:], v.Name[:v.NameSize]) + b += xgb.Pad(int(v.NameSize)) -func NewPortId(c *xgb.Conn) (Port, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Port(id), nil + b += FormatListBytes(buf[b:], v.Formats) + + return buf } -type Encoding uint32 +// AdaptorInfoListBytes writes a list of AdaptorInfo values to a byte slice. +func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} -func NewEncodingId(c *xgb.Conn) (Encoding, error) { - id, err := c.NewId() - if err != nil { - return 0, err +// AdaptorInfoListSize computes the size (bytes) of a list of AdaptorInfo values. +func AdaptorInfoListSize(list []AdaptorInfo) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.NameSize) * 1))) + xgb.Pad((int(item.NumFormats) * 8))) } - return Encoding(id), nil + return size } -type Rational struct { - Numerator int32 - Denominator int32 +const ( + AttributeFlagGettable = 1 + AttributeFlagSettable = 2 +) + +type AttributeInfo struct { + Flags uint32 + Min int32 + Max int32 + Size uint32 + Name string // size: xgb.Pad((int(Size) * 1)) } -// RationalRead reads a byte slice into a Rational value. -func RationalRead(buf []byte, v *Rational) int { +// AttributeInfoRead reads a byte slice into a AttributeInfo value. +func AttributeInfoRead(buf []byte, v *AttributeInfo) int { b := 0 - v.Numerator = int32(xgb.Get32(buf[b:])) + v.Flags = xgb.Get32(buf[b:]) b += 4 - v.Denominator = int32(xgb.Get32(buf[b:])) + v.Min = int32(xgb.Get32(buf[b:])) b += 4 + v.Max = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Size = xgb.Get32(buf[b:]) + b += 4 + + { + byteString := make([]byte, v.Size) + copy(byteString[:v.Size], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Size)) + } + return b } -// RationalReadList reads a byte slice into a list of Rational values. -func RationalReadList(buf []byte, dest []Rational) int { +// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values. +func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Rational{} - b += RationalRead(buf[b:], &dest[i]) + dest[i] = AttributeInfo{} + b += AttributeInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Rational value to a byte slice. -func (v Rational) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a AttributeInfo value to a byte slice. +func (v AttributeInfo) Bytes() []byte { + buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) b := 0 - xgb.Put32(buf[b:], uint32(v.Numerator)) + xgb.Put32(buf[b:], v.Flags) b += 4 - xgb.Put32(buf[b:], uint32(v.Denominator)) + xgb.Put32(buf[b:], uint32(v.Min)) b += 4 + xgb.Put32(buf[b:], uint32(v.Max)) + b += 4 + + xgb.Put32(buf[b:], v.Size) + b += 4 + + copy(buf[b:], v.Name[:v.Size]) + b += xgb.Pad(int(v.Size)) + return buf } -// RationalListBytes writes a list of Rational values to a byte slice. -func RationalListBytes(buf []byte, list []Rational) int { +// AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice. +func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -184,169 +231,161 @@ func RationalListBytes(buf []byte, list []Rational) int { return b } -type Format struct { - Visual xproto.Visualid - Depth byte - // padding: 3 bytes +// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. +func AttributeInfoListSize(list []AttributeInfo) int { + size := 0 + for _, item := range list { + size += (16 + xgb.Pad((int(item.Size) * 1))) + } + return size } -// FormatRead reads a byte slice into a Format value. -func FormatRead(buf []byte, v *Format) int { - b := 0 - - v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) - b += 4 - - v.Depth = buf[b] - b += 1 - - b += 3 // padding +// BadBadControl is the error number for a BadBadControl. +const BadBadControl = 2 - return b +type BadControlError struct { + Sequence uint16 + NiceName string } -// FormatReadList reads a byte slice into a list of Format values. -func FormatReadList(buf []byte, dest []Format) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Format{} - b += FormatRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} +// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. +func BadControlErrorNew(buf []byte) xgb.Error { + v := BadControlError{} + v.NiceName = "BadControl" -// Bytes writes a Format value to a byte slice. -func (v Format) Bytes() []byte { - buf := make([]byte, 8) - b := 0 + b := 1 // skip error determinant + b += 1 // don't read error number - xgb.Put32(buf[b:], uint32(v.Visual)) - b += 4 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - buf[b] = v.Depth - b += 1 + return v +} - b += 3 // padding +// SequenceId returns the sequence id attached to the BadBadControl error. +// This is mostly used internally. +func (err BadControlError) SequenceId() uint16 { + return err.Sequence +} - return buf +// BadId returns the 'BadValue' number if one exists for the BadBadControl error. If no bad value exists, 0 is returned. +func (err BadControlError) BadId() uint32 { + return 0 } -// FormatListBytes writes a list of Format values to a byte slice. -func FormatListBytes(buf []byte, list []Format) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// Error returns a rudimentary string representation of the BadBadControl error. + +func (err BadControlError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type AdaptorInfo struct { - BaseId Port - NameSize uint16 - NumPorts uint16 - NumFormats uint16 - Type byte - // padding: 1 bytes - Name string // size: xgb.Pad((int(NameSize) * 1)) - Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) +func init() { + xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew } -// AdaptorInfoRead reads a byte slice into a AdaptorInfo value. -func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { - b := 0 +// BadBadEncoding is the error number for a BadBadEncoding. +const BadBadEncoding = 1 - v.BaseId = Port(xgb.Get32(buf[b:])) - b += 4 +type BadEncodingError struct { + Sequence uint16 + NiceName string +} - v.NameSize = xgb.Get16(buf[b:]) - b += 2 +// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice. +func BadEncodingErrorNew(buf []byte) xgb.Error { + v := BadEncodingError{} + v.NiceName = "BadEncoding" - v.NumPorts = xgb.Get16(buf[b:]) - b += 2 + b := 1 // skip error determinant + b += 1 // don't read error number - v.NumFormats = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Type = buf[b] - b += 1 + return v +} - b += 1 // padding +// SequenceId returns the sequence id attached to the BadBadEncoding error. +// This is mostly used internally. +func (err BadEncodingError) SequenceId() uint16 { + return err.Sequence +} - { - byteString := make([]byte, v.NameSize) - copy(byteString[:v.NameSize], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameSize)) - } +// BadId returns the 'BadValue' number if one exists for the BadBadEncoding error. If no bad value exists, 0 is returned. +func (err BadEncodingError) BadId() uint32 { + return 0 +} - v.Formats = make([]Format, v.NumFormats) - b += FormatReadList(buf[b:], v.Formats) +// Error returns a rudimentary string representation of the BadBadEncoding error. - return b +func (err BadEncodingError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// AdaptorInfoReadList reads a byte slice into a list of AdaptorInfo values. -func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = AdaptorInfo{} - b += AdaptorInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +func init() { + xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew } -// Bytes writes a AdaptorInfo value to a byte slice. -func (v AdaptorInfo) Bytes() []byte { - buf := make([]byte, ((12 + xgb.Pad((int(v.NameSize) * 1))) + xgb.Pad((int(v.NumFormats) * 8)))) - b := 0 +// BadBadPort is the error number for a BadBadPort. +const BadBadPort = 0 - xgb.Put32(buf[b:], uint32(v.BaseId)) - b += 4 +type BadPortError struct { + Sequence uint16 + NiceName string +} - xgb.Put16(buf[b:], v.NameSize) - b += 2 +// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. +func BadPortErrorNew(buf []byte) xgb.Error { + v := BadPortError{} + v.NiceName = "BadPort" - xgb.Put16(buf[b:], v.NumPorts) - b += 2 + b := 1 // skip error determinant + b += 1 // don't read error number - xgb.Put16(buf[b:], v.NumFormats) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - buf[b] = v.Type - b += 1 + return v +} - b += 1 // padding +// SequenceId returns the sequence id attached to the BadBadPort error. +// This is mostly used internally. +func (err BadPortError) SequenceId() uint16 { + return err.Sequence +} - copy(buf[b:], v.Name[:v.NameSize]) - b += xgb.Pad(int(v.NameSize)) +// BadId returns the 'BadValue' number if one exists for the BadBadPort error. If no bad value exists, 0 is returned. +func (err BadPortError) BadId() uint32 { + return 0 +} - b += FormatListBytes(buf[b:], v.Formats) +// Error returns a rudimentary string representation of the BadBadPort error. - return buf +func (err BadPortError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// AdaptorInfoListBytes writes a list of AdaptorInfo values to a byte slice. -func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +func init() { + xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew } -// AdaptorInfoListSize computes the size (bytes) of a list of AdaptorInfo values. -func AdaptorInfoListSize(list []AdaptorInfo) int { - size := 0 - for _, item := range list { - size += ((12 + xgb.Pad((int(item.NameSize) * 1))) + xgb.Pad((int(item.NumFormats) * 8))) +type Encoding uint32 + +func NewEncodingId(c *xgb.Conn) (Encoding, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return size + return Encoding(id), nil } type EncodingInfo struct { @@ -452,6 +491,74 @@ func EncodingInfoListSize(list []EncodingInfo) int { return size } +type Format struct { + Visual xproto.Visualid + Depth byte + // padding: 3 bytes +} + +// FormatRead reads a byte slice into a Format value. +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// FormatReadList reads a byte slice into a list of Format values. +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Format value to a byte slice. +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + return buf +} + +// FormatListBytes writes a list of Format values to a byte slice. +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + GrabPortStatusSuccess = 0 + GrabPortStatusBadExtension = 1 + GrabPortStatusAlreadyGrabbed = 2 + GrabPortStatusInvalidTime = 3 + GrabPortStatusBadReply = 4 + GrabPortStatusBadAlloc = 5 +) + type Image struct { Id uint32 Width uint16 @@ -572,94 +679,6 @@ func ImageListSize(list []Image) int { return size } -type AttributeInfo struct { - Flags uint32 - Min int32 - Max int32 - Size uint32 - Name string // size: xgb.Pad((int(Size) * 1)) -} - -// AttributeInfoRead reads a byte slice into a AttributeInfo value. -func AttributeInfoRead(buf []byte, v *AttributeInfo) int { - b := 0 - - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - v.Min = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Max = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Size = xgb.Get32(buf[b:]) - b += 4 - - { - byteString := make([]byte, v.Size) - copy(byteString[:v.Size], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Size)) - } - - return b -} - -// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values. -func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = AttributeInfo{} - b += AttributeInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a AttributeInfo value to a byte slice. -func (v AttributeInfo) Bytes() []byte { - buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) - b := 0 - - xgb.Put32(buf[b:], v.Flags) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Min)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Max)) - b += 4 - - xgb.Put32(buf[b:], v.Size) - b += 4 - - copy(buf[b:], v.Name[:v.Size]) - b += xgb.Pad(int(v.Size)) - - return buf -} - -// AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice. -func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. -func AttributeInfoListSize(list []AttributeInfo) int { - size := 0 - for _, item := range list { - size += (16 + xgb.Pad((int(item.Size) * 1))) - } - return size -} - type ImageFormatInfo struct { Id uint32 Type byte @@ -890,86 +909,24 @@ func ImageFormatInfoListSize(list []ImageFormatInfo) int { return size } -// VideoNotify is the event number for a VideoNotifyEvent. -const VideoNotify = 0 - -type VideoNotifyEvent struct { - Sequence uint16 - Reason byte - Time xproto.Timestamp - Drawable xproto.Drawable - Port Port -} - -// VideoNotifyEventNew constructs a VideoNotifyEvent value that implements xgb.Event from a byte slice. -func VideoNotifyEventNew(buf []byte) xgb.Event { - v := VideoNotifyEvent{} - b := 1 // don't read event number - - v.Reason = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) - b += 4 - - v.Port = Port(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Bytes writes a VideoNotifyEvent value to a byte slice. -func (v VideoNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Reason - b += 1 - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Port)) - b += 4 - - return buf -} +const ( + ImageFormatInfoFormatPacked = 0 + ImageFormatInfoFormatPlanar = 1 +) -// SequenceId returns the sequence id attached to the VideoNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v VideoNotifyEvent) SequenceId() uint16 { - return v.Sequence -} +const ( + ImageFormatInfoTypeRgb = 0 + ImageFormatInfoTypeYuv = 1 +) -// String is a rudimentary string representation of VideoNotifyEvent. -func (v VideoNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) - return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +type Port uint32 -func init() { - xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew +func NewPortId(c *xgb.Conn) (Port, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Port(id), nil } // PortNotify is the event number for a PortNotifyEvent. @@ -1059,182 +1016,224 @@ func init() { xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew } -// BadBadPort is the error number for a BadBadPort. -const BadBadPort = 0 - -type BadPortError struct { - Sequence uint16 - NiceName string +type Rational struct { + Numerator int32 + Denominator int32 } -// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. -func BadPortErrorNew(buf []byte) xgb.Error { - v := BadPortError{} - v.NiceName = "BadPort" +// RationalRead reads a byte slice into a Rational value. +func RationalRead(buf []byte, v *Rational) int { + b := 0 - b := 1 // skip error determinant - b += 1 // don't read error number + v.Numerator = int32(xgb.Get32(buf[b:])) + b += 4 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.Denominator = int32(xgb.Get32(buf[b:])) + b += 4 - return v + return b } -// SequenceId returns the sequence id attached to the BadBadPort error. -// This is mostly used internally. -func (err BadPortError) SequenceId() uint16 { - return err.Sequence +// RationalReadList reads a byte slice into a list of Rational values. +func RationalReadList(buf []byte, dest []Rational) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rational{} + b += RationalRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// BadId returns the 'BadValue' number if one exists for the BadBadPort error. If no bad value exists, 0 is returned. -func (err BadPortError) BadId() uint32 { - return 0 -} +// Bytes writes a Rational value to a byte slice. +func (v Rational) Bytes() []byte { + buf := make([]byte, 8) + b := 0 -// Error returns a rudimentary string representation of the BadBadPort error. + xgb.Put32(buf[b:], uint32(v.Numerator)) + b += 4 -func (err BadPortError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}" + xgb.Put32(buf[b:], uint32(v.Denominator)) + b += 4 + + return buf } -func init() { - xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew +// RationalListBytes writes a list of Rational values to a byte slice. +func RationalListBytes(buf []byte, list []Rational) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// BadBadEncoding is the error number for a BadBadEncoding. -const BadBadEncoding = 1 +const ( + ScanlineOrderTopToBottom = 0 + ScanlineOrderBottomToTop = 1 +) -type BadEncodingError struct { +const ( + TypeInputMask = 1 + TypeOutputMask = 2 + TypeVideoMask = 4 + TypeStillMask = 8 + TypeImageMask = 16 +) + +// VideoNotify is the event number for a VideoNotifyEvent. +const VideoNotify = 0 + +type VideoNotifyEvent struct { Sequence uint16 - NiceName string + Reason byte + Time xproto.Timestamp + Drawable xproto.Drawable + Port Port } -// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice. -func BadEncodingErrorNew(buf []byte) xgb.Error { - v := BadEncodingError{} - v.NiceName = "BadEncoding" +// VideoNotifyEventNew constructs a VideoNotifyEvent value that implements xgb.Event from a byte slice. +func VideoNotifyEventNew(buf []byte) xgb.Event { + v := VideoNotifyEvent{} + b := 1 // don't read event number - b := 1 // skip error determinant - b += 1 // don't read error number + v.Reason = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + return v } -// SequenceId returns the sequence id attached to the BadBadEncoding error. -// This is mostly used internally. -func (err BadEncodingError) SequenceId() uint16 { - return err.Sequence -} +// Bytes writes a VideoNotifyEvent value to a byte slice. +func (v VideoNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 -// BadId returns the 'BadValue' number if one exists for the BadBadEncoding error. If no bad value exists, 0 is returned. -func (err BadEncodingError) BadId() uint32 { - return 0 + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Reason + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + return buf } -// Error returns a rudimentary string representation of the BadBadEncoding error. +// SequenceId returns the sequence id attached to the VideoNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v VideoNotifyEvent) SequenceId() uint16 { + return v.Sequence +} -func (err BadEncodingError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// String is a rudimentary string representation of VideoNotifyEvent. +func (v VideoNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew + xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew } -// BadBadControl is the error number for a BadBadControl. -const BadBadControl = 2 +const ( + VideoNotifyReasonStarted = 0 + VideoNotifyReasonStopped = 1 + VideoNotifyReasonBusy = 2 + VideoNotifyReasonPreempted = 3 + VideoNotifyReasonHardError = 4 +) -type BadControlError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Bool' -// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. -func BadControlErrorNew(buf []byte) xgb.Error { - v := BadControlError{} - v.NiceName = "BadControl" +// Skipping definition for base type 'Byte' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Card8' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Char' - return v -} +// Skipping definition for base type 'Void' -// SequenceId returns the sequence id attached to the BadBadControl error. -// This is mostly used internally. -func (err BadControlError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Double' -// BadId returns the 'BadValue' number if one exists for the BadBadControl error. If no bad value exists, 0 is returned. -func (err BadControlError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Float' -// Error returns a rudimentary string representation of the BadBadControl error. +// Skipping definition for base type 'Int16' -func (err BadControlError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Int32' -func init() { - xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew -} +// Skipping definition for base type 'Int8' -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests. +type GetPortAttributeCookie struct { *xgb.Cookie } -// QueryExtension sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() -func QueryExtension(c *xgb.Conn) QueryExtensionCookie { +// GetPortAttribute sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() +func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryExtensionRequest(c), cookie) - return QueryExtensionCookie{cookie} + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} } -// QueryExtensionUnchecked sends an unchecked request. +// GetPortAttributeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { +func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionRequest(c), cookie) - return QueryExtensionCookie{cookie} + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} } -// QueryExtensionReply represents the data returned from a QueryExtension request. -type QueryExtensionReply struct { +// GetPortAttributeReply represents the data returned from a GetPortAttribute request. +type GetPortAttributeReply 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 + Value int32 } -// Reply blocks and returns the reply data for a QueryExtension request. -func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { +// Reply blocks and returns the reply data for a GetPortAttribute request. +func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1242,12 +1241,12 @@ func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { if buf == nil { return nil, nil } - return queryExtensionReply(buf), nil + return getPortAttributeReply(buf), nil } -// queryExtensionReply reads a byte slice into a QueryExtensionReply value. -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) +// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. +func getPortAttributeReply(buf []byte) *GetPortAttributeReply { + v := new(GetPortAttributeReply) b := 1 // skip reply determinant b += 1 // padding @@ -1258,220 +1257,203 @@ func queryExtensionReply(buf []byte) *QueryExtensionReply { 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 + v.Value = int32(xgb.Get32(buf[b:])) + b += 4 return v } -// Write request to wire for QueryExtension -// queryExtensionRequest writes a QueryExtension request to a byte slice. -func queryExtensionRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GetPortAttribute +// getPortAttributeRequest writes a GetPortAttribute request to a byte slice. +func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 14 // 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + return buf } -// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. -type QueryAdaptorsCookie struct { +// GetStillCookie is a cookie used only for GetStill requests. +type GetStillCookie struct { *xgb.Cookie } -// QueryAdaptors sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() -func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { +// GetStill sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(queryAdaptorsRequest(c, Window), cookie) - return QueryAdaptorsCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} } -// QueryAdaptorsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { +// GetStillChecked sends a checked request. +// If an error occurs, it can be retrieved using GetStillCookie.Check() +func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryAdaptorsRequest(c, Window), cookie) - return QueryAdaptorsCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} } -// QueryAdaptorsReply represents the data returned from a QueryAdaptors request. -type QueryAdaptorsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumAdaptors uint16 - // padding: 22 bytes - Info []AdaptorInfo // size: AdaptorInfoListSize(Info) +// 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 GetStillCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a QueryAdaptors request. -func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryAdaptorsReply(buf), nil -} +// Write request to wire for GetStill +// getStillRequest writes a GetStill request to a byte slice. +func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) -// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value. -func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { - v := new(QueryAdaptorsReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XVIDEO"] + b += 1 - b += 1 // padding + buf[b] = 8 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Port)) b += 4 - v.NumAdaptors = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 - b += 22 // padding + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - v.Info = make([]AdaptorInfo, v.NumAdaptors) - b += AdaptorInfoReadList(buf[b:], v.Info) + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 - return v -} + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 -// Write request to wire for QueryAdaptors -// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice. -func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], VidW) + b += 2 - buf[b] = c.Extensions["XVIDEO"] - b += 1 + xgb.Put16(buf[b:], VidH) + b += 2 - buf[b] = 1 // request opcode - b += 1 + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], uint16(DrwY)) b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 return buf } -// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. -type QueryEncodingsCookie struct { +// GetVideoCookie is a cookie used only for GetVideo requests. +type GetVideoCookie struct { *xgb.Cookie } -// QueryEncodings sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() -func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { +// GetVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(queryEncodingsRequest(c, Port), cookie) - return QueryEncodingsCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} } -// QueryEncodingsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { +// GetVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using GetVideoCookie.Check() +func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryEncodingsRequest(c, Port), cookie) - return QueryEncodingsCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} } -// QueryEncodingsReply represents the data returned from a QueryEncodings request. -type QueryEncodingsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumEncodings uint16 - // padding: 22 bytes - Info []EncodingInfo // size: EncodingInfoListSize(Info) +// 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 GetVideoCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a QueryEncodings request. -func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryEncodingsReply(buf), nil -} +// Write request to wire for GetVideo +// getVideoRequest writes a GetVideo request to a byte slice. +func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) -// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. -func queryEncodingsReply(buf []byte) *QueryEncodingsReply { - v := new(QueryEncodingsReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XVIDEO"] + b += 1 - b += 1 // padding + buf[b] = 7 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Port)) b += 4 - v.NumEncodings = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 - b += 22 // padding + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - v.Info = make([]EncodingInfo, v.NumEncodings) - b += EncodingInfoReadList(buf[b:], v.Info) + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 - return v -} + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 -// Write request to wire for QueryEncodings -// queryEncodingsRequest writes a QueryEncodings request to a byte slice. -func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { - size := 8 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], VidW) + b += 2 - buf[b] = c.Extensions["XVIDEO"] - b += 1 + xgb.Put16(buf[b:], VidH) + b += 2 - buf[b] = 2 // request opcode - b += 1 + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], uint16(DrwY)) b += 2 - xgb.Put32(buf[b:], uint32(Port)) - b += 4 + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 return buf } @@ -1564,50 +1546,90 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { return buf } -// UngrabPortCookie is a cookie used only for UngrabPort requests. -type UngrabPortCookie struct { +// ListImageFormatsCookie is a cookie used only for ListImageFormats requests. +type ListImageFormatsCookie struct { *xgb.Cookie } -// UngrabPort sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { +// ListImageFormats sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() +func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) - return UngrabPortCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} } -// UngrabPortChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabPortCookie.Check() -func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { +// ListImageFormatsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) - return UngrabPortCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{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 UngrabPortCookie) Check() error { - return cook.Cookie.Check() +// ListImageFormatsReply represents the data returned from a ListImageFormats request. +type ListImageFormatsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumFormats uint32 + // padding: 20 bytes + Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) } -// Write request to wire for UngrabPort -// ungrabPortRequest writes a UngrabPort request to a byte slice. -func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { - size := 12 +// Reply blocks and returns the reply data for a ListImageFormats request. +func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listImageFormatsReply(buf), nil +} + +// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. +func listImageFormatsReply(buf []byte) *ListImageFormatsReply { + v := new(ListImageFormatsReply) + 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.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Format = make([]ImageFormatInfo, v.NumFormats) + b += ImageFormatInfoReadList(buf[b:], v.Format) + + return v +} + +// Write request to wire for ListImageFormats +// listImageFormatsRequest writes a ListImageFormats request to a byte slice. +func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1616,56 +1638,53 @@ func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { xgb.Put32(buf[b:], uint32(Port)) b += 4 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 - return buf } -// PutVideoCookie is a cookie used only for PutVideo requests. -type PutVideoCookie struct { +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { *xgb.Cookie } -// PutVideo sends an unchecked request. +// PutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { +func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutVideoCookie{cookie} + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} } -// PutVideoChecked sends a checked request. -// If an error occurs, it can be retrieved using PutVideoCookie.Check() -func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() +func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutVideoCookie{cookie} + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{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 PutVideoCookie) Check() error { +func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutVideo -// putVideoRequest writes a PutVideo request to a byte slice. -func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 +// Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. +func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1680,16 +1699,19 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], uint16(VidX)) + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 - xgb.Put16(buf[b:], uint16(VidY)) + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - xgb.Put16(buf[b:], VidW) + xgb.Put16(buf[b:], SrcW) b += 2 - xgb.Put16(buf[b:], VidH) + xgb.Put16(buf[b:], SrcH) b += 2 xgb.Put16(buf[b:], uint16(DrwX)) @@ -1704,6 +1726,15 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto xgb.Put16(buf[b:], DrwH) b += 2 + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + return buf } @@ -1792,42 +1823,42 @@ func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// GetVideoCookie is a cookie used only for GetVideo requests. -type GetVideoCookie struct { +// PutVideoCookie is a cookie used only for PutVideo requests. +type PutVideoCookie struct { *xgb.Cookie } -// GetVideo sends an unchecked request. +// PutVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { +func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetVideoCookie{cookie} + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} } -// GetVideoChecked sends a checked request. -// If an error occurs, it can be retrieved using GetVideoCookie.Check() -func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { +// PutVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using PutVideoCookie.Check() +func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetVideoCookie{cookie} + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{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 GetVideoCookie) Check() error { +func (cook PutVideoCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for GetVideo -// getVideoRequest writes a GetVideo request to a byte slice. -func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { +// Write request to wire for PutVideo +// putVideoRequest writes a PutVideo request to a byte slice. +func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 buf := make([]byte, size) @@ -1835,7 +1866,7 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1877,274 +1908,98 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// GetStillCookie is a cookie used only for GetStill requests. -type GetStillCookie struct { +// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. +type QueryAdaptorsCookie struct { *xgb.Cookie } -// GetStill sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetStillCookie{cookie} -} - -// GetStillChecked sends a checked request. -// If an error occurs, it can be retrieved using GetStillCookie.Check() -func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { +// QueryAdaptors sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() +func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetStillCookie{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 GetStillCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for GetStill -// getStillRequest writes a GetStill request to a byte slice. -func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - 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:], uint32(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], uint16(VidX)) - b += 2 - - xgb.Put16(buf[b:], uint16(VidY)) - b += 2 - - xgb.Put16(buf[b:], VidW) - b += 2 - - xgb.Put16(buf[b:], VidH) - b += 2 - - xgb.Put16(buf[b:], uint16(DrwX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DrwY)) - b += 2 - - xgb.Put16(buf[b:], DrwW) - b += 2 - - xgb.Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// StopVideoCookie is a cookie used only for StopVideo requests. -type StopVideoCookie struct { - *xgb.Cookie + cookie := c.NewCookie(true, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} } -// StopVideo sends an unchecked request. +// QueryAdaptorsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) - return StopVideoCookie{cookie} -} - -// StopVideoChecked sends a checked request. -// If an error occurs, it can be retrieved using StopVideoCookie.Check() -func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { +func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) - return StopVideoCookie{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 StopVideoCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for StopVideo -// stopVideoRequest writes a StopVideo request to a byte slice. -func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - 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:], uint32(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf + cookie := c.NewCookie(false, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} } -// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. -type SelectVideoNotifyCookie struct { - *xgb.Cookie +// QueryAdaptorsReply represents the data returned from a QueryAdaptors request. +type QueryAdaptorsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumAdaptors uint16 + // padding: 22 bytes + Info []AdaptorInfo // size: AdaptorInfoListSize(Info) } -// SelectVideoNotify sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") +// Reply blocks and returns the reply data for a QueryAdaptors request. +func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } - cookie := c.NewCookie(false, false) - c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) - return SelectVideoNotifyCookie{cookie} -} - -// SelectVideoNotifyChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() -func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + if buf == nil { + return nil, nil } - cookie := c.NewCookie(true, false) - c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) - return SelectVideoNotifyCookie{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 SelectVideoNotifyCookie) Check() error { - return cook.Cookie.Check() + return queryAdaptorsReply(buf), nil } -// Write request to wire for SelectVideoNotify -// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice. -func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 +// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value. +func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { + v := new(QueryAdaptorsReply) + b := 1 // skip reply determinant - buf[b] = 10 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests. -type SelectPortNotifyCookie struct { - *xgb.Cookie -} + v.NumAdaptors = xgb.Get16(buf[b:]) + b += 2 -// SelectPortNotify sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) - return SelectPortNotifyCookie{cookie} -} + b += 22 // padding -// SelectPortNotifyChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() -func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) - return SelectPortNotifyCookie{cookie} -} + v.Info = make([]AdaptorInfo, v.NumAdaptors) + b += AdaptorInfoReadList(buf[b:], v.Info) -// 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 SelectPortNotifyCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for SelectPortNotify -// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice. -func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { - size := 12 +// Write request to wire for QueryAdaptors +// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice. +func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] 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 b += 2 - xgb.Put32(buf[b:], uint32(Port)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - return buf } @@ -2261,104 +2116,45 @@ func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW return buf } -// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests. -type SetPortAttributeCookie struct { - *xgb.Cookie -} - -// SetPortAttribute sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) - return SetPortAttributeCookie{cookie} -} - -// SetPortAttributeChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() -func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) - return SetPortAttributeCookie{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 SetPortAttributeCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPortAttribute -// setPortAttributeRequest writes a SetPortAttribute request to a byte slice. -func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 - - buf[b] = 13 // 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(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Attribute)) - b += 4 - - xgb.Put32(buf[b:], uint32(Value)) - b += 4 - - return buf -} - -// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests. -type GetPortAttributeCookie struct { +// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. +type QueryEncodingsCookie struct { *xgb.Cookie } -// GetPortAttribute sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() -func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { +// QueryEncodings sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() +func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) - return GetPortAttributeCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// GetPortAttributeUnchecked sends an unchecked request. +// QueryEncodingsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { +func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) - return GetPortAttributeCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// GetPortAttributeReply represents the data returned from a GetPortAttribute request. -type GetPortAttributeReply struct { +// QueryEncodingsReply represents the data returned from a QueryEncodings request. +type QueryEncodingsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Value int32 + NumEncodings uint16 + // padding: 22 bytes + Info []EncodingInfo // size: EncodingInfoListSize(Info) } -// Reply blocks and returns the reply data for a GetPortAttribute request. -func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { +// Reply blocks and returns the reply data for a QueryEncodings request. +func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2366,12 +2162,12 @@ func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { if buf == nil { return nil, nil } - return getPortAttributeReply(buf), nil + return queryEncodingsReply(buf), nil } -// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. -func getPortAttributeReply(buf []byte) *GetPortAttributeReply { - v := new(GetPortAttributeReply) +// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. +func queryEncodingsReply(buf []byte) *QueryEncodingsReply { + v := new(QueryEncodingsReply) b := 1 // skip reply determinant b += 1 // padding @@ -2382,117 +2178,20 @@ func getPortAttributeReply(buf []byte) *GetPortAttributeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Value = int32(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for GetPortAttribute -// getPortAttributeRequest writes a GetPortAttribute request to a byte slice. -func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 - - buf[b] = 14 // 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(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Attribute)) - b += 4 - - return buf -} - -// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. -type QueryPortAttributesCookie struct { - *xgb.Cookie -} - -// QueryPortAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() -func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} -} - -// QueryPortAttributesUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} -} - -// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. -type QueryPortAttributesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumAttributes uint32 - TextSize uint32 - // padding: 16 bytes - Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) -} - -// Reply blocks and returns the reply data for a QueryPortAttributes request. -func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryPortAttributesReply(buf), nil -} - -// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. -func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { - v := new(QueryPortAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) + v.NumEncodings = xgb.Get16(buf[b:]) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAttributes = xgb.Get32(buf[b:]) - b += 4 - - v.TextSize = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding + b += 22 // padding - v.Attributes = make([]AttributeInfo, v.NumAttributes) - b += AttributeInfoReadList(buf[b:], v.Attributes) + v.Info = make([]EncodingInfo, v.NumEncodings) + b += EncodingInfoReadList(buf[b:], v.Info) return v } -// Write request to wire for QueryPortAttributes -// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice. -func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { +// Write request to wire for QueryEncodings +// queryEncodingsRequest writes a QueryEncodings request to a byte slice. +func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -2500,7 +2199,7 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 15 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2512,45 +2211,44 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { return buf } -// ListImageFormatsCookie is a cookie used only for ListImageFormats requests. -type ListImageFormatsCookie struct { +// QueryExtensionCookie is a cookie used only for QueryExtension requests. +type QueryExtensionCookie struct { *xgb.Cookie } -// ListImageFormats sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() -func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { +// QueryExtension sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() +func QueryExtension(c *xgb.Conn) QueryExtensionCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listImageFormatsRequest(c, Port), cookie) - return ListImageFormatsCookie{cookie} + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} } -// ListImageFormatsUnchecked sends an unchecked request. +// QueryExtensionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { +func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listImageFormatsRequest(c, Port), cookie) - return ListImageFormatsCookie{cookie} + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} } -// ListImageFormatsReply represents the data returned from a ListImageFormats request. -type ListImageFormatsReply struct { +// QueryExtensionReply represents the data returned from a QueryExtension request. +type QueryExtensionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumFormats uint32 - // padding: 20 bytes - Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) + Major uint16 + Minor uint16 } -// Reply blocks and returns the reply data for a ListImageFormats request. -func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { +// Reply blocks and returns the reply data for a QueryExtension request. +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2558,12 +2256,12 @@ func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { if buf == nil { return nil, nil } - return listImageFormatsReply(buf), nil + return queryExtensionReply(buf), nil } -// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. -func listImageFormatsReply(buf []byte) *ListImageFormatsReply { - v := new(ListImageFormatsReply) +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) b := 1 // skip reply determinant b += 1 // padding @@ -2574,36 +2272,31 @@ func listImageFormatsReply(buf []byte) *ListImageFormatsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumFormats = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding + v.Major = xgb.Get16(buf[b:]) + b += 2 - v.Format = make([]ImageFormatInfo, v.NumFormats) - b += ImageFormatInfoReadList(buf[b:], v.Format) + v.Minor = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for ListImageFormats -// listImageFormatsRequest writes a ListImageFormats request to a byte slice. -func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { - size := 8 +// Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. +func queryExtensionRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 16 // request opcode + buf[b] = 0 // 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(Port)) - b += 4 - return buf } @@ -2735,50 +2428,149 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. +type QueryPortAttributesCookie struct { *xgb.Cookie } -// PutImage sends an unchecked request. +// QueryPortAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() +func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// QueryPortAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { +func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. +type QueryPortAttributesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumAttributes uint32 + TextSize uint32 + // padding: 16 bytes + Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) +} + +// Reply blocks and returns the reply data for a QueryPortAttributes request. +func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPortAttributesReply(buf), nil +} + +// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. +func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { + v := new(QueryPortAttributesReply) + 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.NumAttributes = xgb.Get32(buf[b:]) + b += 4 + + v.TextSize = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.Attributes = make([]AttributeInfo, v.NumAttributes) + b += AttributeInfoReadList(buf[b:], v.Attributes) + + return v +} + +// Write request to wire for QueryPortAttributes +// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice. +func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 15 // 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(Port)) + b += 4 + + return buf +} + +// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests. +type SelectPortNotifyCookie struct { + *xgb.Cookie +} + +// SelectPortNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} } -// PutImageChecked sends a checked request. -// If an error occurs, it can be retrieved using PutImageCookie.Check() -func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { +// SelectPortNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() +func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{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 PutImageCookie) Check() error { +func (cook SelectPortNotifyCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutImage -// putImageRequest writes a PutImage request to a byte slice. -func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { - size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) +// Write request to wire for SelectPortNotify +// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice. +func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2787,47 +2579,139 @@ func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto xgb.Put32(buf[b:], uint32(Port)) b += 4 + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. +type SelectVideoNotifyCookie struct { + *xgb.Cookie +} + +// SelectVideoNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +// SelectVideoNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() +func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{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 SelectVideoNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectVideoNotify +// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice. +func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - xgb.Put32(buf[b:], Id) - b += 4 + b += 3 // padding - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 + return buf +} - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 +// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests. +type SetPortAttributeCookie struct { + *xgb.Cookie +} - xgb.Put16(buf[b:], SrcW) - b += 2 +// SetPortAttribute sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} - xgb.Put16(buf[b:], SrcH) - b += 2 +// SetPortAttributeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() +func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} - xgb.Put16(buf[b:], uint16(DrwX)) - b += 2 +// 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 SetPortAttributeCookie) Check() error { + return cook.Cookie.Check() +} - xgb.Put16(buf[b:], uint16(DrwY)) - b += 2 +// Write request to wire for SetPortAttribute +// setPortAttributeRequest writes a SetPortAttribute request to a byte slice. +func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) - xgb.Put16(buf[b:], DrwW) - b += 2 + buf[b] = c.Extensions["XVIDEO"] + b += 1 - xgb.Put16(buf[b:], DrwH) - b += 2 + buf[b] = 13 // request opcode + b += 1 - xgb.Put16(buf[b:], Width) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], Height) - b += 2 + xgb.Put32(buf[b:], uint32(Port)) + b += 4 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(Value)) + b += 4 return buf } @@ -2936,3 +2820,119 @@ func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xpr return buf } + +// StopVideoCookie is a cookie used only for StopVideo requests. +type StopVideoCookie struct { + *xgb.Cookie +} + +// StopVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +// StopVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using StopVideoCookie.Check() +func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{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 StopVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StopVideo +// stopVideoRequest writes a StopVideo request to a byte slice. +func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// UngrabPortCookie is a cookie used only for UngrabPort requests. +type UngrabPortCookie struct { + *xgb.Cookie +} + +// UngrabPort sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +// UngrabPortChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPortCookie.Check() +func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{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 UngrabPortCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabPort +// ungrabPortRequest writes a UngrabPort request to a byte slice. +func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + 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:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} diff --git a/nexgb/xvmc/xvmc.go b/nexgb/xvmc/xvmc.go index 0ddf369..9bcb60b 100644 --- a/nexgb/xvmc/xvmc.go +++ b/nexgb/xvmc/xvmc.go @@ -2,7 +2,7 @@ package xvmc /* - This file was generated by xvmc.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xvmc.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,30 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo-MotionCompensation"] = 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 Context uint32 func NewContextId(c *xgb.Conn) (Context, error) { @@ -75,24 +51,24 @@ func NewContextId(c *xgb.Conn) (Context, error) { return Context(id), nil } -type Surface uint32 +type Subpicture uint32 -func NewSurfaceId(c *xgb.Conn) (Surface, error) { +func NewSubpictureId(c *xgb.Conn) (Subpicture, error) { id, err := c.NewId() if err != nil { return 0, err } - return Surface(id), nil + return Subpicture(id), nil } -type Subpicture uint32 +type Surface uint32 -func NewSubpictureId(c *xgb.Conn) (Subpicture, error) { +func NewSurfaceId(c *xgb.Conn) (Surface, error) { id, err := c.NewId() if err != nil { return 0, err } - return Subpicture(id), nil + return Surface(id), nil } type SurfaceInfo struct { @@ -198,44 +174,71 @@ func SurfaceInfoListBytes(buf []byte, list []SurfaceInfo) 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' + +// CreateContextCookie is a cookie used only for CreateContext requests. +type CreateContextCookie 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 { +// 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, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) + return CreateContextCookie{cookie} } -// QueryVersionUnchecked 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 QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { +func CreateContextUnchecked(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) + return CreateContextCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply 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 - Major uint32 - Minor uint32 + WidthActual uint16 + HeightActual uint16 + FlagsReturn uint32 + // padding: 20 bytes + PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) } -// 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 CreateContext request. +func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -243,12 +246,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return createContextReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// 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 @@ -259,73 +262,107 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Major = xgb.Get32(buf[b:]) - b += 4 + v.WidthActual = xgb.Get16(buf[b:]) + b += 2 - v.Minor = xgb.Get32(buf[b:]) + v.HeightActual = xgb.Get16(buf[b:]) + b += 2 + + v.FlagsReturn = xgb.Get32(buf[b:]) b += 4 + b += 20 // padding + + v.PrivData = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PrivData[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + 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 CreateContext +// createContextRequest writes a CreateContext request to a byte slice. +func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) []byte { + size := 24 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] b += 1 - buf[b] = 0 // request opcode + 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(ContextId)) + b += 4 + + xgb.Put32(buf[b:], uint32(PortId)) + b += 4 + + xgb.Put32(buf[b:], uint32(SurfaceId)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], Flags) + b += 4 + return buf } -// ListSurfaceTypesCookie is a cookie used only for ListSurfaceTypes requests. -type ListSurfaceTypesCookie struct { +// CreateSubpictureCookie is a cookie used only for CreateSubpicture requests. +type CreateSubpictureCookie struct { *xgb.Cookie } -// ListSurfaceTypes sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListSurfaceTypesCookie.Reply() -func ListSurfaceTypes(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { +// CreateSubpicture sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateSubpictureCookie.Reply() +func CreateSubpicture(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'ListSurfaceTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateSubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) - return ListSurfaceTypesCookie{cookie} + c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) + return CreateSubpictureCookie{cookie} } -// ListSurfaceTypesUnchecked sends an unchecked request. +// CreateSubpictureUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListSurfaceTypesUnchecked(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { +func CreateSubpictureUnchecked(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'ListSurfaceTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateSubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) - return ListSurfaceTypesCookie{cookie} + c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) + return CreateSubpictureCookie{cookie} } -// ListSurfaceTypesReply represents the data returned from a ListSurfaceTypes request. -type ListSurfaceTypesReply struct { +// CreateSubpictureReply represents the data returned from a CreateSubpicture request. +type CreateSubpictureReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Num uint32 - // padding: 20 bytes - Surfaces []SurfaceInfo // size: xgb.Pad((int(Num) * 24)) + WidthActual uint16 + HeightActual uint16 + NumPaletteEntries uint16 + EntryBytes uint16 + ComponentOrder []byte // size: 4 + // padding: 12 bytes + PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a ListSurfaceTypes request. -func (cook ListSurfaceTypesCookie) Reply() (*ListSurfaceTypesReply, error) { +// Reply blocks and returns the reply data for a CreateSubpicture request. +func (cook CreateSubpictureCookie) Reply() (*CreateSubpictureReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -333,12 +370,12 @@ func (cook ListSurfaceTypesCookie) Reply() (*ListSurfaceTypesReply, error) { if buf == nil { return nil, nil } - return listSurfaceTypesReply(buf), nil + return createSubpictureReply(buf), nil } -// listSurfaceTypesReply reads a byte slice into a ListSurfaceTypesReply value. -func listSurfaceTypesReply(buf []byte) *ListSurfaceTypesReply { - v := new(ListSurfaceTypesReply) +// createSubpictureReply reads a byte slice into a CreateSubpictureReply value. +func createSubpictureReply(buf []byte) *CreateSubpictureReply { + v := new(CreateSubpictureReply) b := 1 // skip reply determinant b += 1 // padding @@ -349,80 +386,106 @@ func listSurfaceTypesReply(buf []byte) *ListSurfaceTypesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Num = xgb.Get32(buf[b:]) - b += 4 + v.WidthActual = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding + v.HeightActual = xgb.Get16(buf[b:]) + b += 2 - v.Surfaces = make([]SurfaceInfo, v.Num) - b += SurfaceInfoReadList(buf[b:], v.Surfaces) + v.NumPaletteEntries = xgb.Get16(buf[b:]) + b += 2 + + v.EntryBytes = xgb.Get16(buf[b:]) + b += 2 + + v.ComponentOrder = make([]byte, 4) + copy(v.ComponentOrder[:4], buf[b:]) + b += xgb.Pad(int(4)) + + b += 12 // padding + + v.PrivData = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PrivData[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for ListSurfaceTypes -// listSurfaceTypesRequest writes a ListSurfaceTypes request to a byte slice. -func listSurfaceTypesRequest(c *xgb.Conn, PortId xv.Port) []byte { - size := 8 +// Write request to wire for CreateSubpicture +// createSubpictureRequest writes a CreateSubpicture request to a byte slice. +func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] b += 1 - buf[b] = 1 // request opcode + 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:], uint32(PortId)) + xgb.Put32(buf[b:], uint32(SubpictureId)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], XvimageId) b += 4 + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + return buf } -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { +// CreateSurfaceCookie is a cookie used only for CreateSurface requests. +type CreateSurfaceCookie 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, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { +// CreateSurface sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateSurfaceCookie.Reply() +func CreateSurface(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) - return CreateContextCookie{cookie} + c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) + return CreateSurfaceCookie{cookie} } -// CreateContextUnchecked sends an unchecked request. +// CreateSurfaceUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateContextUnchecked(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { +func CreateSurfaceUnchecked(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) - return CreateContextCookie{cookie} + c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) + return CreateSurfaceCookie{cookie} } -// CreateContextReply represents the data returned from a CreateContext request. -type CreateContextReply struct { +// CreateSurfaceReply represents the data returned from a CreateSurface request. +type CreateSurfaceReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - WidthActual uint16 - HeightActual uint16 - FlagsReturn uint32 - // padding: 20 bytes + // padding: 24 bytes PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a CreateContext request. -func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { +// Reply blocks and returns the reply data for a CreateSurface request. +func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -430,12 +493,12 @@ func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { if buf == nil { return nil, nil } - return createContextReply(buf), nil + return createSurfaceReply(buf), nil } -// createContextReply reads a byte slice into a CreateContextReply value. -func createContextReply(buf []byte) *CreateContextReply { - v := new(CreateContextReply) +// createSurfaceReply reads a byte slice into a CreateSurfaceReply value. +func createSurfaceReply(buf []byte) *CreateSurfaceReply { + v := new(CreateSurfaceReply) b := 1 // skip reply determinant b += 1 // padding @@ -446,16 +509,7 @@ func createContextReply(buf []byte) *CreateContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.WidthActual = xgb.Get16(buf[b:]) - b += 2 - - v.HeightActual = xgb.Get16(buf[b:]) - b += 2 - - v.FlagsReturn = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding + b += 24 // padding v.PrivData = make([]uint32, v.Length) for i := 0; i < int(v.Length); i++ { @@ -467,38 +521,26 @@ func createContextReply(buf []byte) *CreateContextReply { return v } -// Write request to wire for CreateContext -// createContextRequest writes a CreateContext request to a byte slice. -func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) []byte { - size := 24 +// Write request to wire for CreateSurface +// createSurfaceRequest writes a CreateSurface request to a byte slice. +func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] b += 1 - buf[b] = 2 // request opcode + 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:], uint32(ContextId)) - b += 4 - - xgb.Put32(buf[b:], uint32(PortId)) - b += 4 - xgb.Put32(buf[b:], uint32(SurfaceId)) b += 4 - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - xgb.Put32(buf[b:], Flags) + xgb.Put32(buf[b:], uint32(ContextId)) b += 4 return buf @@ -559,99 +601,56 @@ func destroyContextRequest(c *xgb.Conn, ContextId Context) []byte { return buf } -// CreateSurfaceCookie is a cookie used only for CreateSurface requests. -type CreateSurfaceCookie struct { +// DestroySubpictureCookie is a cookie used only for DestroySubpicture requests. +type DestroySubpictureCookie struct { *xgb.Cookie } -// CreateSurface sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateSurfaceCookie.Reply() -func CreateSurface(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { - if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) - return CreateSurfaceCookie{cookie} -} - -// CreateSurfaceUnchecked sends an unchecked request. +// DestroySubpicture sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateSurfaceUnchecked(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { +func DestroySubpicture(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroySubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) - return CreateSurfaceCookie{cookie} -} - -// CreateSurfaceReply represents the data returned from a CreateSurface request. -type CreateSurfaceReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 24 bytes - PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) + return DestroySubpictureCookie{cookie} } -// Reply blocks and returns the reply data for a CreateSurface request. -func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DestroySubpictureChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroySubpictureCookie.Check() +func DestroySubpictureChecked(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { + if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { + panic("Cannot issue request 'DestroySubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } - return createSurfaceReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) + return DestroySubpictureCookie{cookie} } -// createSurfaceReply reads a byte slice into a CreateSurfaceReply value. -func createSurfaceReply(buf []byte) *CreateSurfaceReply { - v := new(CreateSurfaceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.PrivData = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PrivData[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - 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 DestroySubpictureCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for CreateSurface -// createSurfaceRequest writes a CreateSurface request to a byte slice. -func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []byte { - size := 12 +// Write request to wire for DestroySubpicture +// destroySubpictureRequest writes a DestroySubpicture request to a byte slice. +func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] 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 b += 2 - xgb.Put32(buf[b:], uint32(SurfaceId)) - b += 4 - - xgb.Put32(buf[b:], uint32(ContextId)) + xgb.Put32(buf[b:], uint32(SubpictureId)) b += 4 return buf @@ -712,49 +711,45 @@ func destroySurfaceRequest(c *xgb.Conn, SurfaceId Surface) []byte { return buf } -// CreateSubpictureCookie is a cookie used only for CreateSubpicture requests. -type CreateSubpictureCookie struct { +// ListSubpictureTypesCookie is a cookie used only for ListSubpictureTypes requests. +type ListSubpictureTypesCookie struct { *xgb.Cookie } -// CreateSubpicture sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateSubpictureCookie.Reply() -func CreateSubpicture(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { +// ListSubpictureTypes sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSubpictureTypesCookie.Reply() +func ListSubpictureTypes(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateSubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSubpictureTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) - return CreateSubpictureCookie{cookie} + c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) + return ListSubpictureTypesCookie{cookie} } -// CreateSubpictureUnchecked sends an unchecked request. +// ListSubpictureTypesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateSubpictureUnchecked(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { +func ListSubpictureTypesUnchecked(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateSubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSubpictureTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) - return CreateSubpictureCookie{cookie} + c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) + return ListSubpictureTypesCookie{cookie} } -// CreateSubpictureReply represents the data returned from a CreateSubpicture request. -type CreateSubpictureReply struct { +// ListSubpictureTypesReply represents the data returned from a ListSubpictureTypes request. +type ListSubpictureTypesReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - WidthActual uint16 - HeightActual uint16 - NumPaletteEntries uint16 - EntryBytes uint16 - ComponentOrder []byte // size: 4 - // padding: 12 bytes - PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) + Num uint32 + // padding: 20 bytes + Types []xv.ImageFormatInfo // size: xv.ImageFormatInfoListSize(Types) } -// Reply blocks and returns the reply data for a CreateSubpicture request. -func (cook CreateSubpictureCookie) Reply() (*CreateSubpictureReply, error) { +// Reply blocks and returns the reply data for a ListSubpictureTypes request. +func (cook ListSubpictureTypesCookie) Reply() (*ListSubpictureTypesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -762,12 +757,12 @@ func (cook CreateSubpictureCookie) Reply() (*CreateSubpictureReply, error) { if buf == nil { return nil, nil } - return createSubpictureReply(buf), nil + return listSubpictureTypesReply(buf), nil } -// createSubpictureReply reads a byte slice into a CreateSubpictureReply value. -func createSubpictureReply(buf []byte) *CreateSubpictureReply { - v := new(CreateSubpictureReply) +// listSubpictureTypesReply reads a byte slice into a ListSubpictureTypesReply value. +func listSubpictureTypesReply(buf []byte) *ListSubpictureTypesReply { + v := new(ListSubpictureTypesReply) b := 1 // skip reply determinant b += 1 // padding @@ -778,104 +773,118 @@ func createSubpictureReply(buf []byte) *CreateSubpictureReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.WidthActual = xgb.Get16(buf[b:]) - b += 2 - - v.HeightActual = xgb.Get16(buf[b:]) - b += 2 - - v.NumPaletteEntries = xgb.Get16(buf[b:]) - b += 2 - - v.EntryBytes = xgb.Get16(buf[b:]) - b += 2 - - v.ComponentOrder = make([]byte, 4) - copy(v.ComponentOrder[:4], buf[b:]) - b += xgb.Pad(int(4)) + v.Num = xgb.Get32(buf[b:]) + b += 4 - b += 12 // padding + b += 20 // padding - v.PrivData = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PrivData[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Types = make([]xv.ImageFormatInfo, v.Num) + b += xv.ImageFormatInfoReadList(buf[b:], v.Types) return v } -// Write request to wire for CreateSubpicture -// createSubpictureRequest writes a CreateSubpicture request to a byte slice. -func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) []byte { - size := 20 +// Write request to wire for ListSubpictureTypes +// listSubpictureTypesRequest writes a ListSubpictureTypes request to a byte slice. +func listSubpictureTypesRequest(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] 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 b += 2 - xgb.Put32(buf[b:], uint32(SubpictureId)) - b += 4 - - xgb.Put32(buf[b:], uint32(Context)) + xgb.Put32(buf[b:], uint32(PortId)) b += 4 - xgb.Put32(buf[b:], XvimageId) + xgb.Put32(buf[b:], uint32(SurfaceId)) b += 4 - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - return buf } -// DestroySubpictureCookie is a cookie used only for DestroySubpicture requests. -type DestroySubpictureCookie struct { +// ListSurfaceTypesCookie is a cookie used only for ListSurfaceTypes requests. +type ListSurfaceTypesCookie struct { *xgb.Cookie } -// DestroySubpicture sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroySubpicture(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { +// ListSurfaceTypes sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSurfaceTypesCookie.Reply() +func ListSurfaceTypes(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'DestroySubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSurfaceTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) - return DestroySubpictureCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) + return ListSurfaceTypesCookie{cookie} } -// DestroySubpictureChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroySubpictureCookie.Check() -func DestroySubpictureChecked(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { +// ListSurfaceTypesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListSurfaceTypesUnchecked(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'DestroySubpicture' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSurfaceTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) - return DestroySubpictureCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) + return ListSurfaceTypesCookie{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 DestroySubpictureCookie) Check() error { - return cook.Cookie.Check() +// ListSurfaceTypesReply represents the data returned from a ListSurfaceTypes request. +type ListSurfaceTypesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Num uint32 + // padding: 20 bytes + Surfaces []SurfaceInfo // size: xgb.Pad((int(Num) * 24)) } -// Write request to wire for DestroySubpicture -// destroySubpictureRequest writes a DestroySubpicture request to a byte slice. -func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte { +// Reply blocks and returns the reply data for a ListSurfaceTypes request. +func (cook ListSurfaceTypesCookie) Reply() (*ListSurfaceTypesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSurfaceTypesReply(buf), nil +} + +// listSurfaceTypesReply reads a byte slice into a ListSurfaceTypesReply value. +func listSurfaceTypesReply(buf []byte) *ListSurfaceTypesReply { + v := new(ListSurfaceTypesReply) + 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.Num = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Surfaces = make([]SurfaceInfo, v.Num) + b += SurfaceInfoReadList(buf[b:], v.Surfaces) + + return v +} + +// Write request to wire for ListSurfaceTypes +// listSurfaceTypesRequest writes a ListSurfaceTypes request to a byte slice. +func listSurfaceTypesRequest(c *xgb.Conn, PortId xv.Port) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -883,57 +892,56 @@ func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte { buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] b += 1 - buf[b] = 7 // request opcode + 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(SubpictureId)) + xgb.Put32(buf[b:], uint32(PortId)) b += 4 return buf } -// ListSubpictureTypesCookie is a cookie used only for ListSubpictureTypes requests. -type ListSubpictureTypesCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// ListSubpictureTypes sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListSubpictureTypesCookie.Reply() -func ListSubpictureTypes(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { +// 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["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'ListSubpictureTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) - return ListSubpictureTypesCookie{cookie} + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} } -// ListSubpictureTypesUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListSubpictureTypesUnchecked(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'ListSubpictureTypes' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) - return ListSubpictureTypesCookie{cookie} + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} } -// ListSubpictureTypesReply represents the data returned from a ListSubpictureTypes request. -type ListSubpictureTypesReply struct { +// 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 - Num uint32 - // padding: 20 bytes - Types []xv.ImageFormatInfo // size: xv.ImageFormatInfoListSize(Types) + Major uint32 + Minor uint32 } -// Reply blocks and returns the reply data for a ListSubpictureTypes request. -func (cook ListSubpictureTypesCookie) Reply() (*ListSubpictureTypesReply, error) { +// 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 @@ -941,12 +949,12 @@ func (cook ListSubpictureTypesCookie) Reply() (*ListSubpictureTypesReply, error) if buf == nil { return nil, nil } - return listSubpictureTypesReply(buf), nil + return queryVersionReply(buf), nil } -// listSubpictureTypesReply reads a byte slice into a ListSubpictureTypesReply value. -func listSubpictureTypesReply(buf []byte) *ListSubpictureTypesReply { - v := new(ListSubpictureTypesReply) +// 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 @@ -957,38 +965,30 @@ func listSubpictureTypesReply(buf []byte) *ListSubpictureTypesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Num = xgb.Get32(buf[b:]) + v.Major = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding - - v.Types = make([]xv.ImageFormatInfo, v.Num) - b += xv.ImageFormatInfoReadList(buf[b:], v.Types) + v.Minor = xgb.Get32(buf[b:]) + b += 4 return v } -// Write request to wire for ListSubpictureTypes -// listSubpictureTypesRequest writes a ListSubpictureTypes request to a byte slice. -func listSubpictureTypesRequest(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) []byte { - size := 12 +// 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["XVIDEO-MOTIONCOMPENSATION"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 0 // 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(PortId)) - b += 4 - - xgb.Put32(buf[b:], uint32(SurfaceId)) - b += 4 - return buf } |