From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/bigreq/bigreq.go | 20 +- nexgb/composite/composite.go | 584 +- nexgb/damage/damage.go | 346 +- nexgb/dpms/dpms.go | 548 +- nexgb/dri2/dri2.go | 912 +- nexgb/ge/ge.go | 20 +- nexgb/glx/glx.go | 9028 +++++++++---------- nexgb/randr/randr.go | 4112 ++++----- nexgb/record/record.go | 838 +- nexgb/render/render.go | 4026 ++++----- nexgb/res/res.go | 318 +- nexgb/screensaver/screensaver.go | 336 +- nexgb/shape/shape.go | 704 +- nexgb/shm/shm.go | 538 +- nexgb/sync/sync.go | 2156 ++--- nexgb/xcmisc/xcmisc.go | 164 +- nexgb/xevie/xevie.go | 292 +- nexgb/xf86dri/xf86dri.go | 978 +- nexgb/xf86vidmode/xf86vidmode.go | 2536 +++--- nexgb/xfixes/xfixes.go | 2412 ++--- nexgb/xinerama/xinerama.go | 394 +- nexgb/xinput/xinput.go | 8174 ++++++++--------- nexgb/xprint/xprint.go | 2418 ++--- nexgb/xproto/xproto.go | 17714 ++++++++++++++++++------------------- nexgb/xselinux/xselinux.go | 1762 ++-- nexgb/xtest/xtest.go | 212 +- nexgb/xv/xv.go | 2542 +++--- nexgb/xvmc/xvmc.go | 720 +- 28 files changed, 32452 insertions(+), 32352 deletions(-) (limited to 'nexgb') 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,110 +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 { - size := 12 - b := 0 - buf := make([]byte, size) +// 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 +} - buf[b] = c.Extensions["COMPOSITE"] - b += 1 +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant - buf[b] = 2 // 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(Window)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - buf[b] = Update - b += 1 - - b += 3 // padding - - return buf -} - -// UnredirectWindowCookie is a cookie used only for UnredirectWindow requests. -type UnredirectWindowCookie struct { - *xgb.Cookie -} + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 -// UnredirectWindow 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 { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'UnredirectWindow' 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} -} + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 -// 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 'UnredirectWindow' 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} -} + b += 16 // 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 UnredirectWindowCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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) @@ -331,59 +360,57 @@ 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] = 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 } -// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. -type UnredirectSubwindowsCookie struct { +// RedirectSubwindowsCookie is a cookie used only for RedirectSubwindows requests. +type RedirectSubwindowsCookie struct { *xgb.Cookie } -// UnredirectSubwindows 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 UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { +func RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { 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 'RedirectSubwindows' 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(redirectSubwindowsRequest(c, Window, Update), cookie) + return RedirectSubwindowsCookie{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 { +// 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 'UnredirectSubwindows' 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(unredirectSubwindowsRequest(c, Window, Update), cookie) - return UnredirectSubwindowsCookie{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 UnredirectSubwindowsCookie) Check() error { +func (cook RedirectSubwindowsCookie) 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 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) @@ -391,7 +418,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] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -408,42 +435,42 @@ func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) return buf } -// CreateRegionFromBorderClipCookie is a cookie used only for CreateRegionFromBorderClip requests. -type CreateRegionFromBorderClipCookie struct { +// RedirectWindowCookie is a cookie used only for RedirectWindow requests. +type RedirectWindowCookie struct { *xgb.Cookie } -// CreateRegionFromBorderClip 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 CreateRegionFromBorderClip(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { +func RedirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { 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 'RedirectWindow' 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(redirectWindowRequest(c, Window, Update), cookie) + return RedirectWindowCookie{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 { +// 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 'CreateRegionFromBorderClip' 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(createRegionFromBorderClipRequest(c, Region, Window), cookie) - return CreateRegionFromBorderClipCookie{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 CreateRegionFromBorderClipCookie) Check() error { +func (cook RedirectWindowCookie) 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 { +// 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) @@ -451,65 +478,67 @@ func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 5 // 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(Region)) - b += 4 - xgb.Put32(buf[b:], uint32(Window)) b += 4 + buf[b] = Update + b += 1 + + b += 3 // padding + return buf } -// NameWindowPixmapCookie is a cookie used only for NameWindowPixmap requests. -type NameWindowPixmapCookie struct { +// ReleaseOverlayWindowCookie is a cookie used only for ReleaseOverlayWindow requests. +type ReleaseOverlayWindowCookie struct { *xgb.Cookie } -// NameWindowPixmap 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 NameWindowPixmap(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { +func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { 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 'ReleaseOverlayWindow' 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(releaseOverlayWindowRequest(c, Window), cookie) + return ReleaseOverlayWindowCookie{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 { +// 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 'NameWindowPixmap' 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(nameWindowPixmapRequest(c, Window, Pixmap), cookie) - return NameWindowPixmapCookie{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 NameWindowPixmapCookie) Check() error { +func (cook ReleaseOverlayWindowCookie) 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 { - 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] = 6 // request opcode + buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -518,92 +547,53 @@ 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 { +// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. +type UnredirectSubwindowsCookie 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. +// UnredirectSubwindows 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 { +func UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'GetOverlayWindow' 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, 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 + cookie := c.NewCookie(false, false) + c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) + return UnredirectSubwindowsCookie{cookie} } -// 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 +// 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 'UnredirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") } - return getOverlayWindowReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) + return UnredirectSubwindowsCookie{cookie} } -// 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 +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// 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 +// 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) buf[b] = c.Extensions["COMPOSITE"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -612,53 +602,58 @@ func getOverlayWindowRequest(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 } -// 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 + return buf +} - 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,121 @@ 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.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 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] = 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + b += AttachFormatListBytes(buf[b:], Attachments) + + return buf +} + +// GetMSCCookie is a cookie used only for GetMSC requests. +type GetMSCCookie 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. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMSCUnchecked(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(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 +} + +// 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 + } + return getMSCReply(buf), nil +} + +// 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 @@ -980,23 +1092,138 @@ func copyRegionReply(buf []byte) *CopyRegionReply { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + 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 +} + +// 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] = 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(Drawable)) + b += 4 + + 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 + + v.ValueHi = xgb.Get32(buf[b:]) + b += 4 + + v.ValueLo = xgb.Get32(buf[b:]) b += 4 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 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] = 6 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1005,59 +1232,50 @@ 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) - b += 4 - - xgb.Put32(buf[b:], Src) + xgb.Put32(buf[b:], Param) b += 4 return buf } -// GetBuffersWithFormatCookie is a cookie used only for GetBuffersWithFormat requests. -type GetBuffersWithFormatCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie 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 { +// 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 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' 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(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetBuffersWithFormatUnchecked 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 GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { 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 'QueryVersion' 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(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetBuffersWithFormatReply represents the data returned from a GetBuffersWithFormat request. -type GetBuffersWithFormatReply 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 - Width uint32 - Height uint32 - Count uint32 - // padding: 12 bytes - Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) + MajorVersion uint32 + MinorVersion 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 QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1065,12 +1283,12 @@ func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, erro if buf == nil { return nil, nil } - return getBuffersWithFormatReply(buf), nil + return queryVersionReply(buf), nil } -// getBuffersWithFormatReply reads a byte slice into a GetBuffersWithFormatReply value. -func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { - v := new(GetBuffersWithFormatReply) +// 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 @@ -1081,47 +1299,37 @@ func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { 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:]) + v.MajorVersion = xgb.Get32(buf[b:]) b += 4 - v.Count = xgb.Get32(buf[b:]) + v.MinorVersion = 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 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 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] = 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(Drawable)) + xgb.Put32(buf[b:], MajorVersion) b += 4 - xgb.Put32(buf[b:], Count) + xgb.Put32(buf[b:], MinorVersion) b += 4 - b += AttachFormatListBytes(buf[b:], Attachments) - 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,39 +40,537 @@ func init() { xgb.NewExtErrorFuncs["GLX"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' +// BadBadContext is the error number for a BadBadContext. +const BadBadContext = 0 + +type BadContextError GenericError + +// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContext" + return v +} + +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} + +// 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 +} + +// Error returns a rudimentary string representation of the BadBadContext error. +func (err BadContextError) 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 "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][0] = BadContextErrorNew +} + +// BadBadContextState is the error number for a BadBadContextState. +const BadBadContextState = 1 + +type BadContextStateError GenericError + +// BadContextStateErrorNew constructs a BadContextStateError value that implements xgb.Error from a byte slice. +func BadContextStateErrorNew(buf []byte) xgb.Error { + v := BadContextStateError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContextState" + return v +} + +// SequenceId returns the sequence id attached to the BadBadContextState error. +// This is mostly used internally. +func (err BadContextStateError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadContextState error. If no bad value exists, 0 is returned. +func (err BadContextStateError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadContextState error. +func (err BadContextStateError) 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 "BadBadContextState {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][1] = BadContextStateErrorNew +} + +// BadBadContextTag is the error number for a BadBadContextTag. +const BadBadContextTag = 4 + +type BadContextTagError 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" + return v +} + +// SequenceId returns the sequence id attached to the BadBadContextTag error. +// This is mostly used internally. +func (err BadContextTagError) 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 { + return 0 +} + +// 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 "BadBadContextTag {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][4] = BadContextTagErrorNew +} + +// BadBadCurrentDrawable is the error number for a BadBadCurrentDrawable. +const BadBadCurrentDrawable = 11 + +type BadCurrentDrawableError 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" + return v +} + +// SequenceId returns the sequence id attached to the BadBadCurrentDrawable error. +// This is mostly used internally. +func (err BadCurrentDrawableError) 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 { + return 0 +} + +// 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 "BadBadCurrentDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][11] = BadCurrentDrawableErrorNew +} + +// BadBadCurrentWindow is the error number for a BadBadCurrentWindow. +const BadBadCurrentWindow = 5 + +type BadCurrentWindowError GenericError + +// BadCurrentWindowErrorNew constructs a BadCurrentWindowError value that implements xgb.Error from a byte slice. +func BadCurrentWindowErrorNew(buf []byte) xgb.Error { + v := BadCurrentWindowError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadCurrentWindow" + return v +} + +// SequenceId returns the sequence id attached to the BadBadCurrentWindow error. +// This is mostly used internally. +func (err BadCurrentWindowError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadCurrentWindow error. If no bad value exists, 0 is returned. +func (err BadCurrentWindowError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadCurrentWindow error. +func (err BadCurrentWindowError) 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 "BadBadCurrentWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][5] = BadCurrentWindowErrorNew +} + +// 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 +} + +// BadBadFBConfig is the error number for a BadBadFBConfig. +const BadBadFBConfig = 9 + +type BadFBConfigError 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" + return v +} + +// SequenceId returns the sequence id attached to the BadBadFBConfig error. +// This is mostly used internally. +func (err BadFBConfigError) 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 { + return 0 +} + +// 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 "BadBadFBConfig {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew +} + +// BadBadLargeRequest is the error number for a BadBadLargeRequest. +const BadBadLargeRequest = 7 + +type BadLargeRequestError 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" + return v +} + +// SequenceId returns the sequence id attached to the BadBadLargeRequest error. +// This is mostly used internally. +func (err BadLargeRequestError) 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 { + return 0 +} + +// 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 "BadBadLargeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][7] = BadLargeRequestErrorNew +} + +// BadBadPbuffer is the error number for a BadBadPbuffer. +const BadBadPbuffer = 10 + +type BadPbufferError 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" + return v +} + +// SequenceId returns the sequence id attached to the BadBadPbuffer error. +// This is mostly used internally. +func (err BadPbufferError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Int16' +// 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 +} -// Skipping definition for base type 'Int32' +// 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 "BadBadPbuffer {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Void' +func init() { + xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew +} -// Skipping definition for base type 'Byte' +// BadBadPixmap is the error number for a BadBadPixmap. +const BadBadPixmap = 3 -// Skipping definition for base type 'Int8' +type BadPixmapError GenericError -// Skipping definition for base type 'Card16' +// 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 +} -// Skipping definition for base type 'Char' +// SequenceId returns the sequence id attached to the BadBadPixmap error. +// This is mostly used internally. +func (err BadPixmapError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Card32' +// 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 +} -// Skipping definition for base type 'Double' +// 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 "BadBadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Bool' +func init() { + xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew +} -// Skipping definition for base type 'Float' +// BadBadRenderRequest is the error number for a BadBadRenderRequest. +const BadBadRenderRequest = 6 -const ( - PbcetDamaged = 32791 - PbcetSaved = 32792 -) +type BadRenderRequestError GenericError -const ( - PbcdtWindow = 32793 - PbcdtPbuffer = 32794 -) +// 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 BadBadRenderRequest error. +// This is mostly used internally. +func (err BadRenderRequestError) 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 { + return 0 +} + +// 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 "BadBadRenderRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][6] = BadRenderRequestErrorNew +} + +// BadBadWindow is the error number for a BadBadWindow. +const BadBadWindow = 12 + +type BadWindowError GenericError + +// BadWindowErrorNew constructs a BadWindowError value that implements xgb.Error from a byte slice. +func BadWindowErrorNew(buf []byte) xgb.Error { + v := BadWindowError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadWindow" + return v +} + +// SequenceId returns the sequence id attached to the BadBadWindow error. +// This is mostly used internally. +func (err BadWindowError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadWindow error. If no bad value exists, 0 is returned. +func (err BadWindowError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadWindow error. +func (err BadWindowError) 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 "BadBadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +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 + +type GLXBadProfileARBError GenericError + +// GLXBadProfileARBErrorNew constructs a GLXBadProfileARBError value that implements xgb.Error from a byte slice. +func GLXBadProfileARBErrorNew(buf []byte) xgb.Error { + v := GLXBadProfileARBError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "GLXBadProfileARB" + return v +} + +// SequenceId returns the sequence id attached to the BadGLXBadProfileARB error. +// This is mostly used internally. +func (err GLXBadProfileARBError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadGLXBadProfileARB error. If no bad value exists, 0 is returned. +func (err GLXBadProfileARBError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadGLXBadProfileARB error. +func (err GLXBadProfileARBError) 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 "BadGLXBadProfileARB {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][13] = GLXBadProfileARBErrorNew +} const ( GcGlCurrentBit = 1 @@ -98,80 +596,90 @@ const ( GcGlAllAttribBits = 16777215 ) -const ( - RmGlRender = 7168 - RmGlFeedback = 7169 - RmGlSelect = 7170 -) - -type Pixmap uint32 +// BadGeneric is the error number for a BadGeneric. +const BadGeneric = -1 -func NewPixmapId(c *xgb.Conn) (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil +type GenericError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 21 bytes } -type Context uint32 +// 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 -func NewContextId(c *xgb.Conn) (Context, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Context(id), nil + return v } -type Pbuffer uint32 +// SequenceId returns the sequence id attached to the BadGeneric error. +// This is mostly used internally. +func (err GenericError) SequenceId() uint16 { + return err.Sequence +} -func NewPbufferId(c *xgb.Conn) (Pbuffer, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pbuffer(id), nil +// 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 } -type Window uint32 +// Error returns a rudimentary string representation of the BadGeneric error. -func NewWindowId(c *xgb.Conn) (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil +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, ", ") + "}" } -type Fbconfig uint32 - -func NewFbconfigId(c *xgb.Conn) (Fbconfig, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fbconfig(id), nil +func init() { + xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew } -type Drawable uint32 +const ( + PbcdtWindow = 32793 + PbcdtPbuffer = 32794 +) -func NewDrawableId(c *xgb.Conn) (Drawable, error) { +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 } - return Drawable(id), nil + return Pbuffer(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 @@ -312,927 +820,945 @@ func init() { xgb.NewExtEventFuncs["GLX"][0] = PbufferClobberEventNew } -// BadGeneric is the error number for a BadGeneric. -const BadGeneric = -1 +type Pixmap uint32 -type GenericError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 21 bytes +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil } -// 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 +const ( + RmGlRender = 7168 + RmGlFeedback = 7169 + RmGlSelect = 7170 +) - v.MajorOpcode = buf[b] - b += 1 +// BadUnsupportedPrivateRequest is the error number for a BadUnsupportedPrivateRequest. +const BadUnsupportedPrivateRequest = 8 - b += 21 // 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 } -// SequenceId returns the sequence id attached to the BadGeneric error. +// SequenceId returns the sequence id attached to the BadUnsupportedPrivateRequest error. // This is mostly used internally. -func (err GenericError) SequenceId() uint16 { +func (err UnsupportedPrivateRequestError) 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 { +// 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 } -// Error returns a rudimentary string representation of the BadGeneric error. - -func (err GenericError) Error() string { +// 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 "BadGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadUnsupportedPrivateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew + xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew } -// BadBadContext is the error number for a BadBadContext. -const BadBadContext = 0 +type Window uint32 -type BadContextError GenericError +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil +} -// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. -func BadContextErrorNew(buf []byte) xgb.Error { - v := BadContextError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadContext" - return v +// 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' + +// AreTexturesResidentCookie is a cookie used only for AreTexturesResident requests. +type AreTexturesResidentCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the BadBadContext error. -// This is mostly used internally. -func (err BadContextError) SequenceId() uint16 { - return err.Sequence +// 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 'AreTexturesResident' 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} } -// 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 +// AreTexturesResidentUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'AreTexturesResident' 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} } -// Error returns a rudimentary string representation of the BadBadContext error. -func (err BadContextError) 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 "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// 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 + RetVal Bool32 + // padding: 20 bytes + Data []bool // size: xgb.Pad(((int(Length) * 4) * 1)) } -func init() { - xgb.NewExtErrorFuncs["GLX"][0] = BadContextErrorNew +// 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 + } + if buf == nil { + return nil, nil + } + return areTexturesResidentReply(buf), nil } -// BadBadContextState is the error number for a BadBadContextState. -const BadBadContextState = 1 +// 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 + + 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 + + b += 20 // padding -type BadContextStateError GenericError + 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) -// BadContextStateErrorNew constructs a BadContextStateError value that implements xgb.Error from a byte slice. -func BadContextStateErrorNew(buf []byte) xgb.Error { - v := BadContextStateError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadContextState" return v } -// SequenceId returns the sequence id attached to the BadBadContextState error. -// This is mostly used internally. -func (err BadContextStateError) SequenceId() uint16 { - return err.Sequence -} +// 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) -// BadId returns the 'BadValue' number if one exists for the BadBadContextState error. If no bad value exists, 0 is returned. -func (err BadContextStateError) BadId() uint32 { - return 0 -} + buf[b] = c.Extensions["GLX"] + b += 1 -// Error returns a rudimentary string representation of the BadBadContextState error. -func (err BadContextStateError) 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 "BadBadContextState {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + buf[b] = 143 // request opcode + b += 1 -func init() { - xgb.NewExtErrorFuncs["GLX"][1] = BadContextStateErrorNew -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadBadDrawable is the error number for a BadBadDrawable. -const BadBadDrawable = 2 + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 -type BadDrawableError GenericError + xgb.Put32(buf[b:], uint32(N)) + b += 4 -// 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 -} + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) -// SequenceId returns the sequence id attached to the BadBadDrawable error. -// This is mostly used internally. -func (err BadDrawableError) SequenceId() uint16 { - return err.Sequence + return buf } -// 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 +// ChangeDrawableAttributesCookie is a cookie used only for ChangeDrawableAttributes requests. +type ChangeDrawableAttributesCookie struct { + *xgb.Cookie } -// 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, ", ") + "}" +// 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'ChangeDrawableAttributes' 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} } -func init() { - xgb.NewExtErrorFuncs["GLX"][2] = BadDrawableErrorNew +// 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 'ChangeDrawableAttributes' 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} } -// BadBadPixmap is the error number for a BadBadPixmap. -const BadBadPixmap = 3 - -type BadPixmapError 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" - 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 ChangeDrawableAttributesCookie) Check() error { + return cook.Cookie.Check() } -// SequenceId returns the sequence id attached to the BadBadPixmap error. -// This is mostly used internally. -func (err BadPixmapError) SequenceId() uint16 { - return err.Sequence -} +// 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) -// 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 -} + buf[b] = c.Extensions["GLX"] + b += 1 -// 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 "BadBadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + buf[b] = 30 // request opcode + b += 1 -func init() { - xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadBadContextTag is the error number for a BadBadContextTag. -const BadBadContextTag = 4 + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 -type BadContextTagError GenericError + xgb.Put32(buf[b:], NumAttribs) + b += 4 -// 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 -} + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) -// SequenceId returns the sequence id attached to the BadBadContextTag error. -// This is mostly used internally. -func (err BadContextTagError) SequenceId() uint16 { - return err.Sequence + return buf } -// 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 +// ClientInfoCookie is a cookie used only for ClientInfo requests. +type ClientInfoCookie struct { + *xgb.Cookie } -// 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 "BadBadContextTag {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ClientInfo 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'ClientInfo' 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} } -func init() { - xgb.NewExtErrorFuncs["GLX"][4] = BadContextTagErrorNew +// 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 'ClientInfo' 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} } -// BadBadCurrentWindow is the error number for a BadBadCurrentWindow. -const BadBadCurrentWindow = 5 - -type BadCurrentWindowError GenericError - -// BadCurrentWindowErrorNew constructs a BadCurrentWindowError value that implements xgb.Error from a byte slice. -func BadCurrentWindowErrorNew(buf []byte) xgb.Error { - v := BadCurrentWindowError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadCurrentWindow" - 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 ClientInfoCookie) Check() error { + return cook.Cookie.Check() } -// SequenceId returns the sequence id attached to the BadBadCurrentWindow error. -// This is mostly used internally. -func (err BadCurrentWindowError) SequenceId() uint16 { - return err.Sequence -} +// 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) -// BadId returns the 'BadValue' number if one exists for the BadBadCurrentWindow error. If no bad value exists, 0 is returned. -func (err BadCurrentWindowError) BadId() uint32 { - return 0 -} + buf[b] = c.Extensions["GLX"] + b += 1 -// Error returns a rudimentary string representation of the BadBadCurrentWindow error. -func (err BadCurrentWindowError) 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 "BadBadCurrentWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + buf[b] = 20 // request opcode + b += 1 -func init() { - xgb.NewExtErrorFuncs["GLX"][5] = BadCurrentWindowErrorNew -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadBadRenderRequest is the error number for a BadBadRenderRequest. -const BadBadRenderRequest = 6 + xgb.Put32(buf[b:], MajorVersion) + b += 4 -type BadRenderRequestError GenericError + xgb.Put32(buf[b:], MinorVersion) + b += 4 -// 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 -} + xgb.Put32(buf[b:], StrLen) + b += 4 -// SequenceId returns the sequence id attached to the BadBadRenderRequest error. -// This is mostly used internally. -func (err BadRenderRequestError) SequenceId() uint16 { - return err.Sequence + copy(buf[b:], String[:StrLen]) + b += xgb.Pad(int(StrLen)) + + return buf } -// 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 +// CopyContextCookie is a cookie used only for CopyContext requests. +type CopyContextCookie struct { + *xgb.Cookie } -// 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 "BadBadRenderRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// CopyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CopyContext(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'CopyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) + return CopyContextCookie{cookie} } -func init() { - xgb.NewExtErrorFuncs["GLX"][6] = BadRenderRequestErrorNew +// CopyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyContextCookie.Check() +func CopyContextChecked(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'CopyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) + return CopyContextCookie{cookie} } -// BadBadLargeRequest is the error number for a BadBadLargeRequest. -const BadBadLargeRequest = 7 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CopyContextCookie) Check() error { + return cook.Cookie.Check() +} -type BadLargeRequestError GenericError +// Write request to wire for CopyContext +// copyContextRequest writes a CopyContext request to a byte slice. +func copyContextRequest(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) []byte { + size := 20 + b := 0 + buf := make([]byte, size) -// 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 -} + buf[b] = c.Extensions["GLX"] + b += 1 -// SequenceId returns the sequence id attached to the BadBadLargeRequest error. -// This is mostly used internally. -func (err BadLargeRequestError) SequenceId() uint16 { - return err.Sequence -} + buf[b] = 10 // request opcode + b += 1 -// 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 -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// 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 "BadBadLargeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], uint32(Src)) + b += 4 -func init() { - xgb.NewExtErrorFuncs["GLX"][7] = BadLargeRequestErrorNew -} + xgb.Put32(buf[b:], uint32(Dest)) + b += 4 -// BadUnsupportedPrivateRequest is the error number for a BadUnsupportedPrivateRequest. -const BadUnsupportedPrivateRequest = 8 + xgb.Put32(buf[b:], Mask) + b += 4 -type UnsupportedPrivateRequestError GenericError + xgb.Put32(buf[b:], uint32(SrcContextTag)) + b += 4 -// 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 + 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 +// CreateContextCookie is a cookie used only for CreateContext requests. +type CreateContextCookie 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 +// 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} } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew +// Check returns an error if one occurred 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() } -// BadBadFBConfig is the error number for a BadBadFBConfig. -const BadBadFBConfig = 9 +// 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) -type BadFBConfigError GenericError + buf[b] = c.Extensions["GLX"] + b += 1 -// 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 -} + buf[b] = 3 // request opcode + b += 1 -// SequenceId returns the sequence id attached to the BadBadFBConfig error. -// This is mostly used internally. -func (err BadFBConfigError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// 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 -} + xgb.Put32(buf[b:], uint32(Context)) + b += 4 -// 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 "BadBadFBConfig {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 -func init() { - xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew -} + xgb.Put32(buf[b:], Screen) + b += 4 -// BadBadPbuffer is the error number for a BadBadPbuffer. -const BadBadPbuffer = 10 + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 -type BadPbufferError GenericError + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -// 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 + b += 3 // padding + + return buf } -// SequenceId returns the sequence id attached to the BadBadPbuffer error. -// This is mostly used internally. -func (err BadPbufferError) SequenceId() uint16 { - return err.Sequence +// CreateContextAttribsARBCookie is a cookie used only for CreateContextAttribsARB requests. +type CreateContextAttribsARBCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'CreateContextAttribsARB' 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} } -// 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 +// 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 'CreateContextAttribsARB' 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} } -// 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 "BadBadPbuffer {" + 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 CreateContextAttribsARBCookie) Check() error { + return cook.Cookie.Check() } -func init() { - xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew -} +// 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) -// BadBadCurrentDrawable is the error number for a BadBadCurrentDrawable. -const BadBadCurrentDrawable = 11 + buf[b] = c.Extensions["GLX"] + b += 1 -type BadCurrentDrawableError GenericError + buf[b] = 34 // request opcode + b += 1 -// 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 -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// SequenceId returns the sequence id attached to the BadBadCurrentDrawable error. -// This is mostly used internally. -func (err BadCurrentDrawableError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put32(buf[b:], uint32(Context)) + b += 4 -// 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 -} + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 -// 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 "BadBadCurrentDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], Screen) + b += 4 -func init() { - xgb.NewExtErrorFuncs["GLX"][11] = BadCurrentDrawableErrorNew -} + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 -// BadBadWindow is the error number for a BadBadWindow. -const BadBadWindow = 12 + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -type BadWindowError GenericError + b += 3 // padding -// BadWindowErrorNew constructs a BadWindowError value that implements xgb.Error from a byte slice. -func BadWindowErrorNew(buf []byte) xgb.Error { - v := BadWindowError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadWindow" - return v + 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 } -// SequenceId returns the sequence id attached to the BadBadWindow error. -// This is mostly used internally. -func (err BadWindowError) SequenceId() uint16 { - return err.Sequence +// CreateGLXPixmapCookie is a cookie used only for CreateGLXPixmap requests. +type CreateGLXPixmapCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadBadWindow error. If no bad value exists, 0 is returned. -func (err BadWindowError) BadId() uint32 { - return 0 +// CreateGLXPixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateGLXPixmap(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'CreateGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) + return CreateGLXPixmapCookie{cookie} } -// Error returns a rudimentary string representation of the BadBadWindow error. -func (err BadWindowError) 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 "BadBadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// CreateGLXPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGLXPixmapCookie.Check() +func CreateGLXPixmapChecked(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'CreateGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) + return CreateGLXPixmapCookie{cookie} } -func init() { - xgb.NewExtErrorFuncs["GLX"][12] = BadWindowErrorNew +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateGLXPixmapCookie) Check() error { + return cook.Cookie.Check() } -// BadGLXBadProfileARB is the error number for a BadGLXBadProfileARB. -const BadGLXBadProfileARB = 13 +// Write request to wire for CreateGLXPixmap +// createGLXPixmapRequest writes a CreateGLXPixmap request to a byte slice. +func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) []byte { + size := 20 + b := 0 + buf := make([]byte, size) -type GLXBadProfileARBError GenericError + buf[b] = c.Extensions["GLX"] + b += 1 -// GLXBadProfileARBErrorNew constructs a GLXBadProfileARBError value that implements xgb.Error from a byte slice. -func GLXBadProfileARBErrorNew(buf []byte) xgb.Error { - v := GLXBadProfileARBError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "GLXBadProfileARB" - return v -} + buf[b] = 13 // request opcode + b += 1 -// SequenceId returns the sequence id attached to the BadGLXBadProfileARB error. -// This is mostly used internally. -func (err GLXBadProfileARBError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadGLXBadProfileARB error. If no bad value exists, 0 is returned. -func (err GLXBadProfileARBError) BadId() uint32 { - return 0 -} + xgb.Put32(buf[b:], Screen) + b += 4 -// Error returns a rudimentary string representation of the BadGLXBadProfileARB error. -func (err GLXBadProfileARBError) 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 "BadGLXBadProfileARB {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 -func init() { - xgb.NewExtErrorFuncs["GLX"][13] = GLXBadProfileARBErrorNew + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + return buf } -// RenderCookie is a cookie used only for Render requests. -type RenderCookie struct { +// CreateNewContextCookie is a cookie used only for CreateNewContext requests. +type CreateNewContextCookie struct { *xgb.Cookie } -// Render sends an unchecked request. +// CreateNewContext 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 { +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 'Render' 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, false) - c.NewRequest(renderRequest(c, ContextTag, Data), cookie) - return RenderCookie{cookie} + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{cookie} } -// 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 { +// 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 'Render' 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, false) - c.NewRequest(renderRequest(c, ContextTag, Data), cookie) - return RenderCookie{cookie} + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{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 RenderCookie) Check() error { +func (cook CreateNewContextCookie) Check() error { return cook.Cookie.Check() } -// 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)))) +// 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 1 // 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(ContextTag)) + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], RenderType) + b += 4 + + xgb.Put32(buf[b:], uint32(ShareList)) b += 4 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding return buf } -// RenderLargeCookie is a cookie used only for RenderLarge requests. -type RenderLargeCookie struct { +// CreatePbufferCookie is a cookie used only for CreatePbuffer requests. +type CreatePbufferCookie struct { *xgb.Cookie } -// RenderLarge sends an unchecked request. +// CreatePbuffer 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 { +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 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePbuffer' 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} + c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) + return CreatePbufferCookie{cookie} } -// 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 { +// 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 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreatePbuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return RenderLargeCookie{cookie} + 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 RenderLargeCookie) Check() error { +func (cook CreatePbufferCookie) Check() error { return cook.Cookie.Check() } -// 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)))) +// 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] = 2 // 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(ContextTag)) + xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put16(buf[b:], RequestNum) - b += 2 + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 - xgb.Put16(buf[b:], RequestTotal) - b += 2 + xgb.Put32(buf[b:], uint32(Pbuffer)) + b += 4 - xgb.Put32(buf[b:], DataLen) + xgb.Put32(buf[b:], NumAttribs) b += 4 - copy(buf[b:], Data[:DataLen]) - b += xgb.Pad(int(DataLen)) + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { *xgb.Cookie } -// CreateContext 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 CreateContext(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { +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 'CreateContext' 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(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) - return CreateContextCookie{cookie} + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{cookie} } -// 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 { +// 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 'CreateContext' 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(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) - return CreateContextCookie{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 CreateContextCookie) Check() error { +func (cook CreatePixmapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateContext -// createContextRequest writes a CreateContext request to a byte slice. -func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) []byte { - size := 24 +// 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] = 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:], uint32(Context)) + xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], uint32(Visual)) + xgb.Put32(buf[b:], uint32(Fbconfig)) b += 4 - xgb.Put32(buf[b:], Screen) + xgb.Put32(buf[b:], uint32(Pixmap)) b += 4 - xgb.Put32(buf[b:], uint32(ShareList)) + xgb.Put32(buf[b:], uint32(GlxPixmap)) b += 4 - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + xgb.Put32(buf[b:], NumAttribs) + b += 4 - b += 3 // padding + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// DestroyContextCookie is a cookie used only for DestroyContext requests. -type DestroyContextCookie struct { +// CreateWindowCookie is a cookie used only for CreateWindow requests. +type CreateWindowCookie struct { *xgb.Cookie } -// DestroyContext 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 DestroyContext(c *xgb.Conn, Context Context) DestroyContextCookie { +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 'DestroyContext' 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(destroyContextRequest(c, Context), cookie) - return DestroyContextCookie{cookie} + c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) + return CreateWindowCookie{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 { +// 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 'DestroyContext' 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(destroyContextRequest(c, Context), cookie) - return DestroyContextCookie{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 DestroyContextCookie) Check() error { +func (cook CreateWindowCookie) 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, Context Context) []byte { - size := 8 +// 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] = 4 // 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(Context)) + 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)) + 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 } -// MakeCurrentCookie is a cookie used only for MakeCurrent requests. -type MakeCurrentCookie struct { +// DeleteListsCookie is a cookie used only for DeleteLists requests. +type DeleteListsCookie struct { *xgb.Cookie } -// 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} -} - -// MakeCurrentUnchecked 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 MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { +func DeleteLists(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeCurrent' 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(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) - return MakeCurrentCookie{cookie} -} - -// 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 + 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 MakeCurrent request. -func (cook MakeCurrentCookie) Reply() (*MakeCurrentReply, 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 makeCurrentReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} } -// 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 - - v.ContextTag = ContextTag(xgb.Get32(buf[b:])) - b += 4 - - b += 20 // 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 DeleteListsCookie) Check() error { + return cook.Cookie.Check() } -// 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 { +// 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) @@ -1240,253 +1766,243 @@ func makeCurrentRequest(c *xgb.Conn, Drawable Drawable, Context Context, OldCont buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 5 // 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:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Context)) + xgb.Put32(buf[b:], List) b += 4 - xgb.Put32(buf[b:], uint32(OldContextTag)) + xgb.Put32(buf[b:], uint32(Range)) b += 4 return buf } -// IsDirectCookie is a cookie used only for IsDirect requests. -type IsDirectCookie struct { +// DeleteQueriesARBCookie is a cookie used only for DeleteQueriesARB requests. +type DeleteQueriesARBCookie struct { *xgb.Cookie } -// 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} -} - -// IsDirectUnchecked 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 IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { +func DeleteQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsDirect' 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(isDirectRequest(c, Context), cookie) - return IsDirectCookie{cookie} -} - -// 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 + 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 IsDirect request. -func (cook IsDirectCookie) Reply() (*IsDirectReply, 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 isDirectReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} } -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.IsDirect = true - } else { - v.IsDirect = 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 DeleteQueriesARBCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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] = 6 // 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:], uint32(Context)) + 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 } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// DeleteTexturesCookie is a cookie used only for DeleteTextures requests. +type DeleteTexturesCookie 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 { +// 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 'QueryVersion' 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(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{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 { +// 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 'QueryVersion' 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(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{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 +// Check returns an error if one occurred 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() } -// 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 -} +// 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) -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 144 // 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 - v.MajorVersion = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(N)) b += 4 - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) - b += 16 // padding + return buf +} - return v +// DeleteWindowCookie is a cookie used only for DeleteWindow requests. +type DeleteWindowCookie struct { + *xgb.Cookie } -// 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 +// 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteWindow' 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} +} + +// 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 'DeleteWindow' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 7 // 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) + xgb.Put32(buf[b:], uint32(Glxwindow)) b += 4 return buf } -// WaitGLCookie is a cookie used only for WaitGL requests. -type WaitGLCookie struct { +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { *xgb.Cookie } -// WaitGL sends an unchecked request. +// DestroyContext sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func WaitGL(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { +func DestroyContext(c *xgb.Conn, Context Context) DestroyContextCookie { 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 'DestroyContext' 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(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{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 { +// 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 'WaitGL' 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, false) - c.NewRequest(waitGLRequest(c, ContextTag), cookie) - return WaitGLCookie{cookie} + c.NewRequest(destroyContextRequest(c, 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 WaitGLCookie) Check() error { +func (cook DestroyContextCookie) 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 { +// 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) @@ -1494,54 +2010,54 @@ func waitGLRequest(c *xgb.Conn, ContextTag ContextTag) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 8 // 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(ContextTag)) + xgb.Put32(buf[b:], uint32(Context)) b += 4 return buf } -// WaitXCookie is a cookie used only for WaitX requests. -type WaitXCookie struct { +// DestroyGLXPixmapCookie is a cookie used only for DestroyGLXPixmap requests. +type DestroyGLXPixmapCookie struct { *xgb.Cookie } -// WaitX sends an unchecked request. +// DestroyGLXPixmap 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 DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { 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 'DestroyGLXPixmap' 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(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{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 { +// 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 'WaitX' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyGLXPixmap' 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(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{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 DestroyGLXPixmapCookie) 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 { +// 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) @@ -1549,184 +2065,172 @@ func waitXRequest(c *xgb.Conn, ContextTag ContextTag) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 9 // 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(ContextTag)) + xgb.Put32(buf[b:], uint32(GlxPixmap)) b += 4 return buf } -// CopyContextCookie is a cookie used only for CopyContext requests. -type CopyContextCookie struct { +// DestroyPbufferCookie is a cookie used only for DestroyPbuffer requests. +type DestroyPbufferCookie struct { *xgb.Cookie } -// CopyContext 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 CopyContext(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { +func DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CopyContext' 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(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) - return CopyContextCookie{cookie} + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{cookie} } -// CopyContextChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyContextCookie.Check() -func CopyContextChecked(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { +// 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 'CopyContext' 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(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) - return CopyContextCookie{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 CopyContextCookie) Check() error { +func (cook DestroyPbufferCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CopyContext -// copyContextRequest writes a CopyContext request to a byte slice. -func copyContextRequest(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) []byte { - size := 20 +// 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] = 10 // 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(Src)) - b += 4 - - xgb.Put32(buf[b:], uint32(Dest)) - b += 4 - - xgb.Put32(buf[b:], Mask) - b += 4 - - xgb.Put32(buf[b:], uint32(SrcContextTag)) + xgb.Put32(buf[b:], uint32(Pbuffer)) b += 4 return buf } -// SwapBuffersCookie is a cookie used only for SwapBuffers requests. -type SwapBuffersCookie struct { +// DestroyPixmapCookie is a cookie used only for DestroyPixmap requests. +type DestroyPixmapCookie struct { *xgb.Cookie } -// SwapBuffers sends an unchecked request. +// DestroyPixmap 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 DestroyPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { 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 'DestroyPixmap' 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(destroyPixmapRequest(c, GlxPixmap), cookie) + return DestroyPixmapCookie{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 { +// DestroyPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyPixmapCookie.Check() +func DestroyPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { 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 'DestroyPixmap' 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(destroyPixmapRequest(c, GlxPixmap), cookie) + return DestroyPixmapCookie{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 DestroyPixmapCookie) 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 DestroyPixmap +// destroyPixmapRequest writes a DestroyPixmap request to a byte slice. +func destroyPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 11 // 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(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(GlxPixmap)) b += 4 return buf } -// UseXFontCookie is a cookie used only for UseXFont requests. -type UseXFontCookie struct { +// EndListCookie is a cookie used only for EndList requests. +type EndListCookie struct { *xgb.Cookie } -// UseXFont 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 UseXFont(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { +func EndList(c *xgb.Conn, ContextTag ContextTag) EndListCookie { 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 'EndList' 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(endListRequest(c, ContextTag), cookie) + return EndListCookie{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 { +// 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 'UseXFont' 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(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) - return UseXFontCookie{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 UseXFontCookie) Check() error { +func (cook EndListCookie) 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 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] = 12 // request opcode + buf[b] = 102 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1735,125 +2239,106 @@ func useXFontRequest(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Font)) - b += 4 - - xgb.Put32(buf[b:], First) - b += 4 - - xgb.Put32(buf[b:], Count) - b += 4 - - xgb.Put32(buf[b:], ListBase) - b += 4 - return buf } -// CreateGLXPixmapCookie is a cookie used only for CreateGLXPixmap requests. -type CreateGLXPixmapCookie struct { +// FeedbackBufferCookie is a cookie used only for FeedbackBuffer requests. +type FeedbackBufferCookie struct { *xgb.Cookie } -// CreateGLXPixmap sends an unchecked request. +// FeedbackBuffer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateGLXPixmap(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { +func FeedbackBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) - return CreateGLXPixmapCookie{cookie} + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{cookie} } -// CreateGLXPixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateGLXPixmapCookie.Check() -func CreateGLXPixmapChecked(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { +// 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 'CreateGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) - return CreateGLXPixmapCookie{cookie} + 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 CreateGLXPixmapCookie) Check() error { +func (cook FeedbackBufferCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateGLXPixmap -// createGLXPixmapRequest writes a CreateGLXPixmap request to a byte slice. -func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) []byte { - size := 20 +// 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 - buf[b] = 13 // request opcode + 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:], Screen) - b += 4 - - xgb.Put32(buf[b:], uint32(Visual)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Pixmap)) + xgb.Put32(buf[b:], uint32(Size)) b += 4 - xgb.Put32(buf[b:], uint32(GlxPixmap)) + xgb.Put32(buf[b:], uint32(Type)) b += 4 return buf } -// GetVisualConfigsCookie is a cookie used only for GetVisualConfigs requests. -type GetVisualConfigsCookie struct { +// FinishCookie is a cookie used only for Finish requests. +type FinishCookie 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 { +// 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 'GetVisualConfigs' 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(getVisualConfigsRequest(c, Screen), cookie) - return GetVisualConfigsCookie{cookie} + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} } -// GetVisualConfigsUnchecked 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 GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { +func FinishUnchecked(c *xgb.Conn, ContextTag ContextTag) FinishCookie { 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 'Finish' 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} + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} } -// GetVisualConfigsReply represents the data returned from a GetVisualConfigs request. -type GetVisualConfigsReply 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 - NumVisuals uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a GetVisualConfigs request. -func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, 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 @@ -1861,12 +2346,12 @@ func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { if buf == nil { return nil, nil } - return getVisualConfigsReply(buf), nil + return finishReply(buf), nil } -// getVisualConfigsReply reads a byte slice into a GetVisualConfigsReply value. -func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { - v := new(GetVisualConfigsReply) +// 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 @@ -1877,27 +2362,12 @@ func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumVisuals = xgb.Get32(buf[b:]) - b += 4 - - v.NumProperties = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - 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 GetVisualConfigs -// getVisualConfigsRequest writes a GetVisualConfigs request to a byte slice. -func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { +// 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) @@ -1905,54 +2375,54 @@ func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 14 // request opcode + 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:], Screen) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 return buf } -// DestroyGLXPixmapCookie is a cookie used only for DestroyGLXPixmap requests. -type DestroyGLXPixmapCookie struct { +// FlushCookie is a cookie used only for Flush requests. +type FlushCookie struct { *xgb.Cookie } -// DestroyGLXPixmap sends an unchecked request. +// Flush 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 Flush(c *xgb.Conn, ContextTag ContextTag) FlushCookie { 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 'Flush' 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(flushRequest(c, ContextTag), cookie) + return FlushCookie{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 { +// 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 'DestroyGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'Flush' 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(flushRequest(c, ContextTag), cookie) + return FlushCookie{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 FlushCookie) 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 { +// 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) @@ -1960,118 +2430,147 @@ func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 15 // 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(GlxPixmap)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 return buf } -// VendorPrivateCookie is a cookie used only for VendorPrivate requests. -type VendorPrivateCookie struct { +// GenListsCookie is a cookie used only for GenLists requests. +type GenListsCookie 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 { +// 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 'VendorPrivate' 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, false) - c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{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 { +// GenListsUnchecked 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 { 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 'GenLists' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{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 { - return cook.Cookie.Check() +// 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 + RetVal uint32 } -// 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)))) +// 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 + } + if buf == nil { + return nil, nil + } + return genListsReply(buf), nil +} + +// 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 + + 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 + + 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 16 // 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:], VendorCode) - b += 4 - xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + xgb.Put32(buf[b:], uint32(Range)) + b += 4 return buf } -// VendorPrivateWithReplyCookie is a cookie used only for VendorPrivateWithReply requests. -type VendorPrivateWithReplyCookie struct { +// GenQueriesARBCookie is a cookie used only for GenQueriesARB requests. +type GenQueriesARBCookie 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 { +// 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 'VendorPrivateWithReply' 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, true) - c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateWithReplyCookie{cookie} + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} } -// VendorPrivateWithReplyUnchecked sends an unchecked request. +// GenQueriesARBUnchecked 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 GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { 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 'GenQueriesARB' 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} + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} } -// VendorPrivateWithReplyReply represents the data returned from a VendorPrivateWithReply request. -type VendorPrivateWithReplyReply struct { +// 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 - Retval uint32 - Data1 []byte // size: 24 - Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a VendorPrivateWithReply request. -func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { +// 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 @@ -2079,12 +2578,12 @@ func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, if buf == nil { return nil, nil } - return vendorPrivateWithReplyReply(buf), nil + return genQueriesARBReply(buf), nil } -// vendorPrivateWithReplyReply reads a byte slice into a VendorPrivateWithReplyReply value. -func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { - v := new(VendorPrivateWithReplyReply) +// 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 @@ -2095,87 +2594,81 @@ func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { 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)) + b += 24 // padding - 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))) + 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 } -// 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 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] = 17 // 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:], VendorCode) - b += 4 - xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + xgb.Put32(buf[b:], uint32(N)) + b += 4 return buf } -// QueryExtensionsStringCookie is a cookie used only for QueryExtensionsString requests. -type QueryExtensionsStringCookie struct { +// GenTexturesCookie is a cookie used only for GenTextures requests. +type GenTexturesCookie 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 { +// 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 'QueryExtensionsString' 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(queryExtensionsStringRequest(c, Screen), cookie) - return QueryExtensionsStringCookie{cookie} + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} } -// QueryExtensionsStringUnchecked 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 QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { +func GenTexturesUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { 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 'GenTextures' 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} + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} } -// QueryExtensionsStringReply represents the data returned from a QueryExtensionsString request. -type QueryExtensionsStringReply 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 - // padding: 4 bytes - N uint32 - // padding: 16 bytes + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Reply blocks and returns the reply data for a QueryExtensionsString request. -func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, 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 @@ -2183,12 +2676,12 @@ func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, er if buf == nil { return nil, nil } - return queryExtensionsStringReply(buf), nil + return genTexturesReply(buf), nil } -// queryExtensionsStringReply reads a byte slice into a QueryExtensionsStringReply value. -func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { - v := new(QueryExtensionsStringReply) +// 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 @@ -2199,78 +2692,84 @@ func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 + b += 24 // padding - b += 16 // 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 } -// 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 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] = 18 // 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:], Screen) + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) b += 4 return buf } -// QueryServerStringCookie is a cookie used only for QueryServerString requests. -type QueryServerStringCookie struct { +// GetBooleanvCookie is a cookie used only for GetBooleanv requests. +type GetBooleanvCookie 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 { +// 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 'QueryServerString' 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, true) - c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) - return QueryServerStringCookie{cookie} + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{cookie} } -// QueryServerStringUnchecked sends an unchecked request. +// GetBooleanvUnchecked 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 GetBooleanvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { 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 'GetBooleanv' 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} + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{cookie} } -// QueryServerStringReply represents the data returned from a QueryServerString request. -type QueryServerStringReply struct { +// 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 - StrLen uint32 - // padding: 16 bytes - String string // size: xgb.Pad((int(StrLen) * 1)) + N uint32 + Datum bool + // padding: 15 bytes + Data []bool // size: xgb.Pad((int(N) * 1)) } -// Reply blocks and returns the reply data for a QueryServerString request. -func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { +// 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 @@ -2278,12 +2777,12 @@ func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { if buf == nil { return nil, nil } - return queryServerStringReply(buf), nil + return getBooleanvReply(buf), nil } -// queryServerStringReply reads a byte slice into a QueryServerStringReply value. -func queryServerStringReply(buf []byte) *QueryServerStringReply { - v := new(QueryServerStringReply) +// getBooleanvReply reads a byte slice into a GetBooleanvReply value. +func getBooleanvReply(buf []byte) *GetBooleanvReply { + v := new(GetBooleanvReply) b := 1 // skip reply determinant b += 1 // padding @@ -2296,150 +2795,95 @@ func queryServerStringReply(buf []byte) *QueryServerStringReply { b += 4 // padding - v.StrLen = xgb.Get32(buf[b:]) + v.N = 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)) + if buf[b] == 1 { + v.Datum = true + } else { + v.Datum = false } - - return v -} - -// 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] = 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:], Screen) - b += 4 - - xgb.Put32(buf[b:], Name) - b += 4 - - return buf -} - -// ClientInfoCookie is a cookie used only for ClientInfo requests. -type ClientInfoCookie struct { - *xgb.Cookie -} - -// ClientInfo 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ClientInfo' 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} -} + b += 15 // padding -// 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 'ClientInfo' 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(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) - return ClientInfoCookie{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 ClientInfoCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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] = 20 // 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:], MajorVersion) - b += 4 - - xgb.Put32(buf[b:], MinorVersion) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], StrLen) + xgb.Put32(buf[b:], uint32(Pname)) 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 { +// GetClipPlaneCookie is a cookie used only for GetClipPlane requests. +type GetClipPlaneCookie 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 { +// 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 'GetFBConfigs' 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, true) - c.NewRequest(getFBConfigsRequest(c, Screen), cookie) - return GetFBConfigsCookie{cookie} + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{cookie} } -// GetFBConfigsUnchecked sends an unchecked request. +// GetClipPlaneUnchecked 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 { +func GetClipPlaneUnchecked(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { 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 'GetClipPlane' 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} + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{cookie} } -// GetFBConfigsReply represents the data returned from a GetFBConfigs request. -type GetFBConfigsReply struct { +// 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 - NumFbConfigs uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) + // padding: 24 bytes + Data []Float64 // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Reply blocks and returns the reply data for a GetFBConfigs request. -func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { +// 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 @@ -2447,12 +2891,12 @@ func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { if buf == nil { return nil, nil } - return getFBConfigsReply(buf), nil + return getClipPlaneReply(buf), nil } -// getFBConfigsReply reads a byte slice into a GetFBConfigsReply value. -func getFBConfigsReply(buf []byte) *GetFBConfigsReply { - v := new(GetFBConfigsReply) +// getClipPlaneReply reads a byte slice into a GetClipPlaneReply value. +func getClipPlaneReply(buf []byte) *GetClipPlaneReply { + v := new(GetClipPlaneReply) b := 1 // skip reply determinant b += 1 // padding @@ -2463,289 +2907,199 @@ func getFBConfigsReply(buf []byte) *GetFBConfigsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumFbConfigs = xgb.Get32(buf[b:]) - b += 4 - - v.NumProperties = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding + b += 24 // padding - v.PropertyList = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PropertyList[i] = xgb.Get32(buf[b:]) - b += 4 + 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 } b = xgb.Pad(b) return v } -// 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 +// 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] = 21 // 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:], Screen) + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Plane)) b += 4 return buf } -// CreatePixmapCookie is a cookie used only for CreatePixmap requests. -type CreatePixmapCookie struct { +// GetColorTableCookie is a cookie used only for GetColorTable requests. +type GetColorTableCookie 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, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { +// 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 'CreatePixmap' 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(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) - return CreatePixmapCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{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 { +// 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 'CreatePixmap' 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} -} - -// Check returns an error if one occurred 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, 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] = 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 + panic("Cannot issue request 'GetColorTable' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - b = xgb.Pad(b) - - return buf + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{cookie} } -// DestroyPixmapCookie is a cookie used only for DestroyPixmap requests. -type DestroyPixmapCookie struct { - *xgb.Cookie +// 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)) } -// DestroyPixmap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") +// 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 } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) - return DestroyPixmapCookie{cookie} -} - -// DestroyPixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyPixmapCookie.Check() -func DestroyPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + if buf == nil { + return nil, nil } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) - return DestroyPixmapCookie{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 DestroyPixmapCookie) Check() error { - return cook.Cookie.Check() + return getColorTableReply(buf), nil } -// Write request to wire for DestroyPixmap -// destroyPixmapRequest writes a DestroyPixmap request to a byte slice. -func destroyPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 +// getColorTableReply reads a byte slice into a GetColorTableReply value. +func getColorTableReply(buf []byte) *GetColorTableReply { + v := new(GetColorTableReply) + b := 1 // skip reply determinant - buf[b] = 23 // 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(GlxPixmap)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} - -// CreateNewContextCookie is a cookie used only for CreateNewContext requests. -type CreateNewContextCookie struct { - *xgb.Cookie -} + b += 8 // padding -// 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 'CreateNewContext' 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} -} + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 -// 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 'CreateNewContext' 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} -} + b += 12 // 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 CreateNewContextCookie) Check() error { - return cook.Cookie.Check() -} + 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))) -// 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 + 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] = 24 // 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)) - b += 4 - - xgb.Put32(buf[b:], uint32(Fbconfig)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Screen) + xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], RenderType) + 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 - return buf } -// QueryContextCookie is a cookie used only for QueryContext requests. -type QueryContextCookie struct { +// GetColorTableParameterfvCookie is a cookie used only for GetColorTableParameterfv requests. +type GetColorTableParameterfvCookie 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 { +// 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 'QueryContext' 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, true) - c.NewRequest(queryContextRequest(c, Context), cookie) - return QueryContextCookie{cookie} + c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{cookie} } -// QueryContextUnchecked sends an unchecked request. +// GetColorTableParameterfvUnchecked 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 GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { 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 'GetColorTableParameterfv' 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(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{cookie} } -// QueryContextReply represents the data returned from a QueryContext request. -type QueryContextReply struct { +// 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 - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) + // 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 QueryContext request. -func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { +// 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 @@ -2753,12 +3107,12 @@ func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { if buf == nil { return nil, nil } - return queryContextReply(buf), nil + return getColorTableParameterfvReply(buf), nil } -// queryContextReply reads a byte slice into a QueryContextReply value. -func queryContextReply(buf []byte) *QueryContextReply { - v := new(QueryContextReply) +// getColorTableParameterfvReply reads a byte slice into a GetColorTableParameterfvReply value. +func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { + v := new(GetColorTableParameterfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -2769,14 +3123,19 @@ func queryContextReply(buf []byte) *QueryContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAttribs = xgb.Get32(buf[b:]) + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 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 += 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) @@ -2784,66 +3143,75 @@ func queryContextReply(buf []byte) *QueryContextReply { return v } -// 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 +// 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 25 // request opcode + buf[b] = 148 // 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:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// MakeContextCurrentCookie is a cookie used only for MakeContextCurrent requests. -type MakeContextCurrentCookie struct { +// GetColorTableParameterivCookie is a cookie used only for GetColorTableParameteriv requests. +type GetColorTableParameterivCookie 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 { +// 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 'MakeContextCurrent' 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, true) - c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) - return MakeContextCurrentCookie{cookie} + c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{cookie} } -// MakeContextCurrentUnchecked sends an unchecked request. +// GetColorTableParameterivUnchecked 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 GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { 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 'GetColorTableParameteriv' 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(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{cookie} } -// MakeContextCurrentReply represents the data returned from a MakeContextCurrent request. -type MakeContextCurrentReply struct { +// 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 - ContextTag ContextTag - // padding: 20 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 MakeContextCurrent request. -func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { +// 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 @@ -2851,12 +3219,12 @@ func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { if buf == nil { return nil, nil } - return makeContextCurrentReply(buf), nil + return getColorTableParameterivReply(buf), nil } -// makeContextCurrentReply reads a byte slice into a MakeContextCurrentReply value. -func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { - v := new(MakeContextCurrentReply) +// getColorTableParameterivReply reads a byte slice into a GetColorTableParameterivReply value. +func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { + v := new(GetColorTableParameterivReply) b := 1 // skip reply determinant b += 1 // padding @@ -2867,209 +3235,200 @@ func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextTag = ContextTag(xgb.Get32(buf[b:])) + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding + 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 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 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 149 // 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)) + xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(ReadDrawable)) + xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], uint32(Context)) + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// CreatePbufferCookie is a cookie used only for CreatePbuffer requests. -type CreatePbufferCookie struct { +// GetCompressedTexImageARBCookie is a cookie used only for GetCompressedTexImageARB requests. +type GetCompressedTexImageARBCookie 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 { +// 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 'CreatePbuffer' 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, false) - c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) - return CreatePbufferCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{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 { +// GetCompressedTexImageARBUnchecked 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 { 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 'GetCompressedTexImageARB' 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(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{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() +// 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)) } -// 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 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 + } + return getCompressedTexImageARBReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getCompressedTexImageARBReply reads a byte slice into a GetCompressedTexImageARBReply value. +func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { + v := new(GetCompressedTexImageARBReply) + 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)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Pbuffer)) - b += 4 + b += 8 // padding - xgb.Put32(buf[b:], NumAttribs) + v.Size = int32(xgb.Get32(buf[b:])) 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 -} - -// 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} -} + b += 12 // padding -// 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} -} + 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 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 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] = 28 // request opcode + buf[b] = 160 // 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:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) b += 4 return buf } -// GetDrawableAttributesCookie is a cookie used only for GetDrawableAttributes requests. -type GetDrawableAttributesCookie struct { +// GetConvolutionFilterCookie is a cookie used only for GetConvolutionFilter requests. +type GetConvolutionFilterCookie 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 { +// 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 'GetDrawableAttributes' 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, true) - c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) - return GetDrawableAttributesCookie{cookie} + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} } -// GetDrawableAttributesUnchecked sends an unchecked request. +// GetConvolutionFilterUnchecked 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 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 'GetDrawableAttributes' 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, true) - c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) - return GetDrawableAttributesCookie{cookie} + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} } -// GetDrawableAttributesReply represents the data returned from a GetDrawableAttributes request. -type GetDrawableAttributesReply struct { +// 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 - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) + // padding: 8 bytes + Width int32 + Height int32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// 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 GetConvolutionFilter request. +func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3077,12 +3436,12 @@ func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, er if buf == nil { return nil, nil } - return getDrawableAttributesReply(buf), nil + return getConvolutionFilterReply(buf), nil } -// getDrawableAttributesReply reads a byte slice into a GetDrawableAttributesReply value. -func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { - v := new(GetDrawableAttributesReply) +// 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 @@ -3093,572 +3452,665 @@ func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAttribs = xgb.Get32(buf[b:]) + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) b += 4 - b += 20 // padding + v.Height = int32(xgb.Get32(buf[b:])) + b += 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) + 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 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 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] = 29 // request opcode + buf[b] = 150 // 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:], 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 } -// ChangeDrawableAttributesCookie is a cookie used only for ChangeDrawableAttributes requests. -type ChangeDrawableAttributesCookie struct { +// GetConvolutionParameterfvCookie is a cookie used only for GetConvolutionParameterfv requests. +type GetConvolutionParameterfvCookie 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 { +// 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 'ChangeDrawableAttributes' 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, false) - c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) - return ChangeDrawableAttributesCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{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 { +// GetConvolutionParameterfvUnchecked 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 { 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 'GetConvolutionParameterfv' 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)) +} + +// 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 + } + return getConvolutionParameterfvReply(buf), nil +} + +// 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) - return ChangeDrawableAttributesCookie{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 ChangeDrawableAttributesCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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)))) +// 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] = 30 // request opcode + buf[b] = 151 // 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:], NumAttribs) + xgb.Put32(buf[b:], Target) b += 4 - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], Pname) + b += 4 return buf } -// CreateWindowCookie is a cookie used only for CreateWindow requests. -type CreateWindowCookie struct { +// GetConvolutionParameterivCookie is a cookie used only for GetConvolutionParameteriv requests. +type GetConvolutionParameterivCookie struct { *xgb.Cookie } -// 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 { +// 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 'CreateWindow' 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, false) - c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return CreateWindowCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} } -// 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 { +// GetConvolutionParameterivUnchecked 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 { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'CreateWindow' 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, false) - c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return CreateWindowCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{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 { - return cook.Cookie.Check() +// 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)) } -// 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) +// 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 + } + return getConvolutionParameterivReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getConvolutionParameterivReply reads a byte slice into a GetConvolutionParameterivReply value. +func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { + v := new(GetConvolutionParameterivReply) + b := 1 // skip reply determinant - buf[b] = 31 // 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(Fbconfig)) - b += 4 + b += 4 // padding - xgb.Put32(buf[b:], uint32(Window)) + v.N = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(GlxWindow)) + v.Datum = int32(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], NumAttribs) - b += 4 + b += 12 // padding - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) + 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 buf -} - -// DeleteWindowCookie is a cookie used only for DeleteWindow requests. -type DeleteWindowCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteWindow' 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} -} - -// 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 'DeleteWindow' 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} -} - -// Check returns an error if one occurred 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() + return v } -// 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 +// 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] = 32 // request opcode + buf[b] = 152 // 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(Glxwindow)) + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// SetClientInfoARBCookie is a cookie used only for SetClientInfoARB requests. -type SetClientInfoARBCookie struct { +// GetDoublevCookie is a cookie used only for GetDoublev requests. +type GetDoublevCookie 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 { +// 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 'SetClientInfoARB' 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(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfoARBCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{cookie} } -// 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 { +// 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 'SetClientInfoARB' 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, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{cookie} +} + +// 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)) +} + +// 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 } - 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 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] = 33 // request opcode + buf[b] = 114 // 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:], Pname) 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 { +// GetDrawableAttributesCookie is a cookie used only for GetDrawableAttributes requests. +type GetDrawableAttributesCookie 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 { +// 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 'CreateContextAttribsARB' 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(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return CreateContextAttribsARBCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) + return GetDrawableAttributesCookie{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 { +// 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 'CreateContextAttribsARB' 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(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return CreateContextAttribsARBCookie{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 CreateContextAttribsARBCookie) 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 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) +// 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 +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getDrawableAttributesReply reads a byte slice into a GetDrawableAttributesReply value. +func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { + v := new(GetDrawableAttributesReply) + b := 1 // skip reply determinant - buf[b] = 34 // 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(Context)) - b += 4 - - xgb.Put32(buf[b:], uint32(Fbconfig)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], Screen) + v.NumAttribs = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(ShareList)) - b += 4 + b += 20 // padding - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 + 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 - b += 3 // padding + buf[b] = 29 // request opcode + b += 1 - xgb.Put32(buf[b:], NumAttribs) - b += 4 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 return buf } -// SetClientInfo2ARBCookie is a cookie used only for SetClientInfo2ARB requests. -type SetClientInfo2ARBCookie struct { +// GetErrorCookie is a cookie used only for GetError requests. +type GetErrorCookie 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 { +// 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 'SetClientInfo2ARB' 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, false) - c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfo2ARBCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{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 { +// GetErrorUnchecked 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 { 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 'GetError' 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(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{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() +// 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 + Error int32 } -// 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 GetError request. +func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getErrorReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getErrorReply reads a byte slice into a GetErrorReply value. +func getErrorReply(buf []byte) *GetErrorReply { + v := new(GetErrorReply) + 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) + v.Error = int32(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], NumVersions) - b += 4 + return v +} - xgb.Put32(buf[b:], GlStrLen) - b += 4 +// 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) - xgb.Put32(buf[b:], GlxStrLen) - b += 4 + buf[b] = c.Extensions["GLX"] + b += 1 - for i := 0; i < int((int(NumVersions) * 3)); i++ { - xgb.Put32(buf[b:], GlVersions[i]) - b += 4 - } - b = xgb.Pad(b) + buf[b] = 115 // request opcode + b += 1 - copy(buf[b:], GlExtensionString[:GlStrLen]) - b += xgb.Pad(int(GlStrLen)) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += xgb.Pad(int(GlxStrLen)) + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 return buf } -// NewListCookie is a cookie used only for NewList requests. -type NewListCookie struct { +// GetFBConfigsCookie is a cookie used only for GetFBConfigs requests. +type GetFBConfigsCookie 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 { +// 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 'NewList' 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, false) - c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) - return NewListCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{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 { +// 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 { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'NewList' 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, false) - c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) - return NewListCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{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() +// 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)) } -// 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) +// 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 +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getFBConfigsReply reads a byte slice into a GetFBConfigsReply value. +func getFBConfigsReply(buf []byte) *GetFBConfigsReply { + v := new(GetFBConfigsReply) + b := 1 // skip reply determinant - buf[b] = 101 // 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:], List) + v.NumFbConfigs = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], Mode) + v.NumProperties = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// EndListCookie is a cookie used only for EndList requests. -type EndListCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'EndList' 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} -} + b += 16 // padding -// 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 'EndList' 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(endListRequest(c, ContextTag), cookie) - return EndListCookie{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 EndListCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for EndList -// endListRequest writes a EndList request to a byte slice. -func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { +// 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) @@ -3666,62 +4118,113 @@ func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 102 // 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)) + xgb.Put32(buf[b:], Screen) b += 4 return buf } -// DeleteListsCookie is a cookie used only for DeleteLists requests. -type DeleteListsCookie struct { +// GetFloatvCookie is a cookie used only for GetFloatv requests. +type GetFloatvCookie struct { *xgb.Cookie } -// 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 { +// 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 'DeleteLists' 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, false) - c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) - return DeleteListsCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{cookie} } -// 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 { +// GetFloatvUnchecked 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 { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteLists' 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, false) - c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) - return DeleteListsCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{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 DeleteListsCookie) Check() error { - return cook.Cookie.Check() +// 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: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// 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 +// 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 + } + if buf == nil { + return nil, nil + } + return getFloatvReply(buf), nil +} + +// 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 + + 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 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 103 // request opcode + buf[b] = 116 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3730,52 +4233,52 @@ func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range i xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], List) - 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 { +// GetHistogramCookie is a cookie used only for GetHistogram requests. +type GetHistogramCookie 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 { +// 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 'GenLists' 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(genListsRequest(c, ContextTag, Range), cookie) - return GenListsCookie{cookie} + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} } -// GenListsUnchecked 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 GenListsUnchecked(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { +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 'GenLists' 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(genListsRequest(c, ContextTag, Range), cookie) - return GenListsCookie{cookie} + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} } -// GenListsReply represents the data returned from a GenLists request. -type GenListsReply 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 - RetVal uint32 + // padding: 8 bytes + Width 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 GetHistogram request. +func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3783,12 +4286,12 @@ func (cook GenListsCookie) Reply() (*GenListsReply, error) { if buf == nil { return nil, nil } - return genListsReply(buf), nil + return getHistogramReply(buf), nil } -// genListsReply reads a byte slice into a GenListsReply value. -func genListsReply(buf []byte) *GenListsReply { - v := new(GenListsReply) +// 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 @@ -3799,23 +4302,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.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 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 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] = 104 // request opcode + buf[b] = 154 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3824,117 +4335,127 @@ 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:], 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 } -// FeedbackBufferCookie is a cookie used only for FeedbackBuffer requests. -type FeedbackBufferCookie struct { +// GetHistogramParameterfvCookie is a cookie used only for GetHistogramParameterfv requests. +type GetHistogramParameterfvCookie 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 { +// 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 'FeedbackBuffer' 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, false) - c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) - return FeedbackBufferCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{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 { +// GetHistogramParameterfvUnchecked 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 { 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 'GetHistogramParameterfv' 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(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{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() +// 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 + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// 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 GetHistogramParameterfv request. +func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramParameterfvReply(buf), nil +} - buf[b] = c.Extensions["GLX"] - b += 1 +// getHistogramParameterfvReply reads a byte slice into a GetHistogramParameterfvReply value. +func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { + v := new(GetHistogramParameterfvReply) + 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 += 4 // padding - xgb.Put32(buf[b:], uint32(Type)) + v.N = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// SelectBufferCookie is a cookie used only for SelectBuffer requests. -type SelectBufferCookie struct { - *xgb.Cookie -} + v.Datum = Float32(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 += 12 // 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.") + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(true, false) - c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) - return SelectBufferCookie{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 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 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] = 106 // request opcode + buf[b] = 155 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3943,53 +4464,56 @@ 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:], Pname) b += 4 return buf } -// RenderModeCookie is a cookie used only for RenderMode requests. -type RenderModeCookie struct { +// GetHistogramParameterivCookie is a cookie used only for GetHistogramParameteriv requests. +type GetHistogramParameterivCookie 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 { +// 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 'RenderMode' 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(renderModeRequest(c, ContextTag, Mode), cookie) - return RenderModeCookie{cookie} + c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} } -// RenderModeUnchecked 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 RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { +func GetHistogramParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { 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 'GetHistogramParameteriv' 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(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} } -// RenderModeReply represents the data returned from a RenderMode request. -type RenderModeReply 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 - RetVal uint32 - N uint32 - NewMode uint32 + // padding: 4 bytes + N uint32 + Datum int32 // padding: 12 bytes - Data []uint32 // size: xgb.Pad((int(N) * 4)) + Data []int32 // 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 GetHistogramParameteriv request. +func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3997,12 +4521,12 @@ func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { if buf == nil { return nil, nil } - return renderModeReply(buf), nil + return getHistogramParameterivReply(buf), nil } -// renderModeReply reads a byte slice into a RenderModeReply value. -func renderModeReply(buf []byte) *RenderModeReply { - v := new(RenderModeReply) +// 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 @@ -4013,20 +4537,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 = int32(xgb.Get32(buf[b:])) b += 4 b += 12 // padding - v.Data = make([]uint32, v.N) + v.Data = make([]int32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = xgb.Get32(buf[b:]) + v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) @@ -4034,17 +4557,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 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] = 107 // request opcode + buf[b] = 156 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4053,48 +4576,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 { +// GetIntegervCookie is a cookie used only for GetIntegerv requests. +type GetIntegervCookie 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 { +// GetIntegerv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetIntegervCookie.Reply() +func GetIntegerv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { 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 'GetIntegerv' 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(getIntegervRequest(c, ContextTag, Pname), cookie) + return GetIntegervCookie{cookie} } -// FinishUnchecked sends an unchecked request. +// GetIntegervUnchecked 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 GetIntegervUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { 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 'GetIntegerv' 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(getIntegervRequest(c, ContextTag, Pname), cookie) + return GetIntegervCookie{cookie} } -// FinishReply represents the data returned from a Finish request. -type FinishReply struct { +// GetIntegervReply represents the data returned from a GetIntegerv request. +type GetIntegervReply 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 GetIntegerv request. +func (cook GetIntegervCookie) Reply() (*GetIntegervReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4102,12 +4633,12 @@ func (cook FinishCookie) Reply() (*FinishReply, error) { if buf == nil { return nil, nil } - return finishReply(buf), nil + return getIntegervReply(buf), nil } -// finishReply reads a byte slice into a FinishReply value. -func finishReply(buf []byte) *FinishReply { - v := new(FinishReply) +// getIntegervReply reads a byte slice into a GetIntegervReply value. +func getIntegervReply(buf []byte) *GetIntegervReply { + v := new(GetIntegervReply) b := 1 // skip reply determinant b += 1 // padding @@ -4118,136 +4649,37 @@ func finishReply(buf []byte) *FinishReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - 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 - - return buf -} - -// PixelStorefCookie is a cookie used only for PixelStoref requests. -type PixelStorefCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'PixelStoref' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) - return PixelStorefCookie{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() -} - -// 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) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 109 // 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 += 4 // padding - xgb.Put32(buf[b:], Pname) + v.N = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(Datum)) + v.Datum = int32(xgb.Get32(buf[b:])) b += 4 - return buf -} - -// PixelStoreiCookie is a cookie used only for PixelStorei requests. -type PixelStoreiCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'PixelStorei' 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} -} + b += 12 // padding -// 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.") + 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(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) - return PixelStoreiCookie{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 PixelStoreiCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 +// Write request to wire for GetIntegerv +// getIntegervRequest writes a GetIntegerv request to a byte slice. +func getIntegervRequest(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] = 110 // request opcode + buf[b] = 117 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4259,50 +4691,50 @@ func pixelStoreiRequest(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 } -// ReadPixelsCookie is a cookie used only for ReadPixels requests. -type ReadPixelsCookie struct { +// GetLightfvCookie is a cookie used only for GetLightfv requests. +type GetLightfvCookie 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 { +// GetLightfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetLightfvCookie.Reply() +func GetLightfv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { 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 'GetLightfv' 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(getLightfvRequest(c, ContextTag, Light, Pname), cookie) + return GetLightfvCookie{cookie} } -// ReadPixelsUnchecked sends an unchecked request. +// GetLightfvUnchecked 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 GetLightfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { 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 'GetLightfv' 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(getLightfvRequest(c, ContextTag, Light, Pname), cookie) + return GetLightfvCookie{cookie} } -// ReadPixelsReply represents the data returned from a ReadPixels request. -type ReadPixelsReply struct { +// GetLightfvReply represents the data returned from a GetLightfv request. +type GetLightfvReply 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)) + // 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 ReadPixels request. -func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { +// Reply blocks and returns the reply data for a GetLightfv request. +func (cook GetLightfvCookie) Reply() (*GetLightfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4310,12 +4742,12 @@ func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { if buf == nil { return nil, nil } - return readPixelsReply(buf), nil + return getLightfvReply(buf), nil } -// readPixelsReply reads a byte slice into a ReadPixelsReply value. -func readPixelsReply(buf []byte) *ReadPixelsReply { - v := new(ReadPixelsReply) +// getLightfvReply reads a byte slice into a GetLightfvReply value. +func getLightfvReply(buf []byte) *GetLightfvReply { + v := new(GetLightfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -4326,26 +4758,37 @@ func readPixelsReply(buf []byte) *ReadPixelsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 24 // padding + b += 4 // 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.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 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 GetLightfv +// getLightfvRequest writes a GetLightfv request to a byte slice. +func getLightfvRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 111 // request opcode + buf[b] = 118 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4354,82 +4797,56 @@ 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) + xgb.Put32(buf[b:], Light) b += 4 - xgb.Put32(buf[b:], Type) + xgb.Put32(buf[b:], Pname) 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 { +// GetLightivCookie is a cookie used only for GetLightiv requests. +type GetLightivCookie 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 { +// GetLightiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetLightivCookie.Reply() +func GetLightiv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { 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 'GetLightiv' 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(getLightivRequest(c, ContextTag, Light, Pname), cookie) + return GetLightivCookie{cookie} } -// GetBooleanvUnchecked sends an unchecked request. +// GetLightivUnchecked 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 GetLightivUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { 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 'GetLightiv' 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(getLightivRequest(c, ContextTag, Light, Pname), cookie) + return GetLightivCookie{cookie} } -// GetBooleanvReply represents the data returned from a GetBooleanv request. -type GetBooleanvReply struct { +// GetLightivReply represents the data returned from a GetLightiv request. +type GetLightivReply 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)) + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 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 GetLightiv request. +func (cook GetLightivCookie) Reply() (*GetLightivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4437,12 +4854,12 @@ func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { if buf == nil { return nil, nil } - return getBooleanvReply(buf), nil + return getLightivReply(buf), nil } -// getBooleanvReply reads a byte slice into a GetBooleanvReply value. -func getBooleanvReply(buf []byte) *GetBooleanvReply { - v := new(GetBooleanvReply) +// getLightivReply reads a byte slice into a GetLightivReply value. +func getLightivReply(buf []byte) *GetLightivReply { + v := new(GetLightivReply) b := 1 // skip reply determinant b += 1 // padding @@ -4458,40 +4875,32 @@ func getBooleanvReply(buf []byte) *GetBooleanvReply { v.N = xgb.Get32(buf[b:]) b += 4 - if buf[b] == 1 { - v.Datum = true - } else { - v.Datum = false - } - b += 1 + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 - b += 15 // padding + b += 12 // padding - v.Data = make([]bool, v.N) + v.Data = make([]int32, 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.Data[i] = int32(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 GetLightiv +// getLightivRequest writes a GetLightiv request to a byte slice. +func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 112 // request opcode + buf[b] = 119 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4500,50 +4909,56 @@ func getBooleanvRequest(c *xgb.Conn, ContextTag ContextTag, Pname int32) []byte xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(Pname)) + xgb.Put32(buf[b:], Light) + b += 4 + + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetClipPlaneCookie is a cookie used only for GetClipPlane requests. -type GetClipPlaneCookie struct { +// GetMapdvCookie is a cookie used only for GetMapdv requests. +type GetMapdvCookie 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 { +// GetMapdv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMapdvCookie.Reply() +func GetMapdv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { 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 'GetMapdv' 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(getMapdvRequest(c, ContextTag, Target, Query), cookie) + return GetMapdvCookie{cookie} } -// GetClipPlaneUnchecked sends an unchecked request. +// GetMapdvUnchecked 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 GetMapdvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { 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 'GetMapdv' 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(getMapdvRequest(c, ContextTag, Target, Query), cookie) + return GetMapdvCookie{cookie} } -// GetClipPlaneReply represents the data returned from a GetClipPlane request. -type GetClipPlaneReply struct { +// GetMapdvReply represents the data returned from a GetMapdv request. +type GetMapdvReply 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 Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) } -// 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 GetMapdv request. +func (cook GetMapdvCookie) Reply() (*GetMapdvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4551,12 +4966,12 @@ func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { if buf == nil { return nil, nil } - return getClipPlaneReply(buf), nil + return getMapdvReply(buf), nil } -// getClipPlaneReply reads a byte slice into a GetClipPlaneReply value. -func getClipPlaneReply(buf []byte) *GetClipPlaneReply { - v := new(GetClipPlaneReply) +// getMapdvReply reads a byte slice into a GetMapdvReply value. +func getMapdvReply(buf []byte) *GetMapdvReply { + v := new(GetMapdvReply) b := 1 // skip reply determinant b += 1 // padding @@ -4567,10 +4982,18 @@ 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.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 } @@ -4579,17 +5002,17 @@ func getClipPlaneReply(buf []byte) *GetClipPlaneReply { 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 { - size := 12 +// Write request to wire for GetMapdv +// getMapdvRequest writes a GetMapdv request to a byte slice. +func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 113 // request opcode + buf[b] = 120 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4598,53 +5021,56 @@ 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:], Target) + b += 4 + + xgb.Put32(buf[b:], Query) b += 4 return buf } -// GetDoublevCookie is a cookie used only for GetDoublev requests. -type GetDoublevCookie struct { +// GetMapfvCookie is a cookie used only for GetMapfv requests. +type GetMapfvCookie 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 { +// GetMapfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMapfvCookie.Reply() +func GetMapfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { 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 'GetMapfv' 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(getMapfvRequest(c, ContextTag, Target, Query), cookie) + return GetMapfvCookie{cookie} } -// GetDoublevUnchecked sends an unchecked request. +// GetMapfvUnchecked 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 GetMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { 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 'GetMapfv' 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(getMapfvRequest(c, ContextTag, Target, Query), cookie) + return GetMapfvCookie{cookie} } -// GetDoublevReply represents the data returned from a GetDoublev request. -type GetDoublevReply struct { +// GetMapfvReply represents the data returned from a GetMapfv request. +type GetMapfvReply 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)) + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// 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 GetMapfv request. +func (cook GetMapfvCookie) Reply() (*GetMapfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4652,12 +5078,12 @@ func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { if buf == nil { return nil, nil } - return getDoublevReply(buf), nil + return getMapfvReply(buf), nil } -// getDoublevReply reads a byte slice into a GetDoublevReply value. -func getDoublevReply(buf []byte) *GetDoublevReply { - v := new(GetDoublevReply) +// getMapfvReply reads a byte slice into a GetMapfvReply value. +func getMapfvReply(buf []byte) *GetMapfvReply { + v := new(GetMapfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -4673,32 +5099,32 @@ func getDoublevReply(buf []byte) *GetDoublevReply { v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = Float64(xgb.Get64(buf[b:])) - b += 8 + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 - b += 8 // padding + b += 12 // padding - v.Data = make([]Float64, v.N) + v.Data = make([]Float32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = Float64(xgb.Get64(buf[b:])) - b += 8 + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 } 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 +// Write request to wire for GetMapfv +// getMapfvRequest writes a GetMapfv request to a byte slice. +func getMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 114 // request opcode + buf[b] = 121 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4707,49 +5133,56 @@ 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:], Query) b += 4 return buf } -// GetErrorCookie is a cookie used only for GetError requests. -type GetErrorCookie struct { +// GetMapivCookie is a cookie used only for GetMapiv requests. +type GetMapivCookie 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 { +// GetMapiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMapivCookie.Reply() +func GetMapiv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { 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 'GetMapiv' 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(getMapivRequest(c, ContextTag, Target, Query), cookie) + return GetMapivCookie{cookie} } -// GetErrorUnchecked sends an unchecked request. +// GetMapivUnchecked 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 GetMapivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { 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 'GetMapiv' 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(getMapivRequest(c, ContextTag, Target, Query), cookie) + return GetMapivCookie{cookie} } -// GetErrorReply represents the data returned from a GetError request. -type GetErrorReply struct { +// GetMapivReply represents the data returned from a GetMapiv request. +type GetMapivReply 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 int32 + // padding: 12 bytes + Data []int32 // 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 GetMapiv request. +func (cook GetMapivCookie) Reply() (*GetMapivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4757,12 +5190,12 @@ func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { if buf == nil { return nil, nil } - return getErrorReply(buf), nil + return getMapivReply(buf), nil } -// getErrorReply reads a byte slice into a GetErrorReply value. -func getErrorReply(buf []byte) *GetErrorReply { - v := new(GetErrorReply) +// getMapivReply reads a byte slice into a GetMapivReply value. +func getMapivReply(buf []byte) *GetMapivReply { + v := new(GetMapivReply) b := 1 // skip reply determinant b += 1 // padding @@ -4773,23 +5206,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 = 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 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 GetMapiv +// getMapivRequest writes a GetMapiv request to a byte slice. +func getMapivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 115 // request opcode + buf[b] = 122 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4798,38 +5245,44 @@ 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:], Query) + b += 4 + return buf } -// GetFloatvCookie is a cookie used only for GetFloatv requests. -type GetFloatvCookie struct { +// GetMaterialfvCookie is a cookie used only for GetMaterialfv requests. +type GetMaterialfvCookie 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 { +// GetMaterialfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMaterialfvCookie.Reply() +func GetMaterialfv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { 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 'GetMaterialfv' 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(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialfvCookie{cookie} } -// GetFloatvUnchecked sends an unchecked request. +// GetMaterialfvUnchecked 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 GetMaterialfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { 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 'GetMaterialfv' 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(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialfvCookie{cookie} } -// GetFloatvReply represents the data returned from a GetFloatv request. -type GetFloatvReply struct { +// GetMaterialfvReply represents the data returned from a GetMaterialfv request. +type GetMaterialfvReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -4840,8 +5293,8 @@ type GetFloatvReply struct { Data []Float32 // 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 GetMaterialfv request. +func (cook GetMaterialfvCookie) Reply() (*GetMaterialfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4849,12 +5302,12 @@ func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { if buf == nil { return nil, nil } - return getFloatvReply(buf), nil + return getMaterialfvReply(buf), nil } -// getFloatvReply reads a byte slice into a GetFloatvReply value. -func getFloatvReply(buf []byte) *GetFloatvReply { - v := new(GetFloatvReply) +// getMaterialfvReply reads a byte slice into a GetMaterialfvReply value. +func getMaterialfvReply(buf []byte) *GetMaterialfvReply { + v := new(GetMaterialfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -4885,17 +5338,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 GetMaterialfv +// getMaterialfvRequest writes a GetMaterialfv request to a byte slice. +func getMaterialfvRequest(c *xgb.Conn, ContextTag ContextTag, Face 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] = 123 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4904,41 +5357,44 @@ func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 + xgb.Put32(buf[b:], Face) + b += 4 + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetIntegervCookie is a cookie used only for GetIntegerv requests. -type GetIntegervCookie struct { +// GetMaterialivCookie is a cookie used only for GetMaterialiv requests. +type GetMaterialivCookie struct { *xgb.Cookie } -// GetIntegerv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetIntegervCookie.Reply() -func GetIntegerv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { +// GetMaterialiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMaterialivCookie.Reply() +func GetMaterialiv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetIntegerv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMaterialiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) - return GetIntegervCookie{cookie} + c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialivCookie{cookie} } -// GetIntegervUnchecked sends an unchecked request. +// GetMaterialivUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetIntegervUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { +func GetMaterialivUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetIntegerv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMaterialiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) - return GetIntegervCookie{cookie} + c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialivCookie{cookie} } -// GetIntegervReply represents the data returned from a GetIntegerv request. -type GetIntegervReply struct { +// GetMaterialivReply represents the data returned from a GetMaterialiv request. +type GetMaterialivReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -4949,8 +5405,8 @@ type GetIntegervReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetIntegerv request. -func (cook GetIntegervCookie) Reply() (*GetIntegervReply, error) { +// Reply blocks and returns the reply data for a GetMaterialiv request. +func (cook GetMaterialivCookie) Reply() (*GetMaterialivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4958,12 +5414,12 @@ func (cook GetIntegervCookie) Reply() (*GetIntegervReply, error) { if buf == nil { return nil, nil } - return getIntegervReply(buf), nil + return getMaterialivReply(buf), nil } -// getIntegervReply reads a byte slice into a GetIntegervReply value. -func getIntegervReply(buf []byte) *GetIntegervReply { - v := new(GetIntegervReply) +// getMaterialivReply reads a byte slice into a GetMaterialivReply value. +func getMaterialivReply(buf []byte) *GetMaterialivReply { + v := new(GetMaterialivReply) b := 1 // skip reply determinant b += 1 // padding @@ -4994,17 +5450,17 @@ func getIntegervReply(buf []byte) *GetIntegervReply { return v } -// Write request to wire for GetIntegerv -// getIntegervRequest writes a GetIntegerv request to a byte slice. -func getIntegervRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { - size := 12 +// Write request to wire for GetMaterialiv +// getMaterialivRequest writes a GetMaterialiv request to a byte slice. +func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 117 // request opcode + buf[b] = 124 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5013,53 +5469,53 @@ func getIntegervRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 + xgb.Put32(buf[b:], Face) + b += 4 + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetLightfvCookie is a cookie used only for GetLightfv requests. -type GetLightfvCookie struct { +// GetMinmaxCookie is a cookie used only for GetMinmax requests. +type GetMinmaxCookie struct { *xgb.Cookie } -// GetLightfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetLightfvCookie.Reply() -func GetLightfv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { +// 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 'GetLightfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) - return GetLightfvCookie{cookie} + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} } -// GetLightfvUnchecked sends an unchecked request. +// GetMinmaxUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetLightfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { +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 'GetLightfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) - return GetLightfvCookie{cookie} + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} } -// GetLightfvReply represents the data returned from a GetLightfv request. -type GetLightfvReply struct { +// 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: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Reply blocks and returns the reply data for a GetLightfv request. -func (cook GetLightfvCookie) Reply() (*GetLightfvReply, error) { +// 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 @@ -5067,12 +5523,12 @@ func (cook GetLightfvCookie) Reply() (*GetLightfvReply, error) { if buf == nil { return nil, nil } - return getLightfvReply(buf), nil + return getMinmaxReply(buf), nil } -// getLightfvReply reads a byte slice into a GetLightfvReply value. -func getLightfvReply(buf []byte) *GetLightfvReply { - v := new(GetLightfvReply) +// 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 @@ -5083,37 +5539,26 @@ func getLightfvReply(buf []byte) *GetLightfvReply { 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 + b += 24 // 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) + 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 GetLightfv -// getLightfvRequest writes a GetLightfv request to a byte slice. -func getLightfvRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { - size := 16 +// 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] = 118 // request opcode + buf[b] = 157 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5122,56 +5567,73 @@ func getLightfvRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname u xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Light) + xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], Pname) + 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 } -// GetLightivCookie is a cookie used only for GetLightiv requests. -type GetLightivCookie struct { +// GetMinmaxParameterfvCookie is a cookie used only for GetMinmaxParameterfv requests. +type GetMinmaxParameterfvCookie struct { *xgb.Cookie } -// GetLightiv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetLightivCookie.Reply() -func GetLightiv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { +// 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 'GetLightiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) - return GetLightivCookie{cookie} + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} } -// GetLightivUnchecked sends an unchecked request. +// GetMinmaxParameterfvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetLightivUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { +func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetLightiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) - return GetLightivCookie{cookie} + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} } -// GetLightivReply represents the data returned from a GetLightiv request. -type GetLightivReply struct { +// 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 int32 + Datum Float32 // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetLightiv request. -func (cook GetLightivCookie) Reply() (*GetLightivReply, error) { +// 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 @@ -5179,12 +5641,12 @@ func (cook GetLightivCookie) Reply() (*GetLightivReply, error) { if buf == nil { return nil, nil } - return getLightivReply(buf), nil + return getMinmaxParameterfvReply(buf), nil } -// getLightivReply reads a byte slice into a GetLightivReply value. -func getLightivReply(buf []byte) *GetLightivReply { - v := new(GetLightivReply) +// 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 @@ -5200,14 +5662,14 @@ func getLightivReply(buf []byte) *GetLightivReply { v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = int32(xgb.Get32(buf[b:])) + v.Datum = Float32(xgb.Get32(buf[b:])) b += 4 b += 12 // padding - v.Data = make([]int32, v.N) + v.Data = make([]Float32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) + v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) @@ -5215,9 +5677,9 @@ func getLightivReply(buf []byte) *GetLightivReply { return v } -// Write request to wire for GetLightiv -// getLightivRequest writes a GetLightiv request to a byte slice. -func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { +// 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) @@ -5225,7 +5687,7 @@ func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname u buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 119 // request opcode + buf[b] = 158 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5234,7 +5696,7 @@ func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname u xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Light) + xgb.Put32(buf[b:], Target) b += 4 xgb.Put32(buf[b:], Pname) @@ -5243,47 +5705,47 @@ func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname u return buf } -// GetMapdvCookie is a cookie used only for GetMapdv requests. -type GetMapdvCookie struct { +// GetMinmaxParameterivCookie is a cookie used only for GetMinmaxParameteriv requests. +type GetMinmaxParameterivCookie struct { *xgb.Cookie } -// GetMapdv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMapdvCookie.Reply() -func GetMapdv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { +// 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 'GetMapdv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) - return GetMapdvCookie{cookie} + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} } -// GetMapdvUnchecked sends an unchecked request. +// GetMinmaxParameterivUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMapdvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { +func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMapdv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) - return GetMapdvCookie{cookie} + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} } -// GetMapdvReply represents the data returned from a GetMapdv request. -type GetMapdvReply struct { +// 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 Float64 - // padding: 8 bytes - Data []Float64 // size: xgb.Pad((int(N) * 8)) + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetMapdv request. -func (cook GetMapdvCookie) Reply() (*GetMapdvReply, error) { +// 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 @@ -5291,12 +5753,12 @@ func (cook GetMapdvCookie) Reply() (*GetMapdvReply, error) { if buf == nil { return nil, nil } - return getMapdvReply(buf), nil + return getMinmaxParameterivReply(buf), nil } -// getMapdvReply reads a byte slice into a GetMapdvReply value. -func getMapdvReply(buf []byte) *GetMapdvReply { - v := new(GetMapdvReply) +// 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 @@ -5312,24 +5774,24 @@ func getMapdvReply(buf []byte) *GetMapdvReply { v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = Float64(xgb.Get64(buf[b:])) - b += 8 + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 - b += 8 // padding + b += 12 // padding - v.Data = make([]Float64, v.N) + v.Data = make([]int32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = Float64(xgb.Get64(buf[b:])) - b += 8 + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 } b = xgb.Pad(b) return v } -// Write request to wire for GetMapdv -// getMapdvRequest writes a GetMapdv request to a byte slice. -func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { +// 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) @@ -5337,7 +5799,7 @@ func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query ui buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 120 // request opcode + buf[b] = 159 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5349,41 +5811,41 @@ func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query ui xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], Query) + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetMapfvCookie is a cookie used only for GetMapfv requests. -type GetMapfvCookie struct { +// GetPixelMapfvCookie is a cookie used only for GetPixelMapfv requests. +type GetPixelMapfvCookie struct { *xgb.Cookie } -// GetMapfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMapfvCookie.Reply() -func GetMapfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { +// GetPixelMapfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPixelMapfvCookie.Reply() +func GetPixelMapfv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMapfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPixelMapfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) - return GetMapfvCookie{cookie} + c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) + return GetPixelMapfvCookie{cookie} } -// GetMapfvUnchecked sends an unchecked request. +// GetPixelMapfvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { +func GetPixelMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMapfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPixelMapfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) - return GetMapfvCookie{cookie} + c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) + return GetPixelMapfvCookie{cookie} } -// GetMapfvReply represents the data returned from a GetMapfv request. -type GetMapfvReply struct { +// GetPixelMapfvReply represents the data returned from a GetPixelMapfv request. +type GetPixelMapfvReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -5394,8 +5856,8 @@ type GetMapfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetMapfv request. -func (cook GetMapfvCookie) Reply() (*GetMapfvReply, error) { +// Reply blocks and returns the reply data for a GetPixelMapfv request. +func (cook GetPixelMapfvCookie) Reply() (*GetPixelMapfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5403,12 +5865,12 @@ func (cook GetMapfvCookie) Reply() (*GetMapfvReply, error) { if buf == nil { return nil, nil } - return getMapfvReply(buf), nil + return getPixelMapfvReply(buf), nil } -// getMapfvReply reads a byte slice into a GetMapfvReply value. -func getMapfvReply(buf []byte) *GetMapfvReply { - v := new(GetMapfvReply) +// getPixelMapfvReply reads a byte slice into a GetPixelMapfvReply value. +func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { + v := new(GetPixelMapfvReply) b := 1 // skip reply determinant b += 1 // padding @@ -5439,17 +5901,17 @@ func getMapfvReply(buf []byte) *GetMapfvReply { return v } -// Write request to wire for GetMapfv -// getMapfvRequest writes a GetMapfv request to a byte slice. -func getMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { - size := 16 +// Write request to wire for GetPixelMapfv +// getPixelMapfvRequest writes a GetPixelMapfv request to a byte slice. +func getPixelMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 121 // request opcode + buf[b] = 125 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5458,56 +5920,53 @@ func getMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query ui xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Query) + xgb.Put32(buf[b:], Map) b += 4 return buf } -// GetMapivCookie is a cookie used only for GetMapiv requests. -type GetMapivCookie struct { +// GetPixelMapuivCookie is a cookie used only for GetPixelMapuiv requests. +type GetPixelMapuivCookie struct { *xgb.Cookie } -// GetMapiv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMapivCookie.Reply() -func GetMapiv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { +// GetPixelMapuiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPixelMapuivCookie.Reply() +func GetPixelMapuiv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMapiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPixelMapuiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) - return GetMapivCookie{cookie} + c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) + return GetPixelMapuivCookie{cookie} } -// GetMapivUnchecked sends an unchecked request. +// GetPixelMapuivUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMapivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { +func GetPixelMapuivUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMapiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPixelMapuiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) - return GetMapivCookie{cookie} + c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) + return GetPixelMapuivCookie{cookie} } -// GetMapivReply represents the data returned from a GetMapiv request. -type GetMapivReply struct { +// GetPixelMapuivReply represents the data returned from a GetPixelMapuiv request. +type GetPixelMapuivReply 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 + Datum 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 GetMapiv request. -func (cook GetMapivCookie) Reply() (*GetMapivReply, error) { +// Reply blocks and returns the reply data for a GetPixelMapuiv request. +func (cook GetPixelMapuivCookie) Reply() (*GetPixelMapuivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5515,12 +5974,12 @@ func (cook GetMapivCookie) Reply() (*GetMapivReply, error) { if buf == nil { return nil, nil } - return getMapivReply(buf), nil + return getPixelMapuivReply(buf), nil } -// getMapivReply reads a byte slice into a GetMapivReply value. -func getMapivReply(buf []byte) *GetMapivReply { - v := new(GetMapivReply) +// getPixelMapuivReply reads a byte slice into a GetPixelMapuivReply value. +func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { + v := new(GetPixelMapuivReply) b := 1 // skip reply determinant b += 1 // padding @@ -5536,14 +5995,14 @@ func getMapivReply(buf []byte) *GetMapivReply { v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = int32(xgb.Get32(buf[b:])) + v.Datum = 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) @@ -5551,17 +6010,17 @@ func getMapivReply(buf []byte) *GetMapivReply { return v } -// Write request to wire for GetMapiv -// getMapivRequest writes a GetMapiv request to a byte slice. -func getMapivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { - size := 16 +// Write request to wire for GetPixelMapuiv +// getPixelMapuivRequest writes a GetPixelMapuiv request to a byte slice. +func getPixelMapuivRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 122 // request opcode + buf[b] = 126 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5570,56 +6029,53 @@ func getMapivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query ui xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Query) + xgb.Put32(buf[b:], Map) b += 4 return buf } -// GetMaterialfvCookie is a cookie used only for GetMaterialfv requests. -type GetMaterialfvCookie struct { +// GetPixelMapusvCookie is a cookie used only for GetPixelMapusv requests. +type GetPixelMapusvCookie struct { *xgb.Cookie } -// GetMaterialfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMaterialfvCookie.Reply() -func GetMaterialfv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { +// GetPixelMapusv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPixelMapusvCookie.Reply() +func GetPixelMapusv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMaterialfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPixelMapusv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) - return GetMaterialfvCookie{cookie} + c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) + return GetPixelMapusvCookie{cookie} } -// GetMaterialfvUnchecked sends an unchecked request. +// GetPixelMapusvUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMaterialfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { +func GetPixelMapusvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMaterialfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPixelMapusv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) - return GetMaterialfvCookie{cookie} + c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) + return GetPixelMapusvCookie{cookie} } -// GetMaterialfvReply represents the data returned from a GetMaterialfv request. -type GetMaterialfvReply struct { +// GetPixelMapusvReply represents the data returned from a GetPixelMapusv request. +type GetPixelMapusvReply 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)) + Datum uint16 + // padding: 16 bytes + Data []uint16 // size: xgb.Pad((int(N) * 2)) } -// Reply blocks and returns the reply data for a GetMaterialfv request. -func (cook GetMaterialfvCookie) Reply() (*GetMaterialfvReply, error) { +// Reply blocks and returns the reply data for a GetPixelMapusv request. +func (cook GetPixelMapusvCookie) Reply() (*GetPixelMapusvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5627,12 +6083,12 @@ func (cook GetMaterialfvCookie) Reply() (*GetMaterialfvReply, error) { if buf == nil { return nil, nil } - return getMaterialfvReply(buf), nil + return getPixelMapusvReply(buf), nil } -// getMaterialfvReply reads a byte slice into a GetMaterialfvReply value. -func getMaterialfvReply(buf []byte) *GetMaterialfvReply { - v := new(GetMaterialfvReply) +// getPixelMapusvReply reads a byte slice into a GetPixelMapusvReply value. +func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { + v := new(GetPixelMapusvReply) b := 1 // skip reply determinant b += 1 // padding @@ -5648,32 +6104,32 @@ func getMaterialfvReply(buf []byte) *GetMaterialfvReply { v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = Float32(xgb.Get32(buf[b:])) - b += 4 + v.Datum = xgb.Get16(buf[b:]) + b += 2 - b += 12 // padding + b += 16 // padding - v.Data = make([]Float32, v.N) + v.Data = make([]uint16, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) - b += 4 + v.Data[i] = xgb.Get16(buf[b:]) + b += 2 } b = xgb.Pad(b) return v } -// Write request to wire for GetMaterialfv -// getMaterialfvRequest writes a GetMaterialfv request to a byte slice. -func getMaterialfvRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for GetPixelMapusv +// getPixelMapusvRequest writes a GetPixelMapusv request to a byte slice. +func getPixelMapusvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 123 // request opcode + buf[b] = 127 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5682,56 +6138,50 @@ func getMaterialfvRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Face) - b += 4 - - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], Map) b += 4 return buf } -// GetMaterialivCookie is a cookie used only for GetMaterialiv requests. -type GetMaterialivCookie struct { +// GetPolygonStippleCookie is a cookie used only for GetPolygonStipple requests. +type GetPolygonStippleCookie struct { *xgb.Cookie } -// GetMaterialiv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMaterialivCookie.Reply() -func GetMaterialiv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { +// GetPolygonStipple sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPolygonStippleCookie.Reply() +func GetPolygonStipple(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMaterialiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPolygonStipple' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) - return GetMaterialivCookie{cookie} + c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) + return GetPolygonStippleCookie{cookie} } -// GetMaterialivUnchecked sends an unchecked request. +// GetPolygonStippleUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMaterialivUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { +func GetPolygonStippleUnchecked(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMaterialiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPolygonStipple' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) - return GetMaterialivCookie{cookie} + c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) + return GetPolygonStippleCookie{cookie} } -// GetMaterialivReply represents the data returned from a GetMaterialiv request. -type GetMaterialivReply struct { +// GetPolygonStippleReply represents the data returned from a GetPolygonStipple request. +type GetPolygonStippleReply 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)) + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Reply blocks and returns the reply data for a GetMaterialiv request. -func (cook GetMaterialivCookie) Reply() (*GetMaterialivReply, error) { +// Reply blocks and returns the reply data for a GetPolygonStipple request. +func (cook GetPolygonStippleCookie) Reply() (*GetPolygonStippleReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5739,12 +6189,12 @@ func (cook GetMaterialivCookie) Reply() (*GetMaterialivReply, error) { if buf == nil { return nil, nil } - return getMaterialivReply(buf), nil + return getPolygonStippleReply(buf), nil } -// getMaterialivReply reads a byte slice into a GetMaterialivReply value. -func getMaterialivReply(buf []byte) *GetMaterialivReply { - v := new(GetMaterialivReply) +// getPolygonStippleReply reads a byte slice into a GetPolygonStippleReply value. +func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { + v := new(GetPolygonStippleReply) b := 1 // skip reply determinant b += 1 // padding @@ -5755,37 +6205,26 @@ func getMaterialivReply(buf []byte) *GetMaterialivReply { 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 + b += 24 // 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) + 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 GetMaterialiv -// getMaterialivRequest writes a GetMaterialiv request to a byte slice. -func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { - size := 16 +// Write request to wire for GetPolygonStipple +// getPolygonStippleRequest writes a GetPolygonStipple request to a byte slice. +func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 124 // request opcode + buf[b] = 128 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5794,56 +6233,57 @@ func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Face) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 + if LsbFirst { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 return buf } -// GetPixelMapfvCookie is a cookie used only for GetPixelMapfv requests. -type GetPixelMapfvCookie struct { +// GetQueryObjectivARBCookie is a cookie used only for GetQueryObjectivARB requests. +type GetQueryObjectivARBCookie struct { *xgb.Cookie } -// GetPixelMapfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPixelMapfvCookie.Reply() -func GetPixelMapfv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { +// 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 'GetPixelMapfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) - return GetPixelMapfvCookie{cookie} + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} } -// GetPixelMapfvUnchecked sends an unchecked request. +// GetQueryObjectivARBUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPixelMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { +func GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetPixelMapfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) - return GetPixelMapfvCookie{cookie} + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} } -// GetPixelMapfvReply represents the data returned from a GetPixelMapfv request. -type GetPixelMapfvReply struct { +// 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 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 GetPixelMapfv request. -func (cook GetPixelMapfvCookie) Reply() (*GetPixelMapfvReply, error) { +// 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 @@ -5851,12 +6291,12 @@ func (cook GetPixelMapfvCookie) Reply() (*GetPixelMapfvReply, error) { if buf == nil { return nil, nil } - return getPixelMapfvReply(buf), nil + return getQueryObjectivARBReply(buf), nil } -// getPixelMapfvReply reads a byte slice into a GetPixelMapfvReply value. -func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { - v := new(GetPixelMapfvReply) +// 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 @@ -5872,14 +6312,14 @@ func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { 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) @@ -5887,17 +6327,17 @@ func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { return v } -// Write request to wire for GetPixelMapfv -// getPixelMapfvRequest writes a GetPixelMapfv request to a byte slice. -func getPixelMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { - size := 12 +// 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] = 125 // request opcode + buf[b] = 165 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5906,41 +6346,44 @@ func getPixelMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Map) + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetPixelMapuivCookie is a cookie used only for GetPixelMapuiv requests. -type GetPixelMapuivCookie struct { +// GetQueryObjectuivARBCookie is a cookie used only for GetQueryObjectuivARB requests. +type GetQueryObjectuivARBCookie struct { *xgb.Cookie } -// GetPixelMapuiv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPixelMapuivCookie.Reply() -func GetPixelMapuiv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { +// 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 'GetPixelMapuiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) - return GetPixelMapuivCookie{cookie} + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} } -// GetPixelMapuivUnchecked sends an unchecked request. +// GetQueryObjectuivARBUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPixelMapuivUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { +func GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetPixelMapuiv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) - return GetPixelMapuivCookie{cookie} + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} } -// GetPixelMapuivReply represents the data returned from a GetPixelMapuiv request. -type GetPixelMapuivReply struct { +// 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 @@ -5951,8 +6394,8 @@ type GetPixelMapuivReply struct { Data []uint32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetPixelMapuiv request. -func (cook GetPixelMapuivCookie) Reply() (*GetPixelMapuivReply, error) { +// 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 @@ -5960,12 +6403,12 @@ func (cook GetPixelMapuivCookie) Reply() (*GetPixelMapuivReply, error) { if buf == nil { return nil, nil } - return getPixelMapuivReply(buf), nil + return getQueryObjectuivARBReply(buf), nil } -// getPixelMapuivReply reads a byte slice into a GetPixelMapuivReply value. -func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { - v := new(GetPixelMapuivReply) +// 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 @@ -5996,17 +6439,17 @@ func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { return v } -// Write request to wire for GetPixelMapuiv -// getPixelMapuivRequest writes a GetPixelMapuiv request to a byte slice. -func getPixelMapuivRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { - size := 12 +// 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] = 126 // request opcode + buf[b] = 166 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6015,53 +6458,56 @@ func getPixelMapuivRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byt xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Map) + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetPixelMapusvCookie is a cookie used only for GetPixelMapusv requests. -type GetPixelMapusvCookie struct { +// GetQueryivARBCookie is a cookie used only for GetQueryivARB requests. +type GetQueryivARBCookie struct { *xgb.Cookie } -// GetPixelMapusv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPixelMapusvCookie.Reply() -func GetPixelMapusv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { +// 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 'GetPixelMapusv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) - return GetPixelMapusvCookie{cookie} + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} } -// GetPixelMapusvUnchecked sends an unchecked request. +// GetQueryivARBUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPixelMapusvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { +func GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetPixelMapusv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) - return GetPixelMapusvCookie{cookie} + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} } -// GetPixelMapusvReply represents the data returned from a GetPixelMapusv request. -type GetPixelMapusvReply struct { +// 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 uint16 - // padding: 16 bytes - Data []uint16 // size: xgb.Pad((int(N) * 2)) + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetPixelMapusv request. -func (cook GetPixelMapusvCookie) Reply() (*GetPixelMapusvReply, error) { +// 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 @@ -6069,12 +6515,12 @@ func (cook GetPixelMapusvCookie) Reply() (*GetPixelMapusvReply, error) { if buf == nil { return nil, nil } - return getPixelMapusvReply(buf), nil + return getQueryivARBReply(buf), nil } -// getPixelMapusvReply reads a byte slice into a GetPixelMapusvReply value. -func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { - v := new(GetPixelMapusvReply) +// 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 @@ -6090,32 +6536,32 @@ func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = xgb.Get16(buf[b:]) - b += 2 + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 - b += 16 // padding + b += 12 // padding - v.Data = make([]uint16, v.N) + v.Data = make([]int32, v.N) for i := 0; i < int(v.N); i++ { - v.Data[i] = xgb.Get16(buf[b:]) - b += 2 + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 } b = xgb.Pad(b) return v } -// Write request to wire for GetPixelMapusv -// getPixelMapusvRequest writes a GetPixelMapusv request to a byte slice. -func getPixelMapusvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { - size := 12 +// 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] = 127 // request opcode + buf[b] = 164 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6124,50 +6570,56 @@ func getPixelMapusvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byt xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Map) + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) b += 4 return buf } -// GetPolygonStippleCookie is a cookie used only for GetPolygonStipple requests. -type GetPolygonStippleCookie struct { +// GetSeparableFilterCookie is a cookie used only for GetSeparableFilter requests. +type GetSeparableFilterCookie struct { *xgb.Cookie } -// GetPolygonStipple sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPolygonStippleCookie.Reply() -func GetPolygonStipple(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { +// 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 'GetPolygonStipple' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) - return GetPolygonStippleCookie{cookie} + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} } -// GetPolygonStippleUnchecked sends an unchecked request. +// GetSeparableFilterUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPolygonStippleUnchecked(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { +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 'GetPolygonStipple' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) - return GetPolygonStippleCookie{cookie} + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} } -// GetPolygonStippleReply represents the data returned from a GetPolygonStipple request. -type GetPolygonStippleReply struct { +// 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: 24 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + // 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 GetPolygonStipple request. -func (cook GetPolygonStippleCookie) Reply() (*GetPolygonStippleReply, error) { +// 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 @@ -6175,12 +6627,12 @@ func (cook GetPolygonStippleCookie) Reply() (*GetPolygonStippleReply, error) { if buf == nil { return nil, nil } - return getPolygonStippleReply(buf), nil + return getSeparableFilterReply(buf), nil } -// getPolygonStippleReply reads a byte slice into a GetPolygonStippleReply value. -func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { - v := new(GetPolygonStippleReply) +// 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 @@ -6191,26 +6643,34 @@ func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 24 // padding + b += 8 // padding - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) + 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 GetPolygonStipple -// getPolygonStippleRequest writes a GetPolygonStipple request to a byte slice. -func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) []byte { - size := 12 +// 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] = 128 // request opcode + buf[b] = 153 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6219,7 +6679,16 @@ func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - if LsbFirst { + 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 @@ -6897,282 +7366,45 @@ func getTexGenivRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname // GetTexImageCookie is a cookie used only for GetTexImage requests. type GetTexImageCookie struct { *xgb.Cookie -} - -// GetTexImage sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetTexImageCookie.Reply() -func GetTexImage(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexImage' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) - return GetTexImageCookie{cookie} -} - -// GetTexImageUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetTexImageUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexImage' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) - return GetTexImageCookie{cookie} -} - -// GetTexImageReply represents the data returned from a GetTexImage request. -type GetTexImageReply 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 - Depth int32 - // padding: 4 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) -} - -// Reply blocks and returns the reply data for a GetTexImage request. -func (cook GetTexImageCookie) Reply() (*GetTexImageReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getTexImageReply(buf), nil -} - -// getTexImageReply reads a byte slice into a GetTexImageReply value. -func getTexImageReply(buf []byte) *GetTexImageReply { - v := new(GetTexImageReply) - 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 - - v.Depth = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 4 // 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 GetTexImage -// getTexImageRequest writes a GetTexImage request to a byte slice. -func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 135 // 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:], uint32(Level)) - 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 -} - -// GetTexParameterfvCookie is a cookie used only for GetTexParameterfv requests. -type GetTexParameterfvCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexParameterfv' 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} -} - -// GetTexParameterfvUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexParameterfv' 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} -} - -// 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 - // 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 GetTexParameterfv request. -func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getTexParameterfvReply(buf), nil -} - -// 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 - - 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 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] = 136 // 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 -} - -// GetTexParameterivCookie is a cookie used only for GetTexParameteriv requests. -type GetTexParameterivCookie 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 { +} + +// GetTexImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexImageCookie.Reply() +func GetTexImage(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { 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 'GetTexImage' 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(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) + return GetTexImageCookie{cookie} } -// GetTexParameterivUnchecked sends an unchecked request. +// GetTexImageUnchecked 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 GetTexImageUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { 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 'GetTexImage' 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(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) + return GetTexImageCookie{cookie} } -// GetTexParameterivReply represents the data returned from a GetTexParameteriv request. -type GetTexParameterivReply struct { +// GetTexImageReply represents the data returned from a GetTexImage request. +type GetTexImageReply 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 + Depth int32 // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// 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 GetTexImage request. +func (cook GetTexImageCookie) Reply() (*GetTexImageReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7180,12 +7412,12 @@ func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { if buf == nil { return nil, nil } - return getTexParameterivReply(buf), nil + return getTexImageReply(buf), nil } -// getTexParameterivReply reads a byte slice into a GetTexParameterivReply value. -func getTexParameterivReply(buf []byte) *GetTexParameterivReply { - v := new(GetTexParameterivReply) +// getTexImageReply reads a byte slice into a GetTexImageReply value. +func getTexImageReply(buf []byte) *GetTexImageReply { + v := new(GetTexImageReply) b := 1 // skip reply determinant b += 1 // padding @@ -7196,37 +7428,37 @@ func getTexParameterivReply(buf []byte) *GetTexParameterivReply { 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 = int32(xgb.Get32(buf[b:])) + v.Height = int32(xgb.Get32(buf[b:])) b += 4 - b += 12 // padding + v.Depth = int32(xgb.Get32(buf[b:])) + 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 - } - b = xgb.Pad(b) + b += 4 // 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 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 GetTexImage +// getTexImageRequest writes a GetTexImage request to a byte slice. +func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 28 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 137 // request opcode + buf[b] = 135 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7238,9 +7470,22 @@ func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, xgb.Put32(buf[b:], Target) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], uint32(Level)) + 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 } @@ -7474,191 +7719,47 @@ func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target ui return buf } -// IsListCookie is a cookie used only for IsList requests. -type IsListCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsList' 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} -} - -// IsListUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsList' 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} -} - -// 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 - RetVal Bool32 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return isListReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = Bool32(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for 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)) - b += 4 - - xgb.Put32(buf[b:], List) - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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) - - buf[b] = c.Extensions["GLX"] - b += 1 - - 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(ContextTag)) - b += 4 - - return buf -} - -// AreTexturesResidentCookie is a cookie used only for AreTexturesResident requests. -type AreTexturesResidentCookie struct { +// GetTexParameterfvCookie is a cookie used only for GetTexParameterfv requests. +type GetTexParameterfvCookie 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 { +// 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 'AreTexturesResident' 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(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) - return AreTexturesResidentCookie{cookie} + c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} } -// AreTexturesResidentUnchecked 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 AreTexturesResidentUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { +func GetTexParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { 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 'GetTexParameterfv' 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(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} } -// AreTexturesResidentReply represents the data returned from a AreTexturesResident request. -type AreTexturesResidentReply 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 - RetVal Bool32 - // padding: 20 bytes - Data []bool // size: xgb.Pad(((int(Length) * 4) * 1)) + // 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 AreTexturesResident request. -func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, 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 @@ -7666,12 +7767,12 @@ func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) if buf == nil { return nil, nil } - return areTexturesResidentReply(buf), nil + return getTexParameterfvReply(buf), nil } -// areTexturesResidentReply reads a byte slice into a AreTexturesResidentReply value. -func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { - v := new(AreTexturesResidentReply) +// 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 @@ -7682,36 +7783,37 @@ 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 // padding + + v.N = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 - 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 += 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 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)))) +// 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] = 143 // request opcode + buf[b] = 136 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7720,62 +7822,110 @@ func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Tex xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], Target) b += 4 - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Textures[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], Pname) + b += 4 return buf } -// DeleteTexturesCookie is a cookie used only for DeleteTextures requests. -type DeleteTexturesCookie struct { +// GetTexParameterivCookie is a cookie used only for GetTexParameteriv requests. +type GetTexParameterivCookie 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 { +// 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 'DeleteTextures' 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, false) - c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) - return DeleteTexturesCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{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 { +// GetTexParameterivUnchecked 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 { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteTextures' 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, false) - c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) - return DeleteTexturesCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{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 DeleteTexturesCookie) Check() error { - return cook.Cookie.Check() +// 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 + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) } -// 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)))) +// 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 + } + if buf == nil { + return nil, nil + } + return getTexParameterivReply(buf), nil +} + +// 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 + + 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 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] = 144 // request opcode + buf[b] = 137 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7784,56 +7934,55 @@ func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], Target) b += 4 - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Textures[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], Pname) + b += 4 return buf } -// GenTexturesCookie is a cookie used only for GenTextures requests. -type GenTexturesCookie struct { +// GetVisualConfigsCookie is a cookie used only for GetVisualConfigs requests. +type GetVisualConfigsCookie 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 { +// 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 'GenTextures' 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(genTexturesRequest(c, ContextTag, N), cookie) - return GenTexturesCookie{cookie} + c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} } -// GenTexturesUnchecked 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 GenTexturesUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { +func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { 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 'GetVisualConfigs' 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(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} } -// GenTexturesReply represents the data returned from a GenTextures request. -type GenTexturesReply 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 - // padding: 24 bytes - Data []uint32 // size: xgb.Pad((int(Length) * 4)) + NumVisuals uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) } -// 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 GetVisualConfigs request. +func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7841,12 +7990,12 @@ func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { if buf == nil { return nil, nil } - return genTexturesReply(buf), nil + return getVisualConfigsReply(buf), nil } -// genTexturesReply reads a byte slice into a GenTexturesReply value. -func genTexturesReply(buf []byte) *GenTexturesReply { - v := new(GenTexturesReply) +// 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 @@ -7857,11 +8006,17 @@ func genTexturesReply(buf []byte) *GenTexturesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 24 // padding + v.NumVisuals = xgb.Get32(buf[b:]) + b += 4 - v.Data = make([]uint32, v.Length) + v.NumProperties = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.PropertyList = make([]uint32, v.Length) for i := 0; i < int(v.Length); i++ { - v.Data[i] = xgb.Get32(buf[b:]) + v.PropertyList[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) @@ -7869,68 +8024,66 @@ func genTexturesReply(buf []byte) *GenTexturesReply { 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 { - size := 12 +// 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 145 // 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)) - b += 4 - - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], Screen) b += 4 return buf } -// IsTextureCookie is a cookie used only for IsTexture requests. -type IsTextureCookie struct { +// IsDirectCookie is a cookie used only for IsDirect requests. +type IsDirectCookie 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 { +// 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 'IsTexture' 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(isTextureRequest(c, ContextTag, Texture), cookie) - return IsTextureCookie{cookie} + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} } -// IsTextureUnchecked 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 IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { +func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { 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 'IsDirect' 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(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} } -// IsTextureReply represents the data returned from a IsTexture request. -type IsTextureReply 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 + IsDirect bool + // padding: 23 bytes } -// 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 IsDirect request. +func (cook IsDirectCookie) Reply() (*IsDirectReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7938,12 +8091,12 @@ func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { if buf == nil { return nil, nil } - return isTextureReply(buf), nil + return isDirectReply(buf), nil } -// isTextureReply reads a byte slice into a IsTextureReply value. -func isTextureReply(buf []byte) *IsTextureReply { - v := new(IsTextureReply) +// 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 @@ -7954,77 +8107,77 @@ func isTextureReply(buf []byte) *IsTextureReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.RetVal = Bool32(xgb.Get32(buf[b:])) - b += 4 + if buf[b] == 1 { + v.IsDirect = true + } else { + v.IsDirect = false + } + b += 1 + + b += 23 // padding 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 { - size := 12 +// 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] = 146 // 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:], Texture) + xgb.Put32(buf[b:], uint32(Context)) b += 4 return buf } -// GetColorTableCookie is a cookie used only for GetColorTable requests. -type GetColorTableCookie struct { +// IsListCookie is a cookie used only for IsList requests. +type IsListCookie 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 { +// 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 'GetColorTable' 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(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetColorTableCookie{cookie} + c.NewRequest(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} } -// GetColorTableUnchecked 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 GetColorTableUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { +func IsListUnchecked(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { 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 'IsList' 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(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} } -// GetColorTableReply represents the data returned from a GetColorTable request. -type GetColorTableReply 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: 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 IsList request. +func (cook IsListCookie) Reply() (*IsListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8032,12 +8185,12 @@ func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { if buf == nil { return nil, nil } - return getColorTableReply(buf), nil + return isListReply(buf), nil } -// getColorTableReply reads a byte slice into a GetColorTableReply value. -func getColorTableReply(buf []byte) *GetColorTableReply { - v := new(GetColorTableReply) +// 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 @@ -8048,31 +8201,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 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] = 147 // request opcode + buf[b] = 141 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8081,66 +8226,49 @@ 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:], List) 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 { +// IsQueryARBCookie is a cookie used only for IsQueryARB requests. +type IsQueryARBCookie 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 { +// 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 'GetColorTableParameterfv' 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(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetColorTableParameterfvCookie{cookie} + c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} } -// GetColorTableParameterfvUnchecked 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 GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { +func IsQueryARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { 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 'IsQueryARB' 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(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} } -// GetColorTableParameterfvReply represents the data returned from a GetColorTableParameterfv request. -type GetColorTableParameterfvReply 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 - // padding: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) + RetVal Bool32 } -// 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 IsQueryARB request. +func (cook IsQueryARBCookie) Reply() (*IsQueryARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8148,12 +8276,12 @@ func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvRep if buf == nil { return nil, nil } - return getColorTableParameterfvReply(buf), nil + return isQueryARBReply(buf), nil } -// getColorTableParameterfvReply reads a byte slice into a GetColorTableParameterfvReply value. -func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { - v := new(GetColorTableParameterfvReply) +// 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 @@ -8164,37 +8292,23 @@ 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.RetVal = Bool32(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 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 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 148 // request opcode + buf[b] = 163 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8203,56 +8317,49 @@ func getColorTableParameterfvRequest(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:], Pname) + xgb.Put32(buf[b:], Id) b += 4 return buf } -// GetColorTableParameterivCookie is a cookie used only for GetColorTableParameteriv requests. -type GetColorTableParameterivCookie struct { +// IsTextureCookie is a cookie used only for IsTexture requests. +type IsTextureCookie 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 { +// 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 'GetColorTableParameteriv' 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(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetColorTableParameterivCookie{cookie} + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} } -// GetColorTableParameterivUnchecked 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 GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { +func IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { 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 'IsTexture' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} } -// GetColorTableParameterivReply represents the data returned from a GetColorTableParameteriv request. -type GetColorTableParameterivReply 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: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) + RetVal Bool32 } -// 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 IsTexture request. +func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8260,12 +8367,12 @@ func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivRep if buf == nil { return nil, nil } - return getColorTableParameterivReply(buf), nil + return isTextureReply(buf), nil } -// getColorTableParameterivReply reads a byte slice into a GetColorTableParameterivReply value. -func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { - v := new(GetColorTableParameterivReply) +// 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 @@ -8276,37 +8383,23 @@ 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.RetVal = Bool32(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 GetColorTableParameteriv -// getColorTableParameterivRequest writes a GetColorTableParameteriv request to a byte slice. -func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// 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] = 149 // request opcode + buf[b] = 146 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8315,56 +8408,50 @@ func getColorTableParameterivRequest(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:], Pname) + xgb.Put32(buf[b:], Texture) b += 4 return buf } -// GetConvolutionFilterCookie is a cookie used only for GetConvolutionFilter requests. -type GetConvolutionFilterCookie struct { +// MakeContextCurrentCookie is a cookie used only for MakeContextCurrent requests. +type MakeContextCurrentCookie 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 { +// 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 'GetConvolutionFilter' 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(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetConvolutionFilterCookie{cookie} + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} } -// GetConvolutionFilterUnchecked 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 GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { +func MakeContextCurrentUnchecked(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { 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 'MakeContextCurrent' 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} + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} } -// GetConvolutionFilterReply represents the data returned from a GetConvolutionFilter request. -type GetConvolutionFilterReply 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: 8 bytes - Width int32 - Height int32 - // padding: 8 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + ContextTag ContextTag + // padding: 20 bytes } -// Reply blocks and returns the reply data for a GetConvolutionFilter request. -func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, 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 @@ -8372,12 +8459,12 @@ func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, erro if buf == nil { return nil, nil } - return getConvolutionFilterReply(buf), nil + return makeContextCurrentReply(buf), nil } -// getConvolutionFilterReply reads a byte slice into a GetConvolutionFilterReply value. -func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { - v := new(GetConvolutionFilterReply) +// 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 @@ -8388,102 +8475,83 @@ func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { 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:])) + v.ContextTag = ContextTag(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))) + b += 20 // padding return v } -// 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 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] = 150 // 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:], Format) + xgb.Put32(buf[b:], uint32(ReadDrawable)) 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 } -// GetConvolutionParameterfvCookie is a cookie used only for GetConvolutionParameterfv requests. -type GetConvolutionParameterfvCookie struct { +// MakeCurrentCookie is a cookie used only for MakeCurrent requests. +type MakeCurrentCookie 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 { +// 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 'GetConvolutionParameterfv' 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(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterfvCookie{cookie} + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} } -// GetConvolutionParameterfvUnchecked 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 GetConvolutionParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { +func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { 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 'MakeCurrent' 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} + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} } -// GetConvolutionParameterfvReply represents the data returned from a GetConvolutionParameterfv request. -type GetConvolutionParameterfvReply 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 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 GetConvolutionParameterfv request. -func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvReply, 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 @@ -8491,12 +8559,12 @@ func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvR if buf == nil { return nil, nil } - return getConvolutionParameterfvReply(buf), nil + return makeCurrentReply(buf), nil } -// getConvolutionParameterfvReply reads a byte slice into a GetConvolutionParameterfvReply value. -func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply { - v := new(GetConvolutionParameterfvReply) +// 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 @@ -8507,29 +8575,78 @@ func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding + v.ContextTag = ContextTag(xgb.Get32(buf[b:])) + b += 4 - v.N = xgb.Get32(buf[b:]) + b += 20 // padding + + 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 - v.Datum = Float32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Context)) b += 4 - b += 12 // padding + xgb.Put32(buf[b:], uint32(OldContextTag)) + b += 4 - v.Data = make([]Float32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) - b += 4 + 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.") } - b = xgb.Pad(b) + 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} +} - 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 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 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) @@ -8537,7 +8654,7 @@ func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 151 // request opcode + buf[b] = 101 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -8546,102 +8663,112 @@ 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:], List) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], Mode) b += 4 return buf } -// GetConvolutionParameterivCookie is a cookie used only for GetConvolutionParameteriv requests. -type GetConvolutionParameterivCookie struct { +// PixelStorefCookie is a cookie used only for PixelStoref requests. +type PixelStorefCookie 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 { +// 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 { 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 'PixelStoref' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{cookie} } -// GetConvolutionParameterivUnchecked 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 { +// 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 'GetConvolutionParameteriv' 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(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterivCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{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)) +// Check returns an error if one occurred 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() } -// 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 - } - return getConvolutionParameterivReply(buf), nil -} +// 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) -// getConvolutionParameterivReply reads a byte slice into a GetConvolutionParameterivReply value. -func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { - v := new(GetConvolutionParameterivReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 109 // 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:]) + xgb.Put32(buf[b:], Pname) b += 4 - v.Datum = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Datum)) b += 4 - b += 12 // padding + return buf +} - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 +// PixelStoreiCookie is a cookie used only for PixelStorei requests. +type PixelStoreiCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'PixelStorei' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} +} - return v +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} } -// 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 { +// Check returns an error if one occurred 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 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,50 @@ 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 { - 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. +// Render 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 { +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(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)) + cookie := c.NewCookie(false, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} } -// 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 +// 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.") } - return getMinmaxParameterfvReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} } -// 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 +// Check returns an error if one occurred 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() } -// 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 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 158 // request opcode + buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9350,110 +9366,56 @@ 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.Put32(buf[b:], Pname) - b += 4 + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) return buf } -// GetMinmaxParameterivCookie is a cookie used only for GetMinmaxParameteriv requests. -type GetMinmaxParameterivCookie struct { +// RenderLargeCookie is a cookie used only for RenderLarge requests. +type RenderLargeCookie 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. +// RenderLarge 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 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 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'RenderLarge' 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)) + cookie := c.NewCookie(false, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} } -// 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 +// 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.") } - return getMinmaxParameterivReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} } -// 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 +// Check returns an error if one occurred 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 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 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] = 159 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9462,55 +9424,62 @@ 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.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 } -// GetCompressedTexImageARBCookie is a cookie used only for GetCompressedTexImageARB requests. -type GetCompressedTexImageARBCookie struct { +// RenderModeCookie is a cookie used only for RenderMode requests. +type RenderModeCookie 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 { +// 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 'GetCompressedTexImageARB' 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(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) - return GetCompressedTexImageARBCookie{cookie} + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} } -// GetCompressedTexImageARBUnchecked 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 GetCompressedTexImageARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { +func RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { 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 'RenderMode' 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} + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} } -// GetCompressedTexImageARBReply represents the data returned from a GetCompressedTexImageARB request. -type GetCompressedTexImageARBReply 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: 8 bytes - Size int32 + RetVal uint32 + N uint32 + NewMode uint32 // padding: 12 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + Data []uint32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetCompressedTexImageARB request. -func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBReply, 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 @@ -9518,12 +9487,12 @@ func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBRep if buf == nil { return nil, nil } - return getCompressedTexImageARBReply(buf), nil + return renderModeReply(buf), nil } -// getCompressedTexImageARBReply reads a byte slice into a GetCompressedTexImageARBReply value. -func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { - v := new(GetCompressedTexImageARBReply) +// 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 @@ -9534,31 +9503,38 @@ func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 8 // padding + v.RetVal = xgb.Get32(buf[b:]) + b += 4 - v.Size = int32(xgb.Get32(buf[b:])) + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.NewMode = 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))) + 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 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 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] = 160 // request opcode + buf[b] = 107 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9567,59 +9543,56 @@ 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:], Mode) b += 4 return buf } -// DeleteQueriesARBCookie is a cookie used only for DeleteQueriesARB requests. -type DeleteQueriesARBCookie struct { +// SelectBufferCookie is a cookie used only for SelectBuffer requests. +type SelectBufferCookie struct { *xgb.Cookie } -// DeleteQueriesARB 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 DeleteQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { +func SelectBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { 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 'SelectBuffer' 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(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{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 { +// 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 'DeleteQueriesARB' 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(true, false) - c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) - return DeleteQueriesARBCookie{cookie} + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{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 SelectBufferCookie) 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 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] = 161 // request opcode + buf[b] = 106 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -9628,185 +9601,206 @@ func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids [] xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], uint32(N)) + xgb.Put32(buf[b:], uint32(Size)) b += 4 - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Ids[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// GenQueriesARBCookie is a cookie used only for GenQueriesARB requests. -type GenQueriesARBCookie struct { +// SetClientInfo2ARBCookie is a cookie used only for SetClientInfo2ARB requests. +type SetClientInfo2ARBCookie 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 { +// 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 { 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 'SetClientInfo2ARB' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{cookie} } -// 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 { +// 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 'GenQueriesARB' 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, true) - c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) - return GenQueriesARBCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{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)) +// Check returns an error if one occurred 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() } -// 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 -} +// 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) -// genQueriesARBReply reads a byte slice into a GenQueriesARBReply value. -func genQueriesARBReply(buf []byte) *GenQueriesARBReply { - v := new(GenQueriesARBReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["GLX"] + b += 1 - b += 1 // padding + buf[b] = 35 // 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:], MajorVersion) b += 4 - b += 24 // padding + 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) * 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 +} + +// 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} +} - v.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = xgb.Get32(buf[b:]) - b += 4 +// 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.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{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 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.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{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 { + 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(true, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{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 VendorPrivateCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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,231 +41,258 @@ func init() { xgb.NewExtErrorFuncs["RANDR"] = 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' +// BadBadCrtc is the error number for a BadBadCrtc. +const BadBadCrtc = 1 -// Skipping definition for base type 'Bool' +type BadCrtcError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Float' +// 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 'Card8' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Int16' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Int32' + return v +} -// Skipping definition for base type 'Void' +// 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 'Byte' +// 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 'Int8' +// Error returns a rudimentary string representation of the BadBadCrtc error. -const ( - RotationRotate0 = 1 - RotationRotate90 = 2 - RotationRotate180 = 4 - RotationRotate270 = 8 - RotationReflectX = 16 - RotationReflectY = 32 -) +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, ", ") + "}" +} -const ( - SetConfigSuccess = 0 - SetConfigInvalidConfigTime = 1 - SetConfigInvalidTime = 2 - SetConfigFailed = 3 -) +func init() { + xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew +} -const ( - NotifyMaskScreenChange = 1 - NotifyMaskCrtcChange = 2 - NotifyMaskOutputChange = 4 - NotifyMaskOutputProperty = 8 -) +// BadBadMode is the error number for a BadBadMode. +const BadBadMode = 2 -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 BadModeError struct { + Sequence uint16 + NiceName string +} -const ( - ConnectionConnected = 0 - ConnectionDisconnected = 1 - ConnectionUnknown = 2 -) +// 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 ( - NotifyCrtcChange = 0 - NotifyOutputChange = 1 - NotifyOutputProperty = 2 -) + b := 1 // skip error determinant + b += 1 // don't read error number -type Mode uint32 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -func NewModeId(c *xgb.Conn) (Mode, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Mode(id), nil + return v } -type Crtc uint32 +// SequenceId returns the sequence id attached to the BadBadMode error. +// This is mostly used internally. +func (err BadModeError) SequenceId() uint16 { + return err.Sequence +} -func NewCrtcId(c *xgb.Conn) (Crtc, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Crtc(id), nil +// 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 } -type Output uint32 +// Error returns a rudimentary string representation of the BadBadMode error. -func NewOutputId(c *xgb.Conn) (Output, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Output(id), nil +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, ", ") + "}" } -type ScreenSize struct { - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 +func init() { + xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew } -// ScreenSizeRead reads a byte slice into a ScreenSize value. -func ScreenSizeRead(buf []byte, v *ScreenSize) int { - b := 0 +// BadBadOutput is the error number for a BadBadOutput. +const BadBadOutput = 0 - v.Width = xgb.Get16(buf[b:]) - b += 2 +type BadOutputError struct { + Sequence uint16 + NiceName string +} - v.Height = xgb.Get16(buf[b:]) - b += 2 +// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. +func BadOutputErrorNew(buf []byte) xgb.Error { + v := BadOutputError{} + v.NiceName = "BadOutput" - v.Mwidth = xgb.Get16(buf[b:]) - b += 2 + b := 1 // skip error determinant + b += 1 // don't read error number - v.Mheight = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - return b + return v } -// 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) +// SequenceId returns the sequence id attached to the BadBadOutput error. +// This is mostly used internally. +func (err BadOutputError) SequenceId() uint16 { + return err.Sequence } -// Bytes writes a ScreenSize value to a byte slice. -func (v ScreenSize) Bytes() []byte { - buf := make([]byte, 8) - b := 0 +// 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 +} - xgb.Put16(buf[b:], v.Width) - b += 2 +// Error returns a rudimentary string representation of the BadBadOutput error. - xgb.Put16(buf[b:], v.Height) - b += 2 +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, ", ") + "}" +} - xgb.Put16(buf[b:], v.Mwidth) - b += 2 +func init() { + xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew +} - xgb.Put16(buf[b:], v.Mheight) - b += 2 +const ( + ConnectionConnected = 0 + ConnectionDisconnected = 1 + ConnectionUnknown = 2 +) - return buf -} +type Crtc uint32 -// 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)) +func NewCrtcId(c *xgb.Conn) (Crtc, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return b + return Crtc(id), nil } -type RefreshRates struct { - NRates uint16 - Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) -} +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 +} + +// CrtcChangeRead reads a byte slice into a CrtcChange value. +func CrtcChangeRead(buf []byte, v *CrtcChange) int { + b := 0 + + 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 + + b += 2 // padding -// RefreshRatesRead reads a byte slice into a RefreshRates value. -func RefreshRatesRead(buf []byte, v *RefreshRates) int { - b := 0 + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - v.NRates = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) 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) + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 return b } -// RefreshRatesReadList reads a byte slice into a list of RefreshRates values. -func RefreshRatesReadList(buf []byte, dest []RefreshRates) 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] = RefreshRates{} - b += RefreshRatesRead(buf[b:], &dest[i]) + dest[i] = CrtcChange{} + b += CrtcChangeRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a RefreshRates value to a byte slice. -func (v RefreshRates) Bytes() []byte { - buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) +// 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.NRates) + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Mode)) + b += 4 + + xgb.Put16(buf[b:], v.Rotation) b += 2 - for i := 0; i < int(v.NRates); i++ { - xgb.Put16(buf[b:], v.Rates[i]) - b += 2 - } - b = xgb.Pad(b) + b += 2 // padding + + 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 } -// 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 +} + +// 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 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.SubCode + b += 1 + + b += 2 // skip sequence number + + { + unionBytes := v.U.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + + 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, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew +} + +const ( + NotifyCrtcChange = 0 + NotifyOutputChange = 1 + NotifyOutputProperty = 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 +} + +// 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 +} + +// 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 } -// CrtcChangeRead reads a byte slice into a CrtcChange value. -func CrtcChangeRead(buf []byte, v *CrtcChange) 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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + { + structBytes := Op.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - v.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 + // Create the Union type + v := NotifyDataUnion{} - v.Crtc = Crtc(xgb.Get32(buf[b:])) - b += 4 + // Now copy buf into all fields - v.Mode = Mode(xgb.Get32(buf[b:])) - b += 4 + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) - v.Rotation = xgb.Get16(buf[b:]) - 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) - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + return v +} - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 +// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. +func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { + var b int - v.Width = xgb.Get16(buf[b:]) - b += 2 + b = 0 // re-read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) - v.Height = xgb.Get16(buf[b:]) - b += 2 + b = 0 // re-read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) - return b + b = 0 // re-read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return 28 } -// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. -func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { +// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values. +func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = CrtcChange{} - b += CrtcChangeRead(buf[b:], &dest[i]) + dest[i] = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a CrtcChange value to a byte slice. -func (v CrtcChange) Bytes() []byte { +// 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 - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Crtc)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Mode)) - b += 4 - - xgb.Put16(buf[b:], v.Rotation) - b += 2 - - b += 2 // padding - - 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 - + { + structBytes := v.Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// CrtcChangeListBytes writes a list of CrtcChange values to a byte slice. -func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { +// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. +func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { b := 0 - var structBytes []byte + var unionBytes []byte for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + 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 -} - -// 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 -} - -// NotifyDataUnionOpNew constructs a new NotifyDataUnion union type with the Op field. -func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Op.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)) } -// 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) +// RefreshRatesRead reads a byte slice into a RefreshRates value. +func RefreshRatesRead(buf []byte, v *RefreshRates) int { + b := 0 - b = 0 // re-read the same bytes - v.Oc = OutputChange{} - b += OutputChangeRead(buf[b:], &v.Oc) + v.NRates = xgb.Get16(buf[b:]) + b += 2 - b = 0 // re-read the same bytes - v.Op = OutputProperty{} - b += OutputPropertyRead(buf[b:], &v.Op) + 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 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,288 +1114,141 @@ 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 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.SubCode - b += 1 - - b += 2 // skip sequence number - - { - unionBytes := v.U.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) + for i := 0; i < len(dest); i++ { + dest[i] = ScreenSize{} + b += ScreenSizeRead(buf[b:], &dest[i]) } - - 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, 2) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode)) - return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew -} - -// BadBadOutput is the error number for a BadBadOutput. -const BadBadOutput = 0 - -type BadOutputError struct { - Sequence uint16 - NiceName string + return xgb.Pad(b) } -// 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 +// Bytes writes a ScreenSize value to a byte slice. +func (v ScreenSize) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Width) 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 -} - -// BadBadCrtc is the error number for a BadBadCrtc. -const BadBadCrtc = 1 - -type BadCrtcError struct { - Sequence uint16 - NiceName string -} - -// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice. -func BadCrtcErrorNew(buf []byte) xgb.Error { - v := BadCrtcError{} - v.NiceName = "BadCrtc" - - b := 1 // skip error determinant - b += 1 // don't read error number + xgb.Put16(buf[b:], v.Height) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Mwidth) b += 2 - return v -} + xgb.Put16(buf[b:], v.Mheight) + b += 2 -// SequenceId returns the sequence id attached to the BadBadCrtc error. -// This is mostly used internally. -func (err BadCrtcError) SequenceId() uint16 { - return err.Sequence + return buf } -// 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 +// 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 } -// 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, ", ") + "}" -} +const ( + SetConfigSuccess = 0 + SetConfigInvalidConfigTime = 1 + SetConfigInvalidTime = 2 + SetConfigFailed = 3 +) -func init() { - xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew -} +// Skipping definition for base type 'Bool' -// BadBadMode is the error number for a BadBadMode. -const BadBadMode = 2 +// Skipping definition for base type 'Byte' -type BadModeError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Card8' -// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. -func BadModeErrorNew(buf []byte) xgb.Error { - v := BadModeError{} - v.NiceName = "BadMode" +// 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 BadBadMode error. -// This is mostly used internally. -func (err BadModeError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Int16' -// 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 -} +// Skipping definition for base type 'Int32' -// Error returns a rudimentary string representation of the BadBadMode error. +// Skipping definition for base type 'Int8' -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, ", ") + "}" -} +// Skipping definition for base type 'Card16' -func init() { - xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew -} +// Skipping definition for base type 'Card32' -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// AddOutputModeCookie is a cookie used only for AddOutputMode requests. +type AddOutputModeCookie 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["RANDR"]; !ok { - panic("Cannot issue request 'QueryVersion' 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} -} - -// QueryVersionUnchecked sends an unchecked request. +// AddOutputMode 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 AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { 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 'AddOutputMode' 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} -} - -// 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(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{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 +// 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.") } - return queryVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{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 AddOutputModeCookie) 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, MajorVersion uint32, MinorVersion uint32) []byte { +// 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) @@ -1296,249 +1256,214 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 0 // 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:], MajorVersion) + xgb.Put32(buf[b:], uint32(Output)) b += 4 - xgb.Put32(buf[b:], MinorVersion) + xgb.Put32(buf[b:], uint32(Mode)) b += 4 return buf } -// SetScreenConfigCookie is a cookie used only for SetScreenConfig requests. -type SetScreenConfigCookie struct { +// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. +type ChangeOutputPropertyCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenConfig' 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} -} - -// SetScreenConfigUnchecked sends an unchecked request. +// ChangeOutputProperty 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 { +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 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeOutputProperty' 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} -} - -// 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 + cookie := c.NewCookie(false, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} } -// 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 +// 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.") } - return setScreenConfigReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} } -// 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 +// Check returns an error if one occurred 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() } -// 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 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) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 2 // 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(Output)) b += 4 - xgb.Put32(buf[b:], uint32(Timestamp)) + xgb.Put32(buf[b:], uint32(Property)) b += 4 - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + xgb.Put32(buf[b:], uint32(Type)) b += 4 - xgb.Put16(buf[b:], SizeID) - b += 2 - - xgb.Put16(buf[b:], Rotation) - b += 2 + buf[b] = Format + b += 1 - xgb.Put16(buf[b:], Rate) - b += 2 + 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 } -// SelectInputCookie is a cookie used only for SelectInput requests. -type SelectInputCookie struct { +// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. +type ConfigureOutputPropertyCookie struct { *xgb.Cookie } -// SelectInput sends an unchecked request. +// ConfigureOutputProperty 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 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 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ConfigureOutputProperty' 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(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{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 { +// 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 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ConfigureOutputProperty' 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(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 SelectInputCookie) Check() error { +func (cook ConfigureOutputPropertyCookie) 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 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] = 4 // 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)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 - xgb.Put16(buf[b:], Enable) - b += 2 + 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 } -// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. -type GetScreenInfoCookie struct { +// CreateModeCookie is a cookie used only for CreateMode requests. +type CreateModeCookie 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 { +// 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 'GetScreenInfo' 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(getScreenInfoRequest(c, Window), cookie) - return GetScreenInfoCookie{cookie} + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} } -// GetScreenInfoUnchecked 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 GetScreenInfoUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { +func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { 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 'CreateMode' 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(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{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) +// 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 + Mode Mode + // padding: 20 bytes } -// 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 CreateMode request. +func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1546,16 +1471,15 @@ func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { if buf == nil { return nil, nil } - return getScreenInfoReply(buf), nil + return createModeReply(buf), nil } -// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. -func getScreenInfoReply(buf []byte) *GetScreenInfoReply { - v := new(GetScreenInfoReply) +// createModeReply reads a byte slice into a CreateModeReply value. +func createModeReply(buf []byte) *CreateModeReply { + v := new(CreateModeReply) b := 1 // skip reply determinant - v.Rotations = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -1563,52 +1487,25 @@ 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:])) + v.Mode = Mode(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:]) - 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) + b += 20 // padding 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 { - size := 8 +// 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] = 5 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1617,226 +1514,230 @@ func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) 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 } -// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. -type GetScreenSizeRangeCookie struct { +// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. +type DeleteOutputModeCookie 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 { +// 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 'GetScreenSizeRange' 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(getScreenSizeRangeRequest(c, Window), cookie) - return GetScreenSizeRangeCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} } -// GetScreenSizeRangeUnchecked 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 { +// 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 'GetScreenSizeRange' 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(getScreenSizeRangeRequest(c, Window), cookie) - return GetScreenSizeRangeCookie{cookie} -} - -// 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 + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} } -// 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 - } - if buf == nil { - return nil, nil - } - return getScreenSizeRangeReply(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 DeleteOutputModeCookie) Check() error { + return cook.Cookie.Check() } -// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value. -func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { - v := new(GetScreenSizeRangeReply) - b := 1 // skip reply determinant +// 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) - b += 1 // padding + buf[b] = c.Extensions["RANDR"] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = 19 // 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(Output)) b += 4 - v.MinWidth = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 - v.MinHeight = xgb.Get16(buf[b:]) - b += 2 + return buf +} - v.MaxWidth = xgb.Get16(buf[b:]) - b += 2 +// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. +type DeleteOutputPropertyCookie struct { + *xgb.Cookie +} - v.MaxHeight = 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 += 16 // 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 GetScreenSizeRange -// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. -func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// 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] = 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(Window)) + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) b += 4 return buf } -// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. -type SetScreenSizeCookie struct { +// DestroyModeCookie is a cookie used only for DestroyMode requests. +type DestroyModeCookie struct { *xgb.Cookie } -// SetScreenSize 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 SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { +func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { 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 'DestroyMode' 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} + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{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 { +// 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 'SetScreenSize' 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(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) - return SetScreenSizeCookie{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 SetScreenSizeCookie) Check() error { +func (cook DestroyModeCookie) Check() error { return cook.Cookie.Check() } -// 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 +// 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] = 7 // 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)) - 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) + xgb.Put32(buf[b:], uint32(Mode)) b += 4 return buf } -// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. -type GetScreenResourcesCookie struct { +// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. +type GetCrtcGammaCookie 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 { +// 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 'GetScreenResources' 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(getScreenResourcesRequest(c, Window), cookie) - return GetScreenResourcesCookie{cookie} + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} } -// GetScreenResourcesUnchecked 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 GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { +func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { 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 'GetCrtcGamma' 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(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} } -// GetScreenResourcesReply represents the data returned from a GetScreenResources request. -type GetScreenResourcesReply struct { +// 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 - 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)) + 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 GetScreenResources request. -func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, 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 @@ -1844,12 +1745,12 @@ func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { if buf == nil { return nil, nil } - return getScreenResourcesReply(buf), nil + return getCrtcGammaReply(buf), nil } -// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. -func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { - v := new(GetScreenResourcesReply) +// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value. +func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { + v := new(GetCrtcGammaReply) b := 1 // skip reply determinant b += 1 // padding @@ -1860,53 +1761,38 @@ 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.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.NumCrtcs = xgb.Get16(buf[b:]) - b += 2 - - v.NumOutputs = xgb.Get16(buf[b:]) - b += 2 - - v.NumModes = xgb.Get16(buf[b:]) - b += 2 - - v.NamesLen = xgb.Get16(buf[b:]) + v.Size = xgb.Get16(buf[b:]) b += 2 - b += 8 // padding + b += 22 // 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 + 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.Outputs = make([]Output, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Output(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.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)) + 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 GetScreenResources -// getScreenResourcesRequest writes a GetScreenResources request to a byte slice. -func getScreenResourcesRequest(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) @@ -1914,69 +1800,56 @@ func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 8 // 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 } -// GetOutputInfoCookie is a cookie used only for GetOutputInfo requests. -type GetOutputInfoCookie struct { +// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. +type GetCrtcGammaSizeCookie struct { *xgb.Cookie } -// GetOutputInfo sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetOutputInfoCookie.Reply() -func GetOutputInfo(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { +// 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 'GetOutputInfo' 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(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) - return GetOutputInfoCookie{cookie} + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} } -// GetOutputInfoUnchecked 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 GetOutputInfoUnchecked(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { +func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputInfo' 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(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) - return GetOutputInfoCookie{cookie} + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} } -// GetOutputInfoReply represents the data returned from a GetOutputInfo request. -type GetOutputInfoReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte - Timestamp xproto.Timestamp - Crtc Crtc - MmWidth uint32 - MmHeight uint32 - Connection byte - SubpixelOrder byte - NumCrtcs uint16 - NumModes uint16 - NumPreferred uint16 - NumClones uint16 - NameLen uint16 - Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) - Modes []Mode // size: xgb.Pad((int(NumModes) * 4)) - Clones []Output // size: xgb.Pad((int(NumClones) * 4)) - Name []byte // size: xgb.Pad((int(NameLen) * 1)) +// 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 + Size uint16 + // padding: 22 bytes } -// Reply blocks and returns the reply data for a GetOutputInfo request. -func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, 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 @@ -1984,16 +1857,15 @@ func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { if buf == nil { return nil, nil } - return getOutputInfoReply(buf), nil + return getCrtcGammaSizeReply(buf), nil } -// getOutputInfoReply reads a byte slice into a GetOutputInfoReply value. -func getOutputInfoReply(buf []byte) *GetOutputInfoReply { - v := new(GetOutputInfoReply) +// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. +func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { + v := new(GetCrtcGammaSizeReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2001,131 +1873,84 @@ func getOutputInfoReply(buf []byte) *GetOutputInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Crtc = Crtc(xgb.Get32(buf[b:])) - b += 4 - - v.MmWidth = xgb.Get32(buf[b:]) - b += 4 - - v.MmHeight = xgb.Get32(buf[b:]) - b += 4 - - v.Connection = buf[b] - b += 1 - - v.SubpixelOrder = buf[b] - b += 1 - - v.NumCrtcs = xgb.Get16(buf[b:]) - b += 2 - - v.NumModes = xgb.Get16(buf[b:]) - b += 2 - - v.NumPreferred = xgb.Get16(buf[b:]) - b += 2 - - v.NumClones = xgb.Get16(buf[b:]) - b += 2 - - v.NameLen = xgb.Get16(buf[b:]) + v.Size = xgb.Get16(buf[b:]) b += 2 - 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) - - v.Modes = make([]Mode, v.NumModes) - for i := 0; i < int(v.NumModes); i++ { - v.Modes[i] = Mode(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - v.Clones = make([]Output, v.NumClones) - for i := 0; i < int(v.NumClones); i++ { - v.Clones[i] = Output(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - v.Name = make([]byte, v.NameLen) - copy(v.Name[:v.NameLen], buf[b:]) - b += xgb.Pad(int(v.NameLen)) + b += 22 // padding return v } -// Write request to wire for GetOutputInfo -// getOutputInfoRequest writes a GetOutputInfo request to a byte slice. -func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) []byte { - size := 12 +// 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) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 9 // 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. -type ListOutputPropertiesCookie struct { +// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. +type GetCrtcInfoCookie 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 { +// 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 'ListOutputProperties' 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, true) - c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) - return ListOutputPropertiesCookie{cookie} + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} } -// ListOutputPropertiesUnchecked sends an unchecked request. +// GetCrtcInfoUnchecked 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 GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { 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 'GetCrtcInfo' 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(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} } -// 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)) +// 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)) } -// 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 GetCrtcInfo request. +func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2133,15 +1958,16 @@ func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, erro if buf == nil { return nil, nil } - return listOutputPropertiesReply(buf), nil + return getCrtcInfoReply(buf), nil } -// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value. -func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { - v := new(ListOutputPropertiesReply) +// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. +func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { + v := new(GetCrtcInfoReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2149,14 +1975,46 @@ func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAtoms = xgb.Get16(buf[b:]) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - b += 22 // padding + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - v.Atoms = make([]xproto.Atom, v.NumAtoms) - for i := 0; i < int(v.NumAtoms); i++ { - v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) + 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:]) + 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) @@ -2164,69 +2022,80 @@ func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { 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 { - size := 8 +// 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] = 10 // 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(Output)) + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) b += 4 return buf } -// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests. -type QueryOutputPropertyCookie struct { +// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. +type GetCrtcTransformCookie 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 { +// 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 'QueryOutputProperty' 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(queryOutputPropertyRequest(c, Output, Property), cookie) - return QueryOutputPropertyCookie{cookie} + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} } -// QueryOutputPropertyUnchecked 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 QueryOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { +func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { 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 'GetCrtcTransform' 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(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} } -// QueryOutputPropertyReply represents the data returned from a QueryOutputProperty request. -type QueryOutputPropertyReply 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 - Pending bool - Range bool - Immutable bool - // padding: 21 bytes - ValidValues []int32 // size: xgb.Pad((int(Length) * 4)) + 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 QueryOutputProperty request. -func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, 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 @@ -2234,12 +2103,12 @@ func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) if buf == nil { return nil, nil } - return queryOutputPropertyReply(buf), nil + return getCrtcTransformReply(buf), nil } -// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value. -func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { - v := new(QueryOutputPropertyReply) +// 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 @@ -2250,32 +2119,59 @@ func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { 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.Pending = true + v.HasTransforms = true } else { - v.Pending = false + v.HasTransforms = false } b += 1 - if buf[b] == 1 { - v.Range = true - } else { - v.Range = false + 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)) } - b += 1 - if buf[b] == 1 { - v.Immutable = true - } else { - v.Immutable = false + 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 += 1 + b = xgb.Pad(b) - b += 21 // padding + { + byteString := make([]byte, v.CurrentLen) + copy(byteString[:v.CurrentLen], buf[b:]) + v.CurrentFilterName = string(byteString) + b += xgb.Pad(int(v.CurrentLen)) + } - v.ValidValues = make([]int32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.ValidValues[i] = int32(xgb.Get32(buf[b:])) + 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) @@ -2283,155 +2179,175 @@ func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { 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 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) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 11 // 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. -type ConfigureOutputPropertyCookie struct { +// GetOutputInfoCookie is a cookie used only for GetOutputInfo requests. +type GetOutputInfoCookie 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 { +// GetOutputInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOutputInfoCookie.Reply() +func GetOutputInfo(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputInfo' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{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 { +// GetOutputInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetOutputInfoUnchecked(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputInfo' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{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() +// GetOutputInfoReply represents the data returned from a GetOutputInfo request. +type GetOutputInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte + Timestamp xproto.Timestamp + Crtc Crtc + MmWidth uint32 + MmHeight uint32 + Connection byte + SubpixelOrder byte + NumCrtcs uint16 + NumModes uint16 + NumPreferred uint16 + NumClones uint16 + NameLen uint16 + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Modes []Mode // size: xgb.Pad((int(NumModes) * 4)) + Clones []Output // size: xgb.Pad((int(NumClones) * 4)) + Name []byte // size: xgb.Pad((int(NameLen) * 1)) } -// 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) +// Reply blocks and returns the reply data for a GetOutputInfo request. +func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputInfoReply(buf), nil +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// getOutputInfoReply reads a byte slice into a GetOutputInfoReply value. +func getOutputInfoReply(buf []byte) *GetOutputInfoReply { + v := new(GetOutputInfoReply) + b := 1 // skip reply determinant - buf[b] = 12 // 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 - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.MmWidth = xgb.Get32(buf[b:]) + b += 4 + + v.MmHeight = xgb.Get32(buf[b:]) + b += 4 + + v.Connection = buf[b] b += 1 - if Range { - buf[b] = 1 - } else { - buf[b] = 0 - } + v.SubpixelOrder = buf[b] b += 1 - b += 2 // padding + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 - for i := 0; i < int(len(Values)); i++ { - xgb.Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = xgb.Pad(b) + v.NumModes = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.NumPreferred = xgb.Get16(buf[b:]) + b += 2 -// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. -type ChangeOutputPropertyCookie struct { - *xgb.Cookie -} + v.NumClones = xgb.Get16(buf[b:]) + b += 2 + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + 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) -// 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.") + v.Modes = make([]Mode, v.NumModes) + for i := 0; i < int(v.NumModes); i++ { + v.Modes[i] = Mode(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(false, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{cookie} -} + b = xgb.Pad(b) -// 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.") + v.Clones = make([]Output, v.NumClones) + for i := 0; i < int(v.NumClones); i++ { + v.Clones[i] = Output(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(true, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{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 ChangeOutputPropertyCookie) Check() error { - return cook.Cookie.Check() + v.Name = make([]byte, v.NameLen) + copy(v.Name[:v.NameLen], buf[b:]) + b += xgb.Pad(int(v.NameLen)) + + return v } -// 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)))) +// Write request to wire for GetOutputInfo +// getOutputInfoRequest writes a GetOutputInfo request to a byte slice. +func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2440,82 +2356,95 @@ func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Ato 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) + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) b += 4 - copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) - b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) - return buf } -// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. -type DeleteOutputPropertyCookie struct { +// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. +type GetOutputPrimaryCookie struct { *xgb.Cookie } -// 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 { +// 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 'DeleteOutputProperty' 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, false) - c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) - return DeleteOutputPropertyCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} } -// 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 { +// GetOutputPrimaryUnchecked 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputProperty' 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, false) - c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) - return DeleteOutputPropertyCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{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 DeleteOutputPropertyCookie) Check() error { - return cook.Cookie.Check() +// 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 } -// 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 +// 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 + } + return getOutputPrimaryReply(buf), nil +} + +// 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 +} + +// 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) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 14 // 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)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf @@ -2654,44 +2583,55 @@ func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, return buf } -// CreateModeCookie is a cookie used only for CreateMode requests. -type CreateModeCookie struct { +// GetPanningCookie is a cookie used only for GetPanning requests. +type GetPanningCookie 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 { +// 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 'CreateMode' 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, true) - c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) - return CreateModeCookie{cookie} + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} } -// CreateModeUnchecked sends an unchecked request. +// GetPanningUnchecked 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 GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { 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 'GetPanning' 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(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} } -// 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 - Mode Mode - // padding: 20 bytes +// 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 CreateMode request. -func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { +// 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 @@ -2699,15 +2639,16 @@ func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { if buf == nil { return nil, nil } - return createModeReply(buf), nil + return getPanningReply(buf), nil } -// createModeReply reads a byte slice into a CreateModeReply value. -func createModeReply(buf []byte) *CreateModeReply { - v := new(CreateModeReply) +// getPanningReply reads a byte slice into a GetPanningReply value. +func getPanningReply(buf []byte) *GetPanningReply { + v := new(GetPanningReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2715,81 +2656,51 @@ 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.Left = xgb.Get16(buf[b:]) + b += 2 -// 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.Top = xgb.Get16(buf[b:]) + b += 2 - buf[b] = c.Extensions["RANDR"] - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - buf[b] = 16 // request opcode - b += 1 + v.Height = xgb.Get16(buf[b:]) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.TrackLeft = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 + v.TrackTop = xgb.Get16(buf[b:]) + b += 2 - { - structBytes := ModeInfo.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + v.TrackWidth = xgb.Get16(buf[b:]) + b += 2 - copy(buf[b:], Name[:len(Name)]) - b += xgb.Pad(int(len(Name))) + v.TrackHeight = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.BorderLeft = int16(xgb.Get16(buf[b:])) + b += 2 -// DestroyModeCookie is a cookie used only for DestroyMode requests. -type DestroyModeCookie struct { - *xgb.Cookie -} + v.BorderTop = int16(xgb.Get16(buf[b:])) + b += 2 -// 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyModeRequest(c, Mode), cookie) - return DestroyModeCookie{cookie} -} + v.BorderRight = int16(xgb.Get16(buf[b:])) + b += 2 -// 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.BorderBottom = 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 DestroyModeCookie) Check() error { - return cook.Cookie.Check() + 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 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) @@ -2797,182 +2708,193 @@ func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 17 // 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(Mode)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// AddOutputModeCookie is a cookie used only for AddOutputMode requests. -type AddOutputModeCookie struct { +// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. +type GetScreenInfoCookie 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 { +// 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 'AddOutputMode' 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, false) - c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) - return AddOutputModeCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{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 { +// GetScreenInfoUnchecked 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 { 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 'GetScreenInfo' 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(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{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() +// 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) } -// 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 GetScreenInfo request. +func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenInfoReply(buf), nil +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. +func getScreenInfoReply(buf []byte) *GetScreenInfoReply { + v := new(GetScreenInfoReply) + b := 1 // skip reply determinant - buf[b] = 18 // request opcode + v.Rotations = 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(Mode)) + v.Root = xproto.Window(xgb.Get32(buf[b:])) b += 4 - return buf -} + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. -type DeleteOutputModeCookie struct { - *xgb.Cookie -} + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) - return DeleteOutputModeCookie{cookie} -} + v.NSizes = xgb.Get16(buf[b:]) + b += 2 -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) - return DeleteOutputModeCookie{cookie} -} + v.SizeID = 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 DeleteOutputModeCookie) Check() error { - return cook.Cookie.Check() + 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 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 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] = 19 // 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(Mode)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. -type GetCrtcInfoCookie struct { +// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. +type GetScreenResourcesCookie 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 { +// 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 'GetCrtcInfo' 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(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) - return GetCrtcInfoCookie{cookie} + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} } -// GetCrtcInfoUnchecked 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 GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { +func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { 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 'GetScreenResources' 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(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{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)) +// 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 + 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 GetCrtcInfo request. -func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, 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 @@ -2980,16 +2902,15 @@ func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { if buf == nil { return nil, nil } - return getCrtcInfoReply(buf), nil + return getScreenResourcesReply(buf), nil } -// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. -func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { - v := new(GetCrtcInfoReply) +// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. +func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { + v := new(GetScreenResourcesReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3000,32 +2921,29 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { 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.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 - v.Width = xgb.Get16(buf[b:]) + v.NumCrtcs = xgb.Get16(buf[b:]) b += 2 - v.Height = xgb.Get16(buf[b:]) + v.NumOutputs = xgb.Get16(buf[b:]) b += 2 - v.Mode = Mode(xgb.Get32(buf[b:])) - b += 4 - - v.Rotation = xgb.Get16(buf[b:]) + v.NumModes = xgb.Get16(buf[b:]) b += 2 - v.Rotations = xgb.Get16(buf[b:]) + v.NamesLen = xgb.Get16(buf[b:]) b += 2 - v.NumOutputs = xgb.Get16(buf[b:]) - b += 2 + b += 8 // padding - v.NumPossibleOutputs = xgb.Get16(buf[b:]) - b += 2 + 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) v.Outputs = make([]Output, v.NumOutputs) for i := 0; i < int(v.NumOutputs); i++ { @@ -3034,79 +2952,85 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { } 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) + 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 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 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) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 20 // 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(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 { +// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. +type GetScreenResourcesCurrentCookie 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 { +// 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 'SetCrtcConfig' 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, true) - c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return SetCrtcConfigCookie{cookie} + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} } -// SetCrtcConfigUnchecked sends an unchecked request. +// GetScreenResourcesCurrentUnchecked 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 GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { 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 'GetScreenResourcesCurrent' 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(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{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 +// 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)) } -// 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 GetScreenResourcesCurrent request. +func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3114,16 +3038,15 @@ func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { if buf == nil { return nil, nil } - return setCrtcConfigReply(buf), nil + return getScreenResourcesCurrentReply(buf), nil } -// setCrtcConfigReply reads a byte slice into a SetCrtcConfigReply value. -func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { - v := new(SetCrtcConfigReply) +// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. +func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { + v := new(GetScreenResourcesCurrentReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3134,97 +3057,110 @@ func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - b += 20 // padding + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 + + 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 + } + 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) + + 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 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 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] = 21 // 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(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(Window)) 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 { +// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. +type GetScreenSizeRangeCookie 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 { +// 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 'GetCrtcGammaSize' 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(getCrtcGammaSizeRequest(c, Crtc), cookie) - return GetCrtcGammaSizeCookie{cookie} + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} } -// GetCrtcGammaSizeUnchecked 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 GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { +func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { 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 'GetScreenSizeRange' 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(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} } -// GetCrtcGammaSizeReply represents the data returned from a GetCrtcGammaSize request. -type GetCrtcGammaSizeReply struct { +// 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 - Size uint16 - // padding: 22 bytes + // padding: 1 bytes + MinWidth uint16 + MinHeight uint16 + MaxWidth uint16 + MaxHeight uint16 + // padding: 16 bytes } -// 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 GetScreenSizeRange request. +func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3232,12 +3168,12 @@ func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { if buf == nil { return nil, nil } - return getCrtcGammaSizeReply(buf), nil + return getScreenSizeRangeReply(buf), nil } -// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. -func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { - v := new(GetCrtcGammaSizeReply) +// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value. +func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { + v := new(GetScreenSizeRangeReply) b := 1 // skip reply determinant b += 1 // padding @@ -3248,17 +3184,26 @@ func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Size = xgb.Get16(buf[b:]) + v.MinWidth = xgb.Get16(buf[b:]) b += 2 - b += 22 // padding + v.MinHeight = xgb.Get16(buf[b:]) + b += 2 + + v.MaxWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MaxHeight = xgb.Get16(buf[b:]) + b += 2 + + b += 16 // padding 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 { +// 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) @@ -3266,59 +3211,57 @@ func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 22 // 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)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. -type GetCrtcGammaCookie struct { +// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. +type ListOutputPropertiesCookie 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 { +// 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 'GetCrtcGamma' 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(getCrtcGammaRequest(c, Crtc), cookie) - return GetCrtcGammaCookie{cookie} + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} } -// GetCrtcGammaUnchecked 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 GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { +func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { 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 'ListOutputProperties' 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(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} } -// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. -type GetCrtcGammaReply struct { +// 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 - Size uint16 + NumAtoms 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)) + Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4)) } -// 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 ListOutputProperties request. +func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3326,12 +3269,12 @@ func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { if buf == nil { return nil, nil } - return getCrtcGammaReply(buf), nil + return listOutputPropertiesReply(buf), nil } -// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value. -func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { - v := new(GetCrtcGammaReply) +// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value. +func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { + v := new(ListOutputPropertiesReply) b := 1 // skip reply determinant b += 1 // padding @@ -3342,38 +3285,24 @@ func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Size = xgb.Get16(buf[b:]) + v.NumAtoms = 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.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.Blue = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Blue[i] = xgb.Get16(buf[b:]) - b += 2 + 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 GetCrtcGamma -// getCrtcGammaRequest writes a GetCrtcGamma request to a byte slice. -func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { +// 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) @@ -3381,143 +3310,179 @@ func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 23 // 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)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 return buf } -// SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests. -type SetCrtcGammaCookie struct { +// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests. +type QueryOutputPropertyCookie struct { *xgb.Cookie } -// 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 { +// 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 'SetCrtcGamma' 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, false) - c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) - return SetCrtcGammaCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{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 { +// QueryOutputPropertyUnchecked 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 { 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 'QueryOutputProperty' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{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 { - return cook.Cookie.Check() +// 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)) } -// 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) +// 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 + } + if buf == nil { + return nil, nil + } + return queryOutputPropertyReply(buf), nil +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value. +func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { + v := new(QueryOutputPropertyReply) + b := 1 // skip reply determinant - buf[b] = 24 // 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(Crtc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Size) - b += 2 - - b += 2 // padding + if buf[b] == 1 { + v.Pending = true + } else { + v.Pending = false + } + b += 1 - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Red[i]) - b += 2 + if buf[b] == 1 { + v.Range = true + } else { + v.Range = false } - b = xgb.Pad(b) + b += 1 - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Green[i]) - b += 2 + if buf[b] == 1 { + v.Immutable = true + } else { + v.Immutable = false } - b = xgb.Pad(b) + b += 1 - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Blue[i]) - b += 2 + 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 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] = 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(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + return buf } -// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. -type GetScreenResourcesCurrentCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie 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 { +// 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 'GetScreenResourcesCurrent' 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(getScreenResourcesCurrentRequest(c, Window), cookie) - return GetScreenResourcesCurrentCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetScreenResourcesCurrentUnchecked 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 GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { 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 'QueryVersion' 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(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetScreenResourcesCurrentReply represents the data returned from a GetScreenResourcesCurrent request. -type GetScreenResourcesCurrentReply 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 - 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)) + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 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 QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3525,12 +3490,12 @@ func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentR if buf == nil { return nil, nil } - return getScreenResourcesCurrentReply(buf), nil + return queryVersionReply(buf), nil } -// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. -func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { - v := new(GetScreenResourcesCurrentReply) +// 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 @@ -3541,196 +3506,140 @@ func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.MajorVersion = xgb.Get32(buf[b:]) b += 4 - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.MinorVersion = xgb.Get32(buf[b:]) b += 4 - v.NumCrtcs = xgb.Get16(buf[b:]) - b += 2 - - 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 - } - 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) - - 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)) + b += 16 // padding return v } -// 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 +// 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] = 25 // 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:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) b += 4 return buf } -// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. -type SetCrtcTransformCookie struct { +// SelectInputCookie is a cookie used only for SelectInput requests. +type SelectInputCookie struct { *xgb.Cookie } -// SetCrtcTransform 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 SetCrtcTransform(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { +func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcTransform' 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(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return SetCrtcTransformCookie{cookie} + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{cookie} } -// SetCrtcTransformChecked sends a checked request. -// If an error occurs, it can be retrieved using SetCrtcTransformCookie.Check() -func SetCrtcTransformChecked(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { +// 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 'SetCrtcTransform' 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(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return SetCrtcTransformCookie{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 SetCrtcTransformCookie) Check() error { +func (cook SelectInputCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetCrtcTransform -// setCrtcTransformRequest writes a SetCrtcTransform request to a byte slice. -func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) []byte { - size := xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) +// 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] = 26 // 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 - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put16(buf[b:], FilterLen) + xgb.Put16(buf[b:], Enable) b += 2 b += 2 // padding - copy(buf[b:], FilterName[:FilterLen]) - b += xgb.Pad(int(FilterLen)) - - for i := 0; i < int(len(FilterParams)); i++ { - xgb.Put32(buf[b:], uint32(FilterParams[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. -type GetCrtcTransformCookie struct { +// SetCrtcConfigCookie is a cookie used only for SetCrtcConfig requests. +type SetCrtcConfigCookie 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 { +// 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 'GetCrtcTransform' 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(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} } -// GetCrtcTransformUnchecked 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 GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { +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 'GetCrtcTransform' 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(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{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)) +// 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 GetCrtcTransform request. -func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, 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 @@ -3738,93 +3647,123 @@ func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { if buf == nil { return nil, nil } - return getCrtcTransformReply(buf), nil + return setCrtcConfigReply(buf), nil +} + +// setCrtcConfigReply reads a byte slice into a SetCrtcConfigReply value. +func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { + v := new(SetCrtcConfigReply) + 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:])) + b += 4 + + b += 20 // padding + + return v } -// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. -func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { - v := new(GetCrtcTransformReply) - b := 1 // skip reply determinant +// 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 - b += 1 // padding + buf[b] = 21 // 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(Crtc)) 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) + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 - b += 4 // padding + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 - v.PendingLen = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(X)) b += 2 - v.PendingNparams = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(Y)) b += 2 - v.CurrentLen = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 - v.CurrentNparams = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Rotation) b += 2 - { - byteString := make([]byte, v.PendingLen) - copy(byteString[:v.PendingLen], buf[b:]) - v.PendingFilterName = string(byteString) - b += xgb.Pad(int(v.PendingLen)) - } + b += 2 // padding - v.PendingParams = make([]render.Fixed, v.PendingNparams) - for i := 0; i < int(v.PendingNparams); i++ { - v.PendingParams[i] = render.Fixed(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) - { - byteString := make([]byte, v.CurrentLen) - copy(byteString[:v.CurrentLen], buf[b:]) - v.CurrentFilterName = string(byteString) - b += xgb.Pad(int(v.CurrentLen)) + return buf +} + +// SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests. +type SetCrtcGammaCookie struct { + *xgb.Cookie +} + +// 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} +} - 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 +// 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.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{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 SetCrtcGammaCookie) 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 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] = 27 // request opcode + buf[b] = 24 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3833,141 +3772,160 @@ func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { 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 } -// GetPanningCookie is a cookie used only for GetPanning requests. -type GetPanningCookie struct { +// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. +type SetCrtcTransformCookie 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 { +// SetCrtcTransform sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetCrtcTransform(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcTransform' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{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 { +// SetCrtcTransformChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCrtcTransformCookie.Check() +func SetCrtcTransformChecked(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcTransform' 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} + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{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 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetCrtcTransformCookie) Check() error { + return cook.Cookie.Check() } -// 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 -} +// Write request to wire for SetCrtcTransform +// setCrtcTransformRequest writes a SetCrtcTransform request to a byte slice. +func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) []byte { + size := xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) + b := 0 + buf := make([]byte, size) -// getPanningReply reads a byte slice into a GetPanningReply value. -func getPanningReply(buf []byte) *GetPanningReply { - v := new(GetPanningReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["RANDR"] + b += 1 - v.Status = buf[b] + 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 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Crtc)) 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 + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - v.TrackLeft = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], FilterLen) b += 2 - v.TrackTop = xgb.Get16(buf[b:]) - b += 2 + b += 2 // padding - v.TrackWidth = xgb.Get16(buf[b:]) - b += 2 + copy(buf[b:], FilterName[:FilterLen]) + b += xgb.Pad(int(FilterLen)) - v.TrackHeight = xgb.Get16(buf[b:]) - b += 2 + for i := 0; i < int(len(FilterParams)); i++ { + xgb.Put32(buf[b:], uint32(FilterParams[i])) + b += 4 + } + b = xgb.Pad(b) - v.BorderLeft = int16(xgb.Get16(buf[b:])) - b += 2 + return buf +} - v.BorderTop = int16(xgb.Get16(buf[b:])) - b += 2 +// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. +type SetOutputPrimaryCookie struct { + *xgb.Cookie +} - v.BorderRight = int16(xgb.Get16(buf[b:])) - b += 2 +// 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'SetOutputPrimary' 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} +} - v.BorderBottom = int16(xgb.Get16(buf[b:])) - b += 2 +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{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 SetOutputPrimaryCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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] = 28 // 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)) + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + 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 +type Range8 struct { + First byte + Last byte } -// 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 -} - -// 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,203 +274,174 @@ 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 -// PictforminfoRead reads a byte slice into a Pictforminfo value. -func PictforminfoRead(buf []byte, v *Pictforminfo) int { - b := 0 +type Glyph uint32 - v.Id = Pictformat(xgb.Get32(buf[b:])) - b += 4 +// BadGlyph is the error number for a BadGlyph. +const BadGlyph = 4 - v.Type = buf[b] - b += 1 - - v.Depth = buf[b] - b += 1 +type GlyphError struct { + Sequence uint16 + NiceName string +} - b += 2 // padding +// GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice. +func GlyphErrorNew(buf []byte) xgb.Error { + v := GlyphError{} + v.NiceName = "Glyph" - v.Direct = Directformat{} - b += DirectformatRead(buf[b:], &v.Direct) + b := 1 // skip error determinant + b += 1 // don't read error number - v.Colormap = xproto.Colormap(xgb.Get32(buf[b:])) - b += 4 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - return b + return v } -// 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) +// SequenceId returns the sequence id attached to the BadGlyph error. +// This is mostly used internally. +func (err GlyphError) SequenceId() uint16 { + return err.Sequence } -// 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)) - } +// 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 +} - xgb.Put32(buf[b:], uint32(v.Colormap)) - b += 4 +// Error returns a rudimentary string representation of the BadGlyph error. - return buf +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, ", ") + "}" } -// 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 +func init() { + xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew } -type Pictvisual struct { - Visual xproto.Visualid - Format Pictformat +// BadGlyphSet is the error number for a BadGlyphSet. +const BadGlyphSet = 3 + +type GlyphSetError struct { + Sequence uint16 + NiceName string } -// PictvisualRead reads a byte slice into a Pictvisual value. -func PictvisualRead(buf []byte, v *Pictvisual) int { - b := 0 +// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice. +func GlyphSetErrorNew(buf []byte) xgb.Error { + v := GlyphSetError{} + v.NiceName = "GlyphSet" - v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) - b += 4 + b := 1 // skip error determinant + b += 1 // don't read error number - v.Format = Pictformat(xgb.Get32(buf[b:])) - b += 4 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - return b + return v } -// 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] = Pictvisual{} - b += PictvisualRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the BadGlyphSet error. +// This is mostly used internally. +func (err GlyphSetError) SequenceId() uint16 { + return err.Sequence } -// Bytes writes a Pictvisual value to a byte slice. -func (v Pictvisual) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Visual)) - b += 4 +// 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 +} - xgb.Put32(buf[b:], uint32(v.Format)) - b += 4 +// Error returns a rudimentary string representation of the BadGlyphSet error. - return buf +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, ", ") + "}" } -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +func init() { + xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew } -type Pictdepth struct { - Depth byte - // padding: 1 bytes - NumVisuals uint16 - // padding: 4 bytes - Visuals []Pictvisual // size: xgb.Pad((int(NumVisuals) * 8)) +type Glyphinfo struct { + Width uint16 + Height uint16 + X int16 + Y int16 + XOff int16 + YOff int16 } -// PictdepthRead reads a byte slice into a Pictdepth value. -func PictdepthRead(buf []byte, v *Pictdepth) int { +// GlyphinfoRead reads a byte slice into a Glyphinfo value. +func GlyphinfoRead(buf []byte, v *Glyphinfo) int { b := 0 - v.Depth = buf[b] - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - b += 1 // padding + v.Height = xgb.Get16(buf[b:]) + b += 2 - v.NumVisuals = xgb.Get16(buf[b:]) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - b += 4 // padding + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - v.Visuals = make([]Pictvisual, v.NumVisuals) - b += PictvisualReadList(buf[b:], v.Visuals) + v.XOff = int16(xgb.Get16(buf[b:])) + b += 2 + + v.YOff = int16(xgb.Get16(buf[b:])) + b += 2 return b } -// PictdepthReadList reads a byte slice into a list of Pictdepth values. -func PictdepthReadList(buf []byte, dest []Pictdepth) 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] = Pictdepth{} - b += PictdepthRead(buf[b:], &dest[i]) + dest[i] = Glyphinfo{} + b += GlyphinfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Pictdepth value to a byte slice. -func (v Pictdepth) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8)))) +// Bytes writes a Glyphinfo value to a byte slice. +func (v Glyphinfo) Bytes() []byte { + buf := make([]byte, 12) b := 0 - buf[b] = v.Depth - b += 1 + xgb.Put16(buf[b:], v.Width) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], v.Height) + b += 2 - xgb.Put16(buf[b:], v.NumVisuals) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - b += 4 // padding + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 - b += PictvisualListBytes(buf[b:], v.Visuals) + xgb.Put16(buf[b:], uint16(v.XOff)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.YOff)) + b += 2 return buf } -// PictdepthListBytes writes a list of Pictdepth values to a byte slice. -func PictdepthListBytes(buf []byte, list []Pictdepth) int { +// 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 { @@ -508,101 +452,33 @@ func PictdepthListBytes(buf []byte, list []Pictdepth) int { return b } -// PictdepthListSize computes the size (bytes) of a list of Pictdepth values. -func PictdepthListSize(list []Pictdepth) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.NumVisuals) * 8))) +type Glyphset uint32 + +func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return size + return Glyphset(id), nil } -type Pictscreen struct { - NumDepths uint32 - Fallback Pictformat - Depths []Pictdepth // size: PictdepthListSize(Depths) +type Indexvalue struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 } -// PictscreenRead reads a byte slice into a Pictscreen value. -func PictscreenRead(buf []byte, v *Pictscreen) int { +// IndexvalueRead reads a byte slice into a Indexvalue value. +func IndexvalueRead(buf []byte, v *Indexvalue) int { b := 0 - v.NumDepths = xgb.Get32(buf[b:]) + v.Pixel = xgb.Get32(buf[b:]) b += 4 - v.Fallback = Pictformat(xgb.Get32(buf[b:])) - b += 4 - - v.Depths = make([]Pictdepth, v.NumDepths) - b += PictdepthReadList(buf[b:], v.Depths) - - return b -} - -// PictscreenReadList reads a byte slice into a list of Pictscreen values. -func PictscreenReadList(buf []byte, dest []Pictscreen) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Pictscreen{} - b += PictscreenRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Pictscreen value to a byte slice. -func (v Pictscreen) Bytes() []byte { - buf := make([]byte, (8 + PictdepthListSize(v.Depths))) - b := 0 - - xgb.Put32(buf[b:], v.NumDepths) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Fallback)) - b += 4 - - b += PictdepthListBytes(buf[b:], v.Depths) - - return buf -} - -// PictscreenListBytes writes a list of Pictscreen values to a byte slice. -func PictscreenListBytes(buf []byte, list []Pictscreen) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// PictscreenListSize computes the size (bytes) of a list of Pictscreen values. -func PictscreenListSize(list []Pictscreen) int { - size := 0 - for _, item := range list { - size += (8 + PictdepthListSize(item.Depths)) - } - return size -} - -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.Red = xgb.Get16(buf[b:]) + b += 2 v.Green = xgb.Get16(buf[b:]) b += 2 @@ -661,128 +537,6 @@ func IndexvalueListBytes(buf []byte, list []Indexvalue) int { return b } -type Color struct { - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 -} - -// ColorRead reads a byte slice into a Color value. -func ColorRead(buf []byte, v *Color) 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.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 -} - -type Pointfix struct { - X Fixed - Y Fixed -} - -// PointfixRead reads a byte slice into a Pointfix value. -func PointfixRead(buf []byte, v *Pointfix) int { - b := 0 - - v.X = Fixed(xgb.Get32(buf[b:])) - b += 4 - - v.Y = Fixed(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// PointfixReadList reads a byte slice into a list of Pointfix values. -func PointfixReadList(buf []byte, dest []Pointfix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Pointfix{} - b += PointfixRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Pointfix value to a byte slice. -func (v Pointfix) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.X)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Y)) - b += 4 - - return buf -} - -// PointfixListBytes writes a list of Pointfix values to a byte slice. -func PointfixListBytes(buf []byte, list []Pointfix) 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 Linefix struct { P1 Pointfix P2 Pointfix @@ -843,66 +597,504 @@ func LinefixListBytes(buf []byte, list []Linefix) int { return b } -type Triangle struct { - P1 Pointfix - P2 Pointfix - P3 Pointfix +// BadPictFormat is the error number for a BadPictFormat. +const BadPictFormat = 0 + +type PictFormatError struct { + Sequence uint16 + NiceName string } -// TriangleRead reads a byte slice into a Triangle value. -func TriangleRead(buf []byte, v *Triangle) int { - b := 0 +// PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice. +func PictFormatErrorNew(buf []byte) xgb.Error { + v := PictFormatError{} + v.NiceName = "PictFormat" - v.P1 = Pointfix{} - b += PointfixRead(buf[b:], &v.P1) + b := 1 // skip error determinant + b += 1 // don't read error number - v.P2 = Pointfix{} - b += PointfixRead(buf[b:], &v.P2) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - v.P3 = Pointfix{} - b += PointfixRead(buf[b:], &v.P3) + return v +} - return b +// SequenceId returns the sequence id attached to the BadPictFormat error. +// This is mostly used internally. +func (err PictFormatError) SequenceId() uint16 { + return err.Sequence } -// 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) +// 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 } -// Bytes writes a Triangle value to a byte slice. -func (v Triangle) Bytes() []byte { - buf := make([]byte, 24) - b := 0 +// Error returns a rudimentary string representation of the BadPictFormat error. - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } +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, ", ") + "}" +} - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) +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 + NumVisuals uint16 + // padding: 4 bytes + Visuals []Pictvisual // size: xgb.Pad((int(NumVisuals) * 8)) +} + +// PictdepthRead reads a byte slice into a Pictdepth value. +func PictdepthRead(buf []byte, v *Pictdepth) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.NumVisuals = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]Pictvisual, v.NumVisuals) + b += PictvisualReadList(buf[b:], v.Visuals) + + return b +} + +// PictdepthReadList reads a byte slice into a list of Pictdepth values. +func PictdepthReadList(buf []byte, dest []Pictdepth) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictdepth{} + b += PictdepthRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Pictdepth value to a byte slice. +func (v Pictdepth) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.NumVisuals) + b += 2 + + b += 4 // padding + + b += PictvisualListBytes(buf[b:], v.Visuals) + + return buf +} + +// PictdepthListBytes writes a list of Pictdepth values to a byte slice. +func PictdepthListBytes(buf []byte, list []Pictdepth) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } + return b +} + +// PictdepthListSize computes the size (bytes) of a list of Pictdepth values. +func PictdepthListSize(list []Pictdepth) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumVisuals) * 8))) + } + 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.P3.Bytes() + 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 + Depths []Pictdepth // size: PictdepthListSize(Depths) +} + +// PictscreenRead reads a byte slice into a Pictscreen value. +func PictscreenRead(buf []byte, v *Pictscreen) int { + b := 0 + + v.NumDepths = xgb.Get32(buf[b:]) + b += 4 + + v.Fallback = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + v.Depths = make([]Pictdepth, v.NumDepths) + b += PictdepthReadList(buf[b:], v.Depths) + + return b +} + +// PictscreenReadList reads a byte slice into a list of Pictscreen values. +func PictscreenReadList(buf []byte, dest []Pictscreen) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictscreen{} + b += PictscreenRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Pictscreen value to a byte slice. +func (v Pictscreen) Bytes() []byte { + buf := make([]byte, (8 + PictdepthListSize(v.Depths))) + b := 0 + + xgb.Put32(buf[b:], v.NumDepths) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Fallback)) + b += 4 + + b += PictdepthListBytes(buf[b:], v.Depths) + + return buf +} + +// PictscreenListBytes writes a list of Pictscreen values to a byte slice. +func PictscreenListBytes(buf []byte, list []Pictscreen) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } + return b +} + +// PictscreenListSize computes the size (bytes) of a list of Pictscreen values. +func PictscreenListSize(list []Pictscreen) int { + size := 0 + for _, item := range list { + size += (8 + PictdepthListSize(item.Depths)) + } + return size +} + +type Picture uint32 + +func NewPictureId(c *xgb.Conn) (Picture, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Picture(id), nil +} + +// 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 +} + +const ( + PictureNone = 0 +) + +type Pictvisual struct { + Visual xproto.Visualid + Format Pictformat +} + +// PictvisualRead reads a byte slice into a Pictvisual value. +func PictvisualRead(buf []byte, v *Pictvisual) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Format = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// 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] = Pictvisual{} + b += PictvisualRead(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) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Format)) + b += 4 return buf } -// TriangleListBytes writes a list of Triangle values to a byte slice. -func TriangleListBytes(buf []byte, list []Triangle) 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 { @@ -913,70 +1105,50 @@ func TriangleListBytes(buf []byte, list []Triangle) int { return b } -type Trapezoid struct { - Top Fixed - Bottom Fixed - Left Linefix - Right Linefix +type Pointfix struct { + X Fixed + Y Fixed } -// TrapezoidRead reads a byte slice into a Trapezoid value. -func TrapezoidRead(buf []byte, v *Trapezoid) int { +// PointfixRead reads a byte slice into a Pointfix value. +func PointfixRead(buf []byte, v *Pointfix) int { b := 0 - v.Top = Fixed(xgb.Get32(buf[b:])) + v.X = Fixed(xgb.Get32(buf[b:])) b += 4 - v.Bottom = Fixed(xgb.Get32(buf[b:])) + 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 } -// TrapezoidReadList reads a byte slice into a list of Trapezoid values. -func TrapezoidReadList(buf []byte, dest []Trapezoid) int { +// PointfixReadList reads a byte slice into a list of Pointfix values. +func PointfixReadList(buf []byte, dest []Pointfix) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Trapezoid{} - b += TrapezoidRead(buf[b:], &dest[i]) + dest[i] = Pointfix{} + b += PointfixRead(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 Pointfix value to a byte slice. +func (v Pointfix) Bytes() []byte { + buf := make([]byte, 8) b := 0 - xgb.Put32(buf[b:], uint32(v.Top)) + xgb.Put32(buf[b:], uint32(v.X)) b += 4 - xgb.Put32(buf[b:], uint32(v.Bottom)) + 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 } -// TrapezoidListBytes writes a list of Trapezoid values to a byte slice. -func TrapezoidListBytes(buf []byte, list []Trapezoid) int { +// PointfixListBytes writes a list of Pointfix values to a byte slice. +func PointfixListBytes(buf []byte, list []Pointfix) int { b := 0 var structBytes []byte for _, item := range list { @@ -987,78 +1159,74 @@ func TrapezoidListBytes(buf []byte, list []Trapezoid) int { return b } -type Glyphinfo struct { - Width uint16 - Height uint16 - X int16 - Y int16 - XOff int16 - YOff int16 -} +const ( + PolyEdgeSharp = 0 + PolyEdgeSmooth = 1 +) -// GlyphinfoRead reads a byte slice into a Glyphinfo value. -func GlyphinfoRead(buf []byte, v *Glyphinfo) int { - b := 0 +const ( + PolyModePrecise = 0 + PolyModeImprecise = 1 +) - v.Width = xgb.Get16(buf[b:]) - b += 2 +const ( + RepeatNone = 0 + RepeatNormal = 1 + RepeatPad = 2 + RepeatReflect = 3 +) - v.Height = xgb.Get16(buf[b:]) - b += 2 +type Spanfix struct { + L Fixed + R Fixed + Y Fixed +} - v.X = int16(xgb.Get16(buf[b:])) - b += 2 +// SpanfixRead reads a byte slice into a Spanfix value. +func SpanfixRead(buf []byte, v *Spanfix) int { + b := 0 - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + v.L = Fixed(xgb.Get32(buf[b:])) + b += 4 - v.XOff = int16(xgb.Get16(buf[b:])) - b += 2 + v.R = Fixed(xgb.Get32(buf[b:])) + b += 4 - v.YOff = int16(xgb.Get16(buf[b:])) - b += 2 + v.Y = Fixed(xgb.Get32(buf[b:])) + b += 4 return b } -// GlyphinfoReadList reads a byte slice into a list of Glyphinfo values. -func GlyphinfoReadList(buf []byte, dest []Glyphinfo) 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] = Glyphinfo{} - b += GlyphinfoRead(buf[b:], &dest[i]) + dest[i] = Spanfix{} + b += SpanfixRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Glyphinfo value to a byte slice. -func (v Glyphinfo) Bytes() []byte { +// Bytes writes a Spanfix value to a byte slice. +func (v Spanfix) 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.Put32(buf[b:], uint32(v.L)) + b += 4 - xgb.Put16(buf[b:], uint16(v.XOff)) - b += 2 + xgb.Put32(buf[b:], uint32(v.R)) + b += 4 - xgb.Put16(buf[b:], uint16(v.YOff)) - b += 2 + xgb.Put32(buf[b:], uint32(v.Y)) + b += 4 return buf } -// GlyphinfoListBytes writes a list of Glyphinfo values to a byte slice. -func GlyphinfoListBytes(buf []byte, list []Glyphinfo) 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 { @@ -1069,6 +1237,15 @@ func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { return b } +const ( + SubPixelUnknown = 0 + SubPixelHorizontalRGB = 1 + SubPixelHorizontalBGR = 2 + SubPixelVerticalRGB = 3 + SubPixelVerticalBGR = 4 + SubPixelNone = 5 +) + type Transform struct { Matrix11 Fixed Matrix12 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,788 +1553,650 @@ 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 -} +// Skipping definition for base type 'Bool' -// SequenceId returns the sequence id attached to the BadPictOp error. -// This is mostly used internally. -func (err PictOpError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Byte' -// 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 -} +// Skipping definition for base type 'Card8' -// Error returns a rudimentary string representation of the BadPictOp error. +// Skipping definition for base type 'Char' -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, ", ") + "}" -} +// Skipping definition for base type 'Void' -func init() { - xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew -} +// Skipping definition for base type 'Double' -// BadGlyphSet is the error number for a BadGlyphSet. -const BadGlyphSet = 3 +// Skipping definition for base type 'Float' -type GlyphSetError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Int16' -// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice. -func GlyphSetErrorNew(buf []byte) xgb.Error { - v := GlyphSetError{} - v.NiceName = "GlyphSet" +// Skipping definition for base type 'Int32' - 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 'Card32' -// SequenceId returns the sequence id attached to the BadGlyphSet error. -// This is mostly used internally. -func (err GlyphSetError) SequenceId() uint16 { - return err.Sequence +// AddGlyphsCookie is a cookie used only for AddGlyphs requests. +type AddGlyphsCookie struct { + *xgb.Cookie } -// 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 +// AddGlyphs 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'AddGlyphs' 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} } -// 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, ", ") + "}" +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) + return AddGlyphsCookie{cookie} } -func init() { - xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew +// Check returns an error if one occurred 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() } -// BadGlyph is the error number for a BadGlyph. -const BadGlyph = 4 - -type GlyphError struct { - Sequence uint16 - NiceName string -} +// 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) -// GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice. -func GlyphErrorNew(buf []byte) xgb.Error { - v := GlyphError{} - v.NiceName = "Glyph" + buf[b] = c.Extensions["RENDER"] + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = 20 // 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 -} + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 -// SequenceId returns the sequence id attached to the BadGlyph error. -// This is mostly used internally. -func (err GlyphError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put32(buf[b:], GlyphsLen) + b += 4 -// 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 -} + for i := 0; i < int(GlyphsLen); i++ { + xgb.Put32(buf[b:], Glyphids[i]) + b += 4 + } + b = xgb.Pad(b) -// Error returns a rudimentary string representation of the BadGlyph error. + b += GlyphinfoListBytes(buf[b:], Glyphs) -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, ", ") + "}" -} + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) -func init() { - xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew + return buf } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// AddTrapsCookie is a cookie used only for AddTraps requests. +type AddTrapsCookie 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 { +// AddTraps 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 { 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 'AddTraps' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{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 { +// 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 'QueryVersion' 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, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{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 +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// 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 -} +// 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) -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["RENDER"] + b += 1 - b += 1 // padding + buf[b] = 32 // 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.MajorVersion = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(XOff)) + b += 2 - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(YOff)) + b += 2 - b += 16 // padding + b += TrapListBytes(buf[b:], Traps) - return v + return buf } -// 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 +// ChangePictureCookie is a cookie used only for ChangePicture requests. +type ChangePictureCookie struct { + *xgb.Cookie +} + +// ChangePicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'ChangePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) + return ChangePictureCookie{cookie} +} + +// ChangePictureChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePictureCookie.Check() +func ChangePictureChecked(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'ChangePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) + return ChangePictureCookie{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 ChangePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangePicture +// changePictureRequest writes a ChangePicture request to a byte slice. +func changePictureRequest(c *xgb.Conn, Picture Picture, 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["RENDER"] b += 1 - buf[b] = 0 // 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:], ClientMajorVersion) + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put32(buf[b:], ClientMinorVersion) + 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 } -// QueryPictFormatsCookie is a cookie used only for QueryPictFormats requests. -type QueryPictFormatsCookie struct { +// CompositeCookie is a cookie used only for Composite requests. +type CompositeCookie 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. +// Composite 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 { +func Composite(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'Composite' 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)) + cookie := c.NewCookie(false, false) + c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) + return CompositeCookie{cookie} } -// 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 +// CompositeChecked sends a checked request. +// If an error occurs, it can be retrieved using CompositeCookie.Check() +func CompositeChecked(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'Composite' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } - return queryPictFormatsReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) + return CompositeCookie{cookie} } -// queryPictFormatsReply reads a byte slice into a QueryPictFormatsReply value. -func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { - v := new(QueryPictFormatsReply) - 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 CompositeCookie) Check() error { + return cook.Cookie.Check() +} - b += 1 // padding +// Write request to wire for Composite +// compositeRequest writes a Composite request to a byte slice. +func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 36 + b := 0 + buf := make([]byte, size) - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + buf[b] = c.Extensions["RENDER"] + b += 1 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + buf[b] = 8 // request opcode + b += 1 - v.NumFormats = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - v.NumScreens = xgb.Get32(buf[b:]) - b += 4 + buf[b] = Op + b += 1 - v.NumDepths = xgb.Get32(buf[b:]) - b += 4 + b += 3 // padding - v.NumVisuals = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(Src)) b += 4 - v.NumSubpixel = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(Mask)) b += 4 - b += 4 // padding + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 - v.Formats = make([]Pictforminfo, v.NumFormats) - b += PictforminfoReadList(buf[b:], v.Formats) + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 - v.Screens = make([]Pictscreen, v.NumScreens) - b += PictscreenReadList(buf[b:], v.Screens) + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 - 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) + xgb.Put16(buf[b:], uint16(MaskX)) + b += 2 - return v -} + xgb.Put16(buf[b:], uint16(MaskY)) + b += 2 -// 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) + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 - buf[b] = c.Extensions["RENDER"] - b += 1 + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 - buf[b] = 1 // request opcode - b += 1 + xgb.Put16(buf[b:], Width) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Height) b += 2 return buf } -// QueryPictIndexValuesCookie is a cookie used only for QueryPictIndexValues requests. -type QueryPictIndexValuesCookie struct { +// CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests. +type CompositeGlyphs16Cookie 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 { +// CompositeGlyphs16 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 { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryPictIndexValues' 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, true) - c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) - return QueryPictIndexValuesCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{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 { +// 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 'QueryPictIndexValues' 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, true) - c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) - return QueryPictIndexValuesCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{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)) +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// 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 -} +// 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) -// queryPictIndexValuesReply reads a byte slice into a QueryPictIndexValuesReply value. -func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply { - v := new(QueryPictIndexValuesReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["RENDER"] + 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 - b += 4 - - v.NumValues = xgb.Get32(buf[b:]) - b += 4 + buf[b] = Op + b += 1 - b += 20 // padding + b += 3 // padding - v.Values = make([]Indexvalue, v.NumValues) - b += IndexvalueReadList(buf[b:], v.Values) + xgb.Put32(buf[b:], uint32(Src)) + b += 4 - return v -} + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 -// 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) + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 - buf[b] = c.Extensions["RENDER"] - b += 1 + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 - buf[b] = 2 // request opcode - b += 1 + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - xgb.Put32(buf[b:], uint32(Format)) - b += 4 + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) return buf } -// CreatePictureCookie is a cookie used only for CreatePicture requests. -type CreatePictureCookie struct { +// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests. +type CompositeGlyphs32Cookie struct { *xgb.Cookie } -// CreatePicture 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 CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { +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 'CreatePicture' 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(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) - return CreatePictureCookie{cookie} + c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs32Cookie{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 { +// 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 'CreatePicture' 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(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) - return CreatePictureCookie{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 CreatePictureCookie) Check() error { +func (cook CompositeGlyphs32Cookie) 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 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] = 4 // 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(Pid)) + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Dst)) b += 4 - xgb.Put32(buf[b:], uint32(Format)) + xgb.Put32(buf[b:], uint32(MaskFormat)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Glyphset)) 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:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) return buf } -// ChangePictureCookie is a cookie used only for ChangePicture requests. -type ChangePictureCookie struct { +// CompositeGlyphs8Cookie is a cookie used only for CompositeGlyphs8 requests. +type CompositeGlyphs8Cookie struct { *xgb.Cookie } -// ChangePicture 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 ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { +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 'ChangePicture' 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(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) - return ChangePictureCookie{cookie} + c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs8Cookie{cookie} } -// ChangePictureChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangePictureCookie.Check() -func ChangePictureChecked(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { +// 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 'ChangePicture' 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(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) - return ChangePictureCookie{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 ChangePictureCookie) Check() error { +func (cook CompositeGlyphs8Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangePicture -// changePictureRequest writes a ChangePicture request to a byte slice. -func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// 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] = 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(Picture)) + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Dst)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + + 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 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) return buf } -// SetPictureClipRectanglesCookie is a cookie used only for SetPictureClipRectangles requests. -type SetPictureClipRectanglesCookie struct { +// CreateAnimCursorCookie is a cookie used only for CreateAnimCursor requests. +type CreateAnimCursorCookie struct { *xgb.Cookie } -// SetPictureClipRectangles 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 SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { +func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureClipRectangles' 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(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetPictureClipRectanglesCookie{cookie} + c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) + return CreateAnimCursorCookie{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 { +// 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 'SetPictureClipRectangles' 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(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetPictureClipRectanglesCookie{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 SetPictureClipRectanglesCookie) Check() error { +func (cook CreateAnimCursorCookie) 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)))) +// 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] = 6 // 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(Picture)) + xgb.Put32(buf[b:], uint32(Cid)) b += 4 - xgb.Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += xproto.RectangleListBytes(buf[b:], Rectangles) + b += AnimcursoreltListBytes(buf[b:], Cursors) return buf } -// FreePictureCookie is a cookie used only for FreePicture requests. -type FreePictureCookie struct { +// CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests. +type CreateConicalGradientCookie struct { *xgb.Cookie } -// FreePicture 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 FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { +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 'FreePicture' 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(freePictureRequest(c, Picture), cookie) - return FreePictureCookie{cookie} + c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) + return CreateConicalGradientCookie{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 { +// 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 'FreePicture' 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(freePictureRequest(c, Picture), cookie) - return FreePictureCookie{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 FreePictureCookie) Check() error { +func (cook CreateConicalGradientCookie) 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 +// 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] = 7 // request opcode + buf[b] = 36 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2137,508 +2205,508 @@ func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { xgb.Put32(buf[b:], uint32(Picture)) b += 4 + { + 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 } -// CompositeCookie is a cookie used only for Composite requests. -type CompositeCookie struct { +// CreateCursorCookie is a cookie used only for CreateCursor requests. +type CreateCursorCookie struct { *xgb.Cookie } -// Composite 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 Composite(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { +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 'Composite' 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(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) - return CompositeCookie{cookie} + c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) + return CreateCursorCookie{cookie} } -// CompositeChecked sends a checked request. -// If an error occurs, it can be retrieved using CompositeCookie.Check() -func CompositeChecked(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { +// 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 'Composite' 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(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) - return CompositeCookie{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 CompositeCookie) Check() error { +func (cook CreateCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Composite -// compositeRequest writes a Composite request to a byte slice. -func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 36 +// 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] = 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 - buf[b] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Src)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mask)) + xgb.Put32(buf[b:], uint32(Cid)) b += 4 - xgb.Put32(buf[b:], uint32(Dst)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - xgb.Put16(buf[b:], uint16(MaskX)) - b += 2 - - xgb.Put16(buf[b:], uint16(MaskY)) - 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:], X) b += 2 - xgb.Put16(buf[b:], Height) + xgb.Put16(buf[b:], Y) b += 2 return buf } -// TrapezoidsCookie is a cookie used only for Trapezoids requests. -type TrapezoidsCookie struct { +// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests. +type CreateGlyphSetCookie struct { *xgb.Cookie } -// Trapezoids 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 Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { +func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { 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 'CreateGlyphSet' 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(createGlyphSetRequest(c, Gsid, Format), cookie) + return CreateGlyphSetCookie{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 { +// 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 'Trapezoids' 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(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) - return TrapezoidsCookie{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 TrapezoidsCookie) Check() error { +func (cook CreateGlyphSetCookie) 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 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] = 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 - buf[b] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Src)) - b += 4 - - xgb.Put32(buf[b:], uint32(Dst)) + xgb.Put32(buf[b:], uint32(Gsid)) b += 4 - xgb.Put32(buf[b:], uint32(MaskFormat)) + xgb.Put32(buf[b:], uint32(Format)) 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 } -// TrianglesCookie is a cookie used only for Triangles requests. -type TrianglesCookie struct { +// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests. +type CreateLinearGradientCookie struct { *xgb.Cookie } -// Triangles 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 Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { +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 'Triangles' 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(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return TrianglesCookie{cookie} + c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) + return CreateLinearGradientCookie{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 { +// 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 'Triangles' 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(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return TrianglesCookie{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 TrianglesCookie) Check() error { +func (cook CreateLinearGradientCookie) 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 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] = 11 // 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 - buf[b] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Src)) + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put32(buf[b:], uint32(Dst)) - b += 4 + { + structBytes := P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - xgb.Put32(buf[b:], uint32(MaskFormat)) - b += 4 + { + structBytes := P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 + xgb.Put32(buf[b:], NumStops) + b += 4 - 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) - b += TriangleListBytes(buf[b:], Triangles) + b += ColorListBytes(buf[b:], Colors) return buf } -// TriStripCookie is a cookie used only for TriStrip requests. -type TriStripCookie struct { +// CreatePictureCookie is a cookie used only for CreatePicture requests. +type CreatePictureCookie struct { *xgb.Cookie } -// TriStrip 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 TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { +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 'TriStrip' 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(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriStripCookie{cookie} + c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) + return CreatePictureCookie{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 { +// 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 'TriStrip' 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(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriStripCookie{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 TriStripCookie) Check() error { +func (cook CreatePictureCookie) 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 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] = 12 // 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] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Src)) + xgb.Put32(buf[b:], uint32(Pid)) b += 4 - xgb.Put32(buf[b:], uint32(Dst)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(MaskFormat)) + xgb.Put32(buf[b:], uint32(Format)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += PointfixListBytes(buf[b:], Points) + 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 } -// TriFanCookie is a cookie used only for TriFan requests. -type TriFanCookie struct { +// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests. +type CreateRadialGradientCookie struct { *xgb.Cookie } -// TriFan 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 TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { +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 'TriFan' 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(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriFanCookie{cookie} + c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) + return CreateRadialGradientCookie{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 { +// 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 'TriFan' 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(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriFanCookie{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 TriFanCookie) Check() error { +func (cook CreateRadialGradientCookie) 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 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] = 13 // 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.Put16(buf[b:], uint16(SrcX)) - b += 2 + xgb.Put32(buf[b:], NumStops) + b += 4 - 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) - b += PointfixListBytes(buf[b:], Points) + b += ColorListBytes(buf[b:], Colors) return buf } -// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests. -type CreateGlyphSetCookie struct { +// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. +type CreateSolidFillCookie struct { *xgb.Cookie } -// CreateGlyphSet 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 CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { +func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { 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 'CreateSolidFill' 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(createSolidFillRequest(c, Picture, Color), cookie) + return CreateSolidFillCookie{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 { +// 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 'CreateGlyphSet' 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(createGlyphSetRequest(c, Gsid, Format), cookie) - return CreateGlyphSetCookie{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 CreateGlyphSetCookie) Check() error { +func (cook CreateSolidFillCookie) 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 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] = 17 // 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(Gsid)) + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - xgb.Put32(buf[b:], uint32(Format)) - b += 4 + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests. -type ReferenceGlyphSetCookie struct { +// FillRectanglesCookie is a cookie used only for FillRectangles requests. +type FillRectanglesCookie struct { *xgb.Cookie } -// ReferenceGlyphSet 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 ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { +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 'ReferenceGlyphSet' 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(referenceGlyphSetRequest(c, Gsid, Existing), cookie) - return ReferenceGlyphSetCookie{cookie} + c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) + return FillRectanglesCookie{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 { +// 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 'ReferenceGlyphSet' 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(referenceGlyphSetRequest(c, Gsid, Existing), cookie) - return ReferenceGlyphSetCookie{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 ReferenceGlyphSetCookie) Check() error { +func (cook FillRectanglesCookie) 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 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] = 18 // 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(Gsid)) - b += 4 + buf[b] = Op + b += 1 - xgb.Put32(buf[b:], uint32(Existing)) + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Dst)) b += 4 + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + b += xproto.RectangleListBytes(buf[b:], Rects) + return buf } @@ -2697,75 +2765,6 @@ func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { return buf } -// AddGlyphsCookie is a cookie used only for AddGlyphs requests. -type AddGlyphsCookie struct { - *xgb.Cookie -} - -// AddGlyphs 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'AddGlyphs' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) - return AddGlyphsCookie{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 { - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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(Glyphset)) - b += 4 - - xgb.Put32(buf[b:], GlyphsLen) - b += 4 - - for i := 0; i < int(GlyphsLen); i++ { - xgb.Put32(buf[b:], Glyphids[i]) - b += 4 - } - b = xgb.Pad(b) - - b += GlyphinfoListBytes(buf[b:], Glyphs) - - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) - - return buf -} - // FreeGlyphsCookie is a cookie used only for FreeGlyphs requests. type FreeGlyphsCookie struct { *xgb.Cookie @@ -2827,537 +2826,599 @@ func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { return buf } -// CompositeGlyphs8Cookie is a cookie used only for CompositeGlyphs8 requests. -type CompositeGlyphs8Cookie struct { - *xgb.Cookie -} - -// CompositeGlyphs8 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs8' 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} -} - -// 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 'CompositeGlyphs8' 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} -} - -// Check returns an error if one occurred 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 { - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 23 // 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)) - 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))) - - return buf -} - -// CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests. -type CompositeGlyphs16Cookie struct { +// FreePictureCookie is a cookie used only for FreePicture requests. +type FreePictureCookie struct { *xgb.Cookie } -// CompositeGlyphs16 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 CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { +func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { 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 'FreePicture' 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(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{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 { +// 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 'CompositeGlyphs16' 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(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs16Cookie{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 CompositeGlyphs16Cookie) Check() error { +func (cook FreePictureCookie) 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 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] = 24 // 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 - buf[b] = Op - b += 1 + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 - b += 3 // padding + return buf +} - xgb.Put32(buf[b:], uint32(Src)) - b += 4 +// QueryFiltersCookie is a cookie used only for QueryFilters requests. +type QueryFiltersCookie struct { + *xgb.Cookie +} - xgb.Put32(buf[b:], uint32(Dst)) +// QueryFilters sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFiltersCookie.Reply() +func QueryFilters(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'QueryFilters' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} +} + +// QueryFiltersUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'QueryFilters' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} +} + +// QueryFiltersReply represents the data returned from a QueryFilters request. +type QueryFiltersReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumAliases uint32 + NumFilters uint32 + // padding: 16 bytes + Aliases []uint16 // size: xgb.Pad((int(NumAliases) * 2)) + Filters []xproto.Str // size: xproto.StrListSize(Filters) +} + +// Reply blocks and returns the reply data for a QueryFilters request. +func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFiltersReply(buf), nil +} + +// queryFiltersReply reads a byte slice into a QueryFiltersReply value. +func queryFiltersReply(buf []byte) *QueryFiltersReply { + v := new(QueryFiltersReply) + 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.Put32(buf[b:], uint32(MaskFormat)) + v.NumAliases = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(Glyphset)) + v.NumFilters = xgb.Get32(buf[b:]) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 + b += 16 // padding - xgb.Put16(buf[b:], uint16(SrcY)) + v.Aliases = make([]uint16, v.NumAliases) + for i := 0; i < int(v.NumAliases); i++ { + v.Aliases[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Filters = make([]xproto.Str, v.NumFilters) + b += xproto.StrReadList(buf[b:], v.Filters) + + return v +} + +// Write request to wire for QueryFilters +// queryFiltersRequest writes a QueryFilters request to a byte slice. +func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 return buf } -// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests. -type CompositeGlyphs32Cookie struct { +// QueryPictFormatsCookie is a cookie used only for QueryPictFormats requests. +type QueryPictFormatsCookie struct { *xgb.Cookie } -// CompositeGlyphs32 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 { +// 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 'CompositeGlyphs32' 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(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs32Cookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictFormatsRequest(c), cookie) + return QueryPictFormatsCookie{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 { +// 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 'CompositeGlyphs32' 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(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return CompositeGlyphs32Cookie{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 CompositeGlyphs32Cookie) 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 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) +// 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 +} - buf[b] = c.Extensions["RENDER"] - b += 1 +// queryPictFormatsReply reads a byte slice into a QueryPictFormatsReply value. +func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { + v := new(QueryPictFormatsReply) + b := 1 // skip reply determinant - buf[b] = 25 // 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 - buf[b] = Op - b += 1 + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - b += 3 // padding + v.NumFormats = xgb.Get32(buf[b:]) + b += 4 - xgb.Put32(buf[b:], uint32(Src)) + v.NumScreens = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(Dst)) + v.NumDepths = xgb.Get32(buf[b:]) + b += 4 + + v.NumVisuals = xgb.Get32(buf[b:]) + b += 4 + + v.NumSubpixel = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], uint32(MaskFormat)) - 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) - xgb.Put32(buf[b:], uint32(Glyphset)) - b += 4 + buf[b] = c.Extensions["RENDER"] + b += 1 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 + buf[b] = 1 // request opcode + b += 1 - xgb.Put16(buf[b:], uint16(SrcY)) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) - return buf } -// FillRectanglesCookie is a cookie used only for FillRectangles requests. -type FillRectanglesCookie struct { +// QueryPictIndexValuesCookie is a cookie used only for QueryPictIndexValues requests. +type QueryPictIndexValuesCookie struct { *xgb.Cookie } -// FillRectangles 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 { +// 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 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryPictIndexValues' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{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 { +// 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 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryPictIndexValues' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{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 { - return cook.Cookie.Check() +// 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)) } -// 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)))) +// 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] = 26 // 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 - buf[b] = Op - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], uint32(Dst)) + xgb.Put32(buf[b:], uint32(Format)) 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 { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// CreateCursor 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 { +// 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 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{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 { +// 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 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' 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} + 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 CreateCursorCookie) 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 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 +// 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] = 27 // 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(Cid)) + xgb.Put32(buf[b:], ClientMajorVersion) b += 4 - xgb.Put32(buf[b:], uint32(Source)) + xgb.Put32(buf[b:], ClientMinorVersion) b += 4 - xgb.Put16(buf[b:], X) - b += 2 - - xgb.Put16(buf[b:], Y) - b += 2 - return buf } -// SetPictureTransformCookie is a cookie used only for SetPictureTransform requests. -type SetPictureTransformCookie struct { +// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests. +type ReferenceGlyphSetCookie struct { *xgb.Cookie } -// SetPictureTransform 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 SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { +func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { 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 'ReferenceGlyphSet' 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(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{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 { +// 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 'SetPictureTransform' 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(setPictureTransformRequest(c, Picture, Transform), cookie) - return SetPictureTransformCookie{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 SetPictureTransformCookie) Check() error { +func (cook ReferenceGlyphSetCookie) 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 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] = 28 // 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(Picture)) + xgb.Put32(buf[b:], uint32(Gsid)) b += 4 - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + xgb.Put32(buf[b:], uint32(Existing)) + b += 4 return buf } -// QueryFiltersCookie is a cookie used only for QueryFilters requests. -type QueryFiltersCookie struct { +// SetPictureClipRectanglesCookie is a cookie used only for SetPictureClipRectangles requests. +type SetPictureClipRectanglesCookie struct { *xgb.Cookie } -// QueryFilters sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryFiltersCookie.Reply() -func QueryFilters(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'QueryFilters' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryFiltersRequest(c, Drawable), cookie) - return QueryFiltersCookie{cookie} -} - -// QueryFiltersUnchecked 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 QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { +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 'QueryFilters' 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, true) - c.NewRequest(queryFiltersRequest(c, Drawable), cookie) - return QueryFiltersCookie{cookie} -} - -// QueryFiltersReply represents the data returned from a QueryFilters request. -type QueryFiltersReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumAliases uint32 - NumFilters uint32 - // padding: 16 bytes - Aliases []uint16 // size: xgb.Pad((int(NumAliases) * 2)) - Filters []xproto.Str // size: xproto.StrListSize(Filters) + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{cookie} } -// Reply blocks and returns the reply data for a QueryFilters request. -func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// 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.") } - return queryFiltersReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{cookie} } -// queryFiltersReply reads a byte slice into a QueryFiltersReply value. -func queryFiltersReply(buf []byte) *QueryFiltersReply { - v := new(QueryFiltersReply) - 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.NumAliases = xgb.Get32(buf[b:]) - b += 4 - - v.NumFilters = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.Aliases = make([]uint16, v.NumAliases) - for i := 0; i < int(v.NumAliases); i++ { - v.Aliases[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) - - v.Filters = make([]xproto.Str, v.NumFilters) - b += xproto.StrReadList(buf[b:], v.Filters) - - 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 SetPictureClipRectanglesCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryFilters -// queryFiltersRequest writes a QueryFilters request to a byte slice. -func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { - size := 8 +// 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] = 29 // 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(Drawable)) + 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 } @@ -3430,107 +3491,50 @@ func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Fil return buf } -// CreateAnimCursorCookie is a cookie used only for CreateAnimCursor requests. -type CreateAnimCursorCookie struct { - *xgb.Cookie -} - -// CreateAnimCursor 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateAnimCursor' 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} -} - -// 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 'CreateAnimCursor' 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} -} - -// Check returns an error if one occurred 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 { - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - 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(Cid)) - b += 4 - - b += AnimcursoreltListBytes(buf[b:], Cursors) - - return buf -} - -// AddTrapsCookie is a cookie used only for AddTraps requests. -type AddTrapsCookie struct { +// SetPictureTransformCookie is a cookie used only for SetPictureTransform requests. +type SetPictureTransformCookie struct { *xgb.Cookie } -// AddTraps 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 AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { +func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { 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 'SetPictureTransform' 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(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{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 { +// 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 'AddTraps' 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(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) - return AddTrapsCookie{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 AddTrapsCookie) Check() error { +func (cook SetPictureTransformCookie) 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 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] = 32 // request opcode + buf[b] = 28 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3539,311 +3543,307 @@ 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)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOff)) - b += 2 - - b += TrapListBytes(buf[b:], Traps) + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. -type CreateSolidFillCookie struct { +// TrapezoidsCookie is a cookie used only for Trapezoids requests. +type TrapezoidsCookie struct { *xgb.Cookie } -// CreateSolidFill sends an unchecked request. +// Trapezoids 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 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 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'Trapezoids' 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(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) + return TrapezoidsCookie{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 { +// 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 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'Trapezoids' 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(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 CreateSolidFillCookie) Check() error { +func (cook TrapezoidsCookie) 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 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] = 33 // 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(Picture)) + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) b += 4 - { - structBytes := Color.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 += TrapezoidListBytes(buf[b:], Traps) return buf } -// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests. -type CreateLinearGradientCookie struct { +// TriFanCookie is a cookie used only for TriFan requests. +type TriFanCookie struct { *xgb.Cookie } -// CreateLinearGradient 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 CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { +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 'CreateLinearGradient' 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(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) - return CreateLinearGradientCookie{cookie} + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{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 { +// 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 'CreateLinearGradient' 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(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) - return CreateLinearGradientCookie{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 CreateLinearGradientCookie) Check() error { +func (cook TriFanCookie) 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 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] = 34 // 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)) - b += 4 + buf[b] = Op + b += 1 - { - structBytes := P1.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + b += 3 // padding - { - structBytes := P2.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + 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 += PointfixListBytes(buf[b:], Points) return buf } -// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests. -type CreateRadialGradientCookie struct { +// TriStripCookie is a cookie used only for TriStrip requests. +type TriStripCookie struct { *xgb.Cookie } -// CreateRadialGradient sends an unchecked request. +// TriStrip 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 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 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'TriStrip' 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(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{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 { +// 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 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'TriStrip' 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(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{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 TriStripCookie) 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 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] = 35 // 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(Picture)) - b += 4 - - { - structBytes := Inner.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + buf[b] = Op + b += 1 - { - structBytes := Outer.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + b += 3 // padding - xgb.Put32(buf[b:], uint32(InnerRadius)) + 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 - b := 0 - buf := make([]byte, size) +// 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 +} - buf[b] = c.Extensions["SHAPE"] - b += 1 +// getRectanglesReply reads a byte slice into a GetRectanglesReply value. +func getRectanglesReply(buf []byte) *GetRectanglesReply { + v := new(GetRectanglesReply) + b := 1 // skip reply determinant - buf[b] = 2 // request opcode + v.Ordering = 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 - buf[b] = byte(Operation) - b += 1 - - buf[b] = byte(DestinationKind) + 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 - b += 2 // padding + buf[b] = 8 // request opcode + b += 1 - xgb.Put32(buf[b:], uint32(DestinationWindow)) + 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(XOffset)) + buf[b] = byte(SourceKind) + b += 1 + + 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 + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(YOffset)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + 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 + 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(Shmseg)) + xgb.Put32(buf[b:], uint32(Pid)) b += 4 - return buf -} + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { - *xgb.Cookie -} + xgb.Put16(buf[b:], Width) + b += 2 -// PutImage 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 { + 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 +} + +// DetachCookie is a cookie used only for Detach requests. +type DetachCookie struct { + *xgb.Cookie +} + +// Detach 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 { 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,57 +40,6 @@ func init() { xgb.NewExtErrorFuncs["SYNC"] = 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' - -const ( - AlarmstateActive = 0 - AlarmstateInactive = 1 - AlarmstateDestroyed = 2 -) - -const ( - TesttypePositiveTransition = 0 - TesttypeNegativeTransition = 1 - TesttypePositiveComparison = 2 - TesttypeNegativeComparison = 3 -) - -const ( - ValuetypeAbsolute = 0 - ValuetypeRelative = 1 -) - -const ( - CaCounter = 1 - CaValueType = 2 - CaValue = 4 - CaTestType = 8 - CaDelta = 16 - CaEvents = 32 -) - type Alarm uint32 func NewAlarmId(c *xgb.Conn) (Alarm, error) { @@ -101,293 +50,258 @@ func NewAlarmId(c *xgb.Conn) (Alarm, error) { return Alarm(id), nil } -type Counter uint32 +// BadAlarm is the error number for a BadAlarm. +const BadAlarm = 1 -func NewCounterId(c *xgb.Conn) (Counter, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Counter(id), nil +type AlarmError struct { + Sequence uint16 + NiceName string + BadAlarm uint32 + MinorOpcode uint16 + MajorOpcode byte } -type Fence uint32 - -func NewFenceId(c *xgb.Conn) (Fence, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fence(id), nil -} +// AlarmErrorNew constructs a AlarmError value that implements xgb.Error from a byte slice. +func AlarmErrorNew(buf []byte) xgb.Error { + v := AlarmError{} + v.NiceName = "Alarm" -type Int64 struct { - Hi int32 - Lo uint32 -} + b := 1 // skip error determinant + b += 1 // don't read error number -// Int64Read reads a byte slice into a Int64 value. -func Int64Read(buf []byte, v *Int64) int { - b := 0 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - v.Hi = int32(xgb.Get32(buf[b:])) + v.BadAlarm = xgb.Get32(buf[b:]) b += 4 - v.Lo = xgb.Get32(buf[b:]) - b += 4 + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 - return b -} + v.MajorOpcode = buf[b] + b += 1 -// Int64ReadList reads a byte slice into a list of Int64 values. -func Int64ReadList(buf []byte, dest []Int64) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Int64{} - b += Int64Read(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return v } -// Bytes writes a Int64 value to a byte slice. -func (v Int64) Bytes() []byte { - buf := make([]byte, 8) - b := 0 +// SequenceId returns the sequence id attached to the BadAlarm error. +// This is mostly used internally. +func (err AlarmError) SequenceId() uint16 { + return err.Sequence +} - xgb.Put32(buf[b:], uint32(v.Hi)) - b += 4 +// 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 +} - xgb.Put32(buf[b:], v.Lo) - b += 4 +// Error returns a rudimentary string representation of the BadAlarm error. - return buf +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, ", ") + "}" } -// Int64ListBytes writes a list of Int64 values to a byte slice. -func Int64ListBytes(buf []byte, list []Int64) 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["SYNC"][1] = AlarmErrorNew } -type Systemcounter struct { - Counter Counter - Resolution Int64 - NameLen uint16 - Name string // size: xgb.Pad((int(NameLen) * 1)) +// 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 } -// SystemcounterRead reads a byte slice into a Systemcounter value. -func SystemcounterRead(buf []byte, v *Systemcounter) int { - b := 0 +// 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.Counter = Counter(xgb.Get32(buf[b:])) + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Alarm = Alarm(xgb.Get32(buf[b:])) b += 4 - v.Resolution = Int64{} - b += Int64Read(buf[b:], &v.Resolution) + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) - v.NameLen = xgb.Get16(buf[b:]) - b += 2 + v.AlarmValue = Int64{} + b += Int64Read(buf[b:], &v.AlarmValue) - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 - return b -} + v.State = buf[b] + b += 1 -// SystemcounterReadList reads a byte slice into a list of Systemcounter values. -func SystemcounterReadList(buf []byte, dest []Systemcounter) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Systemcounter{} - b += SystemcounterRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + b += 3 // padding + + return v } -// Bytes writes a Systemcounter value to a byte slice. -func (v Systemcounter) Bytes() []byte { - buf := make([]byte, (14 + xgb.Pad((int(v.NameLen) * 1)))) +// Bytes writes a AlarmNotifyEvent value to a byte slice. +func (v AlarmNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - xgb.Put32(buf[b:], uint32(v.Counter)) + // 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.Resolution.Bytes() + structBytes := v.CounterValue.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } - xgb.Put16(buf[b:], v.NameLen) - b += 2 - - copy(buf[b:], v.Name[:v.NameLen]) - b += xgb.Pad(int(v.NameLen)) - - return buf -} - -// SystemcounterListBytes writes a list of Systemcounter values to a byte slice. -func SystemcounterListBytes(buf []byte, list []Systemcounter) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() + { + structBytes := v.AlarmValue.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } - return b -} - -// SystemcounterListSize computes the size (bytes) of a list of Systemcounter values. -func SystemcounterListSize(list []Systemcounter) int { - size := 0 - for _, item := range list { - size += (14 + xgb.Pad((int(item.NameLen) * 1))) - } - return size -} - -type Trigger struct { - Counter Counter - WaitType uint32 - WaitValue Int64 - TestType uint32 -} - -// TriggerRead reads a byte slice into a Trigger value. -func TriggerRead(buf []byte, v *Trigger) int { - b := 0 - - v.Counter = Counter(xgb.Get32(buf[b:])) - b += 4 - v.WaitType = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(v.Timestamp)) b += 4 - v.WaitValue = Int64{} - b += Int64Read(buf[b:], &v.WaitValue) + buf[b] = v.State + b += 1 - v.TestType = xgb.Get32(buf[b:]) - b += 4 + b += 3 // padding - return b + return buf } -// TriggerReadList reads a byte slice into a list of Trigger values. -func TriggerReadList(buf []byte, dest []Trigger) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Trigger{} - b += TriggerRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// 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 } -// Bytes writes a Trigger value to a byte slice. -func (v Trigger) Bytes() []byte { - buf := make([]byte, 20) - b := 0 +// 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, ", ") + "}" +} - xgb.Put32(buf[b:], uint32(v.Counter)) - b += 4 +func init() { + xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew +} - xgb.Put32(buf[b:], v.WaitType) - b += 4 +const ( + AlarmstateActive = 0 + AlarmstateInactive = 1 + AlarmstateDestroyed = 2 +) - { - structBytes := v.WaitValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } +const ( + CaCounter = 1 + CaValueType = 2 + CaValue = 4 + CaTestType = 8 + CaDelta = 16 + CaEvents = 32 +) - xgb.Put32(buf[b:], v.TestType) - b += 4 +type Counter uint32 - return buf +func NewCounterId(c *xgb.Conn) (Counter, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Counter(id), nil } -// TriggerListBytes writes a list of Trigger values to a byte slice. -func TriggerListBytes(buf []byte, list []Trigger) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// BadCounter is the error number for a BadCounter. +const BadCounter = 0 + +type CounterError struct { + Sequence uint16 + NiceName string + BadCounter uint32 + MinorOpcode uint16 + MajorOpcode byte } -type Waitcondition struct { - Trigger Trigger - EventThreshold Int64 -} +// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. +func CounterErrorNew(buf []byte) xgb.Error { + v := CounterError{} + v.NiceName = "Counter" -// WaitconditionRead reads a byte slice into a Waitcondition value. -func WaitconditionRead(buf []byte, v *Waitcondition) int { - b := 0 + b := 1 // skip error determinant + b += 1 // don't read error number - v.Trigger = Trigger{} - b += TriggerRead(buf[b:], &v.Trigger) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - v.EventThreshold = Int64{} - b += Int64Read(buf[b:], &v.EventThreshold) + v.BadCounter = xgb.Get32(buf[b:]) + b += 4 - return b -} + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 -// WaitconditionReadList reads a byte slice into a list of Waitcondition values. -func WaitconditionReadList(buf []byte, dest []Waitcondition) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Waitcondition{} - b += WaitconditionRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + v.MajorOpcode = buf[b] + b += 1 + + return v } -// Bytes writes a Waitcondition value to a byte slice. -func (v Waitcondition) Bytes() []byte { - buf := make([]byte, 28) - b := 0 +// SequenceId returns the sequence id attached to the BadCounter error. +// This is mostly used internally. +func (err CounterError) SequenceId() uint16 { + return err.Sequence +} - { - structBytes := v.Trigger.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } +// 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 +} - { - structBytes := v.EventThreshold.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } +// Error returns a rudimentary string representation of the BadCounter error. - return buf +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, ", ") + "}" } -// WaitconditionListBytes writes a list of Waitcondition values to a byte slice. -func WaitconditionListBytes(buf []byte, list []Waitcondition) 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["SYNC"][0] = CounterErrorNew } // CounterNotify is the event number for a CounterNotifyEvent. @@ -513,422 +427,617 @@ func init() { xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew } -// AlarmNotify is the event number for a AlarmNotifyEvent. -const AlarmNotify = 1 +type Fence uint32 -type AlarmNotifyEvent struct { - Sequence uint16 - Kind byte - Alarm Alarm - CounterValue Int64 - AlarmValue Int64 - Timestamp xproto.Timestamp - State byte - // padding: 3 bytes +func NewFenceId(c *xgb.Conn) (Fence, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fence(id), nil } -// 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 +type Int64 struct { + Hi int32 + Lo uint32 +} - v.Kind = buf[b] - b += 1 +// Int64Read reads a byte slice into a Int64 value. +func Int64Read(buf []byte, v *Int64) int { + b := 0 - v.Sequence = xgb.Get16(buf[b:]) + v.Hi = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Lo = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Int64ReadList reads a byte slice into a list of Int64 values. +func Int64ReadList(buf []byte, dest []Int64) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Int64{} + b += Int64Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Int64 value to a byte slice. +func (v Int64) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Hi)) + b += 4 + + xgb.Put32(buf[b:], v.Lo) + b += 4 + + return buf +} + +// Int64ListBytes writes a list of Int64 values to a byte slice. +func Int64ListBytes(buf []byte, list []Int64) 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 Systemcounter struct { + Counter Counter + Resolution Int64 + NameLen uint16 + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// SystemcounterRead reads a byte slice into a Systemcounter value. +func SystemcounterRead(buf []byte, v *Systemcounter) int { + b := 0 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.Resolution = Int64{} + b += Int64Read(buf[b:], &v.Resolution) + + v.NameLen = xgb.Get16(buf[b:]) b += 2 - v.Alarm = Alarm(xgb.Get32(buf[b:])) + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b +} + +// SystemcounterReadList reads a byte slice into a list of Systemcounter values. +func SystemcounterReadList(buf []byte, dest []Systemcounter) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Systemcounter{} + b += SystemcounterRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Systemcounter value to a byte slice. +func (v Systemcounter) Bytes() []byte { + buf := make([]byte, (14 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Counter)) b += 4 - v.CounterValue = Int64{} - b += Int64Read(buf[b:], &v.CounterValue) + { + structBytes := v.Resolution.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put16(buf[b:], v.NameLen) + b += 2 + + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) + + return buf +} + +// SystemcounterListBytes writes a list of Systemcounter values to a byte slice. +func SystemcounterListBytes(buf []byte, list []Systemcounter) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// SystemcounterListSize computes the size (bytes) of a list of Systemcounter values. +func SystemcounterListSize(list []Systemcounter) int { + size := 0 + for _, item := range list { + size += (14 + xgb.Pad((int(item.NameLen) * 1))) + } + return size +} + +const ( + TesttypePositiveTransition = 0 + TesttypeNegativeTransition = 1 + TesttypePositiveComparison = 2 + TesttypeNegativeComparison = 3 +) + +type Trigger struct { + Counter Counter + WaitType uint32 + WaitValue Int64 + TestType uint32 +} + +// TriggerRead reads a byte slice into a Trigger value. +func TriggerRead(buf []byte, v *Trigger) int { + b := 0 - v.AlarmValue = Int64{} - b += Int64Read(buf[b:], &v.AlarmValue) + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.WaitType = xgb.Get32(buf[b:]) b += 4 - v.State = buf[b] - b += 1 + v.WaitValue = Int64{} + b += Int64Read(buf[b:], &v.WaitValue) - b += 3 // padding + v.TestType = xgb.Get32(buf[b:]) + b += 4 - return v + return b } -// Bytes writes a AlarmNotifyEvent value to a byte slice. -func (v AlarmNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// TriggerReadList reads a byte slice into a list of Trigger values. +func TriggerReadList(buf []byte, dest []Trigger) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Trigger{} + b += TriggerRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Kind - b += 1 - - b += 2 // skip sequence number +// Bytes writes a Trigger value to a byte slice. +func (v Trigger) Bytes() []byte { + buf := make([]byte, 20) + b := 0 - xgb.Put32(buf[b:], uint32(v.Alarm)) + xgb.Put32(buf[b:], uint32(v.Counter)) b += 4 - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + xgb.Put32(buf[b:], v.WaitType) + b += 4 { - structBytes := v.AlarmValue.Bytes() + structBytes := v.WaitValue.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } - xgb.Put32(buf[b:], uint32(v.Timestamp)) + xgb.Put32(buf[b:], v.TestType) 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 +// TriggerListBytes writes a list of Trigger values to a byte slice. +func TriggerListBytes(buf []byte, list []Trigger) 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 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, ", ") + "}" -} +const ( + ValuetypeAbsolute = 0 + ValuetypeRelative = 1 +) -func init() { - xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew +type Waitcondition struct { + Trigger Trigger + EventThreshold Int64 } -// BadCounter is the error number for a BadCounter. -const BadCounter = 0 +// WaitconditionRead reads a byte slice into a Waitcondition value. +func WaitconditionRead(buf []byte, v *Waitcondition) int { + b := 0 -type CounterError struct { - Sequence uint16 - NiceName string - BadCounter uint32 - MinorOpcode uint16 - MajorOpcode byte -} + v.Trigger = Trigger{} + b += TriggerRead(buf[b:], &v.Trigger) -// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. -func CounterErrorNew(buf []byte) xgb.Error { - v := CounterError{} - v.NiceName = "Counter" + v.EventThreshold = Int64{} + b += Int64Read(buf[b:], &v.EventThreshold) - b := 1 // skip error determinant - b += 1 // don't read error number + return b +} - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// WaitconditionReadList reads a byte slice into a list of Waitcondition values. +func WaitconditionReadList(buf []byte, dest []Waitcondition) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Waitcondition{} + b += WaitconditionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - v.BadCounter = xgb.Get32(buf[b:]) - b += 4 +// Bytes writes a Waitcondition value to a byte slice. +func (v Waitcondition) Bytes() []byte { + buf := make([]byte, 28) + b := 0 - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 + { + structBytes := v.Trigger.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - v.MajorOpcode = buf[b] - b += 1 + { + structBytes := v.EventThreshold.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - 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 +// WaitconditionListBytes writes a list of Waitcondition values to a byte slice. +func WaitconditionListBytes(buf []byte, list []Waitcondition) 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 BadCounter error. If no bad value exists, 0 is returned. -func (err CounterError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Bool' -// Error returns a rudimentary string representation of the BadCounter error. +// Skipping definition for base type 'Byte' -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, ", ") + "}" -} +// Skipping definition for base type 'Card8' -func init() { - xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew -} +// Skipping definition for base type 'Char' -// BadAlarm is the error number for a BadAlarm. -const BadAlarm = 1 +// Skipping definition for base type 'Void' -type AlarmError struct { - Sequence uint16 - NiceName string - BadAlarm uint32 - MinorOpcode uint16 - MajorOpcode byte -} +// Skipping definition for base type 'Double' -// 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 'Float' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Int16' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int32' - v.BadAlarm = xgb.Get32(buf[b:]) - b += 4 +// Skipping definition for base type 'Int8' - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card16' - v.MajorOpcode = buf[b] - b += 1 +// Skipping definition for base type 'Card32' - return v +// AwaitCookie is a cookie used only for Await requests. +type AwaitCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the BadAlarm error. -// This is mostly used internally. -func (err AlarmError) SequenceId() uint16 { - return err.Sequence +// 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.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{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 { + 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} +} + +// Check returns an error if one occurred 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() } -// 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 -} +// 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) + + buf[b] = c.Extensions["SYNC"] + b += 1 -// Error returns a rudimentary string representation of the BadAlarm error. + buf[b] = 7 // request opcode + b += 1 -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.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -func init() { - xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew + b += WaitconditionListBytes(buf[b:], WaitList) + + return buf } -// InitializeCookie is a cookie used only for Initialize requests. -type InitializeCookie struct { +// AwaitFenceCookie is a cookie used only for AwaitFence requests. +type AwaitFenceCookie 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 { +// 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 'Initialize' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'AwaitFence' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} } -// 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 { +// 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 'Initialize' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + panic("Cannot issue request 'AwaitFence' 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} + cookie := c.NewCookie(true, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{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 +// Check returns an error if one occurred 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() } -// 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 -} +// 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) -// initializeReply reads a byte slice into a InitializeReply value. -func initializeReply(buf []byte) *InitializeReply { - v := new(InitializeReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["SYNC"] + b += 1 - b += 1 // padding + 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 - b += 4 + for i := 0; i < int(len(FenceList)); i++ { + xgb.Put32(buf[b:], uint32(FenceList[i])) + b += 4 + } + b = xgb.Pad(b) - v.MajorVersion = buf[b] - b += 1 + return buf +} - v.MinorVersion = buf[b] - b += 1 +// ChangeAlarmCookie is a cookie used only for ChangeAlarm requests. +type ChangeAlarmCookie struct { + *xgb.Cookie +} - b += 22 // padding +// 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} +} - return v +// 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} } -// 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 +// Check returns an error if one occurred 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() +} + +// 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) buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = 0 // 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 - buf[b] = DesiredMajorVersion - b += 1 + xgb.Put32(buf[b:], uint32(Id)) + b += 4 - buf[b] = DesiredMinorVersion - 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) return buf } -// ListSystemCountersCookie is a cookie used only for ListSystemCounters requests. -type ListSystemCountersCookie struct { +// ChangeCounterCookie is a cookie used only for ChangeCounter requests. +type ChangeCounterCookie 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 { +// ChangeCounter 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 { 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 'ChangeCounter' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} } -// 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 { +// 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 'ListSystemCounters' 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(listSystemCountersRequest(c), cookie) - return ListSystemCountersCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{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) +// Check returns an error if one occurred 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() } -// 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 -} +// 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) -// listSystemCountersReply reads a byte slice into a ListSystemCountersReply value. -func listSystemCountersReply(buf []byte) *ListSystemCountersReply { - v := new(ListSystemCountersReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["SYNC"] + 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(Counter)) b += 4 - v.CountersLen = xgb.Get32(buf[b:]) - b += 4 + { + structBytes := Amount.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// CreateAlarmCookie is a cookie used only for CreateAlarm requests. +type CreateAlarmCookie struct { + *xgb.Cookie +} - b += 20 // padding +// 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 { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'CreateAlarm' 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} +} - v.Counters = make([]Systemcounter, v.CountersLen) - b += SystemcounterReadList(buf[b:], v.Counters) +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return CreateAlarmCookie{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 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) +} + +// 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 } -// 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) - - 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,110 +192,73 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.DriMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.DriMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.DriMinorPatch = xgb.Get32(buf[b:]) + v.Authenticated = xgb.Get32(buf[b:]) b += 4 return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for AuthConnection +// authConnectionRequest writes a AuthConnection request to a byte slice. +func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Magic) + b += 4 + return buf } -// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. -type QueryDirectRenderingCapableCookie struct { +// CloseConnectionCookie is a cookie used only for CloseConnection requests. +type CloseConnectionCookie struct { *xgb.Cookie } -// QueryDirectRenderingCapable sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply() -func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) - return QueryDirectRenderingCapableCookie{cookie} -} - -// QueryDirectRenderingCapableUnchecked sends an unchecked request. +// CloseConnection sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { +func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) - return QueryDirectRenderingCapableCookie{cookie} -} - -// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. -type QueryDirectRenderingCapableReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - IsCapable bool + cookie := c.NewCookie(false, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} } -// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request. -func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// CloseConnectionChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseConnectionCookie.Check() +func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - return queryDirectRenderingCapableReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} } -// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. -func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { - v := new(QueryDirectRenderingCapableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.IsCapable = true - } else { - v.IsCapable = false - } - b += 1 - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CloseConnectionCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryDirectRenderingCapable -// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice. -func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { +// Write request to wire for CloseConnection +// closeConnectionRequest writes a CloseConnection request to a byte slice. +func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -305,7 +266,7 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -317,47 +278,43 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// OpenConnectionCookie is a cookie used only for OpenConnection requests. -type OpenConnectionCookie struct { +// CreateContextCookie is a cookie used only for CreateContext requests. +type CreateContextCookie struct { *xgb.Cookie } -// OpenConnection sends a checked request. -// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply() -func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { +// CreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() +func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(openConnectionRequest(c, Screen), cookie) - return OpenConnectionCookie{cookie} + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} } -// OpenConnectionUnchecked sends an unchecked request. +// CreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { +func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(openConnectionRequest(c, Screen), cookie) - return OpenConnectionCookie{cookie} + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} } -// OpenConnectionReply represents the data returned from a OpenConnection request. -type OpenConnectionReply struct { +// CreateContextReply represents the data returned from a CreateContext request. +type CreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - SareaHandleLow uint32 - SareaHandleHigh uint32 - BusIdLen uint32 - // padding: 12 bytes - BusId string // size: xgb.Pad((int(BusIdLen) * 1)) + HwContext uint32 } -// Reply blocks and returns the reply data for a OpenConnection request. -func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { +// Reply blocks and returns the reply data for a CreateContext request. +func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -365,12 +322,12 @@ func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { if buf == nil { return nil, nil } - return openConnectionReply(buf), nil + return createContextReply(buf), nil } -// openConnectionReply reads a byte slice into a OpenConnectionReply value. -func openConnectionReply(buf []byte) *OpenConnectionReply { - v := new(OpenConnectionReply) +// createContextReply reads a byte slice into a CreateContextReply value. +func createContextReply(buf []byte) *CreateContextReply { + v := new(CreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -381,38 +338,23 @@ func openConnectionReply(buf []byte) *OpenConnectionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.SareaHandleLow = xgb.Get32(buf[b:]) - b += 4 - - v.SareaHandleHigh = xgb.Get32(buf[b:]) + v.HwContext = xgb.Get32(buf[b:]) b += 4 - v.BusIdLen = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - { - byteString := make([]byte, v.BusIdLen) - copy(byteString[:v.BusIdLen], buf[b:]) - v.BusId = string(byteString) - b += xgb.Pad(int(v.BusIdLen)) - } - return v } -// Write request to wire for OpenConnection -// openConnectionRequest writes a OpenConnection request to a byte slice. -func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 +// Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. +func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -421,106 +363,52 @@ func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - return buf -} - -// CloseConnectionCookie is a cookie used only for CloseConnection requests. -type CloseConnectionCookie struct { - *xgb.Cookie -} - -// CloseConnection sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(closeConnectionRequest(c, Screen), cookie) - return CloseConnectionCookie{cookie} -} - -// CloseConnectionChecked sends a checked request. -// If an error occurs, it can be retrieved using CloseConnectionCookie.Check() -func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(closeConnectionRequest(c, Screen), cookie) - return CloseConnectionCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CloseConnectionCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CloseConnection -// closeConnectionRequest writes a CloseConnection request to a byte slice. -func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + xgb.Put32(buf[b:], Visual) + b += 4 - xgb.Put32(buf[b:], Screen) + xgb.Put32(buf[b:], Context) b += 4 return buf } -// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests. -type GetClientDriverNameCookie struct { +// CreateDrawableCookie is a cookie used only for CreateDrawable requests. +type CreateDrawableCookie struct { *xgb.Cookie } -// GetClientDriverName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply() -func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { +// CreateDrawable sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply() +func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) - return GetClientDriverNameCookie{cookie} + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} } -// GetClientDriverNameUnchecked sends an unchecked request. +// CreateDrawableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { +func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) - return GetClientDriverNameCookie{cookie} + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} } -// GetClientDriverNameReply represents the data returned from a GetClientDriverName request. -type GetClientDriverNameReply struct { +// CreateDrawableReply represents the data returned from a CreateDrawable request. +type CreateDrawableReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ClientDriverMajorVersion uint32 - ClientDriverMinorVersion uint32 - ClientDriverPatchVersion uint32 - ClientDriverNameLen uint32 - // padding: 8 bytes - ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) + HwDrawableHandle uint32 } -// Reply blocks and returns the reply data for a GetClientDriverName request. -func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { +// Reply blocks and returns the reply data for a CreateDrawable request. +func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -528,12 +416,12 @@ func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) if buf == nil { return nil, nil } - return getClientDriverNameReply(buf), nil + return createDrawableReply(buf), nil } -// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value. -func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { - v := new(GetClientDriverNameReply) +// createDrawableReply reads a byte slice into a CreateDrawableReply value. +func createDrawableReply(buf []byte) *CreateDrawableReply { + v := new(CreateDrawableReply) b := 1 // skip reply determinant b += 1 // padding @@ -544,41 +432,23 @@ func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ClientDriverMajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) - b += 4 - - v.ClientDriverNameLen = xgb.Get32(buf[b:]) + v.HwDrawableHandle = xgb.Get32(buf[b:]) b += 4 - b += 8 // padding - - { - byteString := make([]byte, v.ClientDriverNameLen) - copy(byteString[:v.ClientDriverNameLen], buf[b:]) - v.ClientDriverName = string(byteString) - b += xgb.Pad(int(v.ClientDriverNameLen)) - } - return v } -// Write request to wire for GetClientDriverName -// getClientDriverNameRequest writes a GetClientDriverName request to a byte slice. -func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 +// Write request to wire for CreateDrawable +// createDrawableRequest writes a CreateDrawable request to a byte slice. +func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -587,86 +457,56 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], Drawable) + b += 4 + return buf } -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { *xgb.Cookie } -// CreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() -func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) - return CreateContextCookie{cookie} -} - -// CreateContextUnchecked sends an unchecked request. +// DestroyContext sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { +func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) - return CreateContextCookie{cookie} -} - -// CreateContextReply represents the data returned from a CreateContext request. -type CreateContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - HwContext uint32 + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} } -// Reply blocks and returns the reply data for a CreateContext request. -func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyContextCookie.Check() +func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - return createContextReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} } -// createContextReply reads a byte slice into a CreateContextReply value. -func createContextReply(buf []byte) *CreateContextReply { - v := new(CreateContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.HwContext = xgb.Get32(buf[b:]) - b += 4 - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for CreateContext -// createContextRequest writes a CreateContext request to a byte slice. -func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { - size := 16 +// Write request to wire for DestroyContext +// destroyContextRequest writes a DestroyContext request to a byte slice. +func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -675,51 +515,48 @@ func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uin xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Visual) - b += 4 - xgb.Put32(buf[b:], Context) b += 4 return buf } -// DestroyContextCookie is a cookie used only for DestroyContext requests. -type DestroyContextCookie struct { +// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. +type DestroyDrawableCookie struct { *xgb.Cookie } -// DestroyContext sends an unchecked request. +// DestroyDrawable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { +func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) - return DestroyContextCookie{cookie} + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} } -// DestroyContextChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyContextCookie.Check() -func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { +// DestroyDrawableChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() +func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) - return DestroyContextCookie{cookie} + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyContextCookie) Check() error { +func (cook DestroyDrawableCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyContext -// destroyContextRequest writes a DestroyContext request to a byte slice. -func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { +// Write request to wire for DestroyDrawable +// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. +func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -727,7 +564,7 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -736,49 +573,54 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Context) + xgb.Put32(buf[b:], Drawable) b += 4 return buf } -// CreateDrawableCookie is a cookie used only for CreateDrawable requests. -type CreateDrawableCookie struct { +// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests. +type GetClientDriverNameCookie struct { *xgb.Cookie } -// CreateDrawable sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply() -func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { +// GetClientDriverName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply() +func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) - return CreateDrawableCookie{cookie} + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} } -// CreateDrawableUnchecked sends an unchecked request. +// GetClientDriverNameUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { +func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) - return CreateDrawableCookie{cookie} + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} } -// CreateDrawableReply represents the data returned from a CreateDrawable request. -type CreateDrawableReply struct { +// GetClientDriverNameReply represents the data returned from a GetClientDriverName request. +type GetClientDriverNameReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - HwDrawableHandle uint32 + ClientDriverMajorVersion uint32 + ClientDriverMinorVersion uint32 + ClientDriverPatchVersion uint32 + ClientDriverNameLen uint32 + // padding: 8 bytes + ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) } -// Reply blocks and returns the reply data for a CreateDrawable request. -func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { +// Reply blocks and returns the reply data for a GetClientDriverName request. +func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -786,12 +628,12 @@ func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { if buf == nil { return nil, nil } - return createDrawableReply(buf), nil + return getClientDriverNameReply(buf), nil } -// createDrawableReply reads a byte slice into a CreateDrawableReply value. -func createDrawableReply(buf []byte) *CreateDrawableReply { - v := new(CreateDrawableReply) +// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value. +func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { + v := new(GetClientDriverNameReply) b := 1 // skip reply determinant b += 1 // padding @@ -802,23 +644,41 @@ func createDrawableReply(buf []byte) *CreateDrawableReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.HwDrawableHandle = xgb.Get32(buf[b:]) + v.ClientDriverMajorVersion = xgb.Get32(buf[b:]) b += 4 + v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverNameLen = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + { + byteString := make([]byte, v.ClientDriverNameLen) + copy(byteString[:v.ClientDriverNameLen], buf[b:]) + v.ClientDriverName = string(byteString) + b += xgb.Pad(int(v.ClientDriverNameLen)) + } + return v } -// Write request to wire for CreateDrawable -// createDrawableRequest writes a CreateDrawable request to a byte slice. -func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { - size := 12 +// Write request to wire for GetClientDriverName +// getClientDriverNameRequest writes a GetClientDriverName request to a byte slice. +func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -827,56 +687,114 @@ func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Drawable) - b += 4 - return buf } -// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. -type DestroyDrawableCookie struct { +// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. +type GetDeviceInfoCookie struct { *xgb.Cookie } -// DestroyDrawable sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { +// GetDeviceInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply() +func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) - return DestroyDrawableCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} } -// DestroyDrawableChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() -func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { +// GetDeviceInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) - return DestroyDrawableCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyDrawableCookie) Check() error { - return cook.Cookie.Check() +// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request. +type GetDeviceInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + FramebufferHandleLow uint32 + FramebufferHandleHigh uint32 + FramebufferOriginOffset uint32 + FramebufferSize uint32 + FramebufferStride uint32 + DevicePrivateSize uint32 + DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) +} + +// Reply blocks and returns the reply data for a GetDeviceInfo request. +func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceInfoReply(buf), nil +} + +// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value. +func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { + v := new(GetDeviceInfoReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.FramebufferHandleLow = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferHandleHigh = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferOriginOffset = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferSize = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferStride = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivateSize = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivate = make([]uint32, v.DevicePrivateSize) + for i := 0; i < int(v.DevicePrivateSize); i++ { + v.DevicePrivate[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v } -// Write request to wire for DestroyDrawable -// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. -func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { - size := 12 +// Write request to wire for GetDeviceInfo +// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice. +func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -885,9 +803,6 @@ func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Drawable) - b += 4 - return buf } @@ -1026,49 +941,47 @@ func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte return buf } -// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. -type GetDeviceInfoCookie struct { +// OpenConnectionCookie is a cookie used only for OpenConnection requests. +type OpenConnectionCookie struct { *xgb.Cookie } -// GetDeviceInfo sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply() -func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { +// OpenConnection sends a checked request. +// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply() +func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) - return GetDeviceInfoCookie{cookie} + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} } -// GetDeviceInfoUnchecked sends an unchecked request. +// OpenConnectionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { +func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) - return GetDeviceInfoCookie{cookie} + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} } -// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request. -type GetDeviceInfoReply struct { +// OpenConnectionReply represents the data returned from a OpenConnection request. +type OpenConnectionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - FramebufferHandleLow uint32 - FramebufferHandleHigh uint32 - FramebufferOriginOffset uint32 - FramebufferSize uint32 - FramebufferStride uint32 - DevicePrivateSize uint32 - DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) + SareaHandleLow uint32 + SareaHandleHigh uint32 + BusIdLen uint32 + // padding: 12 bytes + BusId string // size: xgb.Pad((int(BusIdLen) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceInfo request. -func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { +// Reply blocks and returns the reply data for a OpenConnection request. +func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1076,12 +989,12 @@ func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { if buf == nil { return nil, nil } - return getDeviceInfoReply(buf), nil + return openConnectionReply(buf), nil } -// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value. -func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { - v := new(GetDeviceInfoReply) +// openConnectionReply reads a byte slice into a OpenConnectionReply value. +func openConnectionReply(buf []byte) *OpenConnectionReply { + v := new(OpenConnectionReply) b := 1 // skip reply determinant b += 1 // padding @@ -1092,37 +1005,30 @@ func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.FramebufferHandleLow = xgb.Get32(buf[b:]) - b += 4 - - v.FramebufferHandleHigh = xgb.Get32(buf[b:]) - b += 4 - - v.FramebufferOriginOffset = xgb.Get32(buf[b:]) + v.SareaHandleLow = xgb.Get32(buf[b:]) b += 4 - v.FramebufferSize = xgb.Get32(buf[b:]) + v.SareaHandleHigh = xgb.Get32(buf[b:]) b += 4 - v.FramebufferStride = xgb.Get32(buf[b:]) + v.BusIdLen = xgb.Get32(buf[b:]) b += 4 - v.DevicePrivateSize = xgb.Get32(buf[b:]) - b += 4 + b += 12 // padding - v.DevicePrivate = make([]uint32, v.DevicePrivateSize) - for i := 0; i < int(v.DevicePrivateSize); i++ { - v.DevicePrivate[i] = xgb.Get32(buf[b:]) - b += 4 + { + byteString := make([]byte, v.BusIdLen) + copy(byteString[:v.BusIdLen], buf[b:]) + v.BusId = string(byteString) + b += xgb.Pad(int(v.BusIdLen)) } - b = xgb.Pad(b) return v } -// Write request to wire for GetDeviceInfo -// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice. -func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { +// Write request to wire for OpenConnection +// openConnectionRequest writes a OpenConnection request to a byte slice. +func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1130,7 +1036,7 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1142,43 +1048,43 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// AuthConnectionCookie is a cookie used only for AuthConnection requests. -type AuthConnectionCookie struct { +// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. +type QueryDirectRenderingCapableCookie struct { *xgb.Cookie } -// AuthConnection sends a checked request. -// If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply() -func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { +// QueryDirectRenderingCapable sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply() +func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) - return AuthConnectionCookie{cookie} + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} } -// AuthConnectionUnchecked sends an unchecked request. +// QueryDirectRenderingCapableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { +func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) - return AuthConnectionCookie{cookie} + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} } -// AuthConnectionReply represents the data returned from a AuthConnection request. -type AuthConnectionReply struct { +// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. +type QueryDirectRenderingCapableReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Authenticated uint32 + IsCapable bool } -// Reply blocks and returns the reply data for a AuthConnection request. -func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { +// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request. +func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1186,12 +1092,12 @@ func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { if buf == nil { return nil, nil } - return authConnectionReply(buf), nil + return queryDirectRenderingCapableReply(buf), nil } -// authConnectionReply reads a byte slice into a AuthConnectionReply value. -func authConnectionReply(buf []byte) *AuthConnectionReply { - v := new(AuthConnectionReply) +// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. +func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { + v := new(QueryDirectRenderingCapableReply) b := 1 // skip reply determinant b += 1 // padding @@ -1202,23 +1108,27 @@ func authConnectionReply(buf []byte) *AuthConnectionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Authenticated = xgb.Get32(buf[b:]) - b += 4 + if buf[b] == 1 { + v.IsCapable = true + } else { + v.IsCapable = false + } + b += 1 return v } -// Write request to wire for AuthConnection -// authConnectionRequest writes a AuthConnection request to a byte slice. -func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { - size := 12 +// Write request to wire for QueryDirectRenderingCapable +// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice. +func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1227,8 +1137,98 @@ func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Magic) + return buf +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + DriMajorVersion uint16 + DriMinorVersion uint16 + DriMinorPatch uint32 +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.DriMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorPatch = xgb.Get32(buf[b:]) b += 4 + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + return buf } 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,52 +276,209 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][4] = ExtensionDisabledErrorNew } -// BadClientNotLocal is the error number for a BadClientNotLocal. -const BadClientNotLocal = 5 - -type ClientNotLocalError 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" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +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 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 +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 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,44 +525,302 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][6] = ZoomLockedErrorNew } -// 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' + +// AddModeLineCookie is a cookie used only for AddModeLine requests. +type AddModeLineCookie 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 { +// 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 'QueryVersion' 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, 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} +} + +// 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 'AddModeLine' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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 + + 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 + + xgb.Put32(buf[b:], uint32(AfterDotclock)) + b += 4 + + xgb.Put16(buf[b:], AfterHdisplay) + b += 2 + + xgb.Put16(buf[b:], AfterHsyncstart) + b += 2 + + xgb.Put16(buf[b:], AfterHsyncend) + b += 2 + + xgb.Put16(buf[b:], AfterHtotal) + b += 2 + + xgb.Put16(buf[b:], AfterHskew) + b += 2 + + 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 +} + +// DeleteModeLineCookie is a cookie used only for DeleteModeLine requests. +type DeleteModeLineCookie 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 { + 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.") + } + 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} +} + +// 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 'DeleteModeLine' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], 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 +} + +// GetAllModeLinesCookie is a cookie used only for GetAllModeLines requests. +type GetAllModeLinesCookie 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 { + 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.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// GetAllModeLinesUnchecked 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 GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { 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.") + panic("Cannot issue request 'GetAllModeLines' 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} + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// 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 - MajorVersion uint16 - MinorVersion uint16 + Modecount uint32 + // padding: 20 bytes + Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) } -// 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 GetAllModeLines request. +func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -594,12 +828,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return getAllModeLinesReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// 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 @@ -610,85 +844,82 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get16(buf[b:]) - b += 2 + v.Modecount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 + v.Modeinfo = make([]ModeInfo, v.Modecount) + b += ModeInfoReadList(buf[b:], v.Modeinfo) 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 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) buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 0 // 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:], Screen) + b += 2 + + b += 2 // padding + return buf } -// GetModeLineCookie is a cookie used only for GetModeLine requests. -type GetModeLineCookie struct { +// GetDotClocksCookie is a cookie used only for GetDotClocks requests. +type GetDotClocksCookie 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 { +// 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 'GetModeLine' 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(getModeLineRequest(c, Screen), cookie) - return GetModeLineCookie{cookie} + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} } -// GetModeLineUnchecked 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 GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { +func GetDotClocksUnchecked(c *xgb.Conn, Screen uint16) GetDotClocksCookie { 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 'GetDotClocks' 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} + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} } -// GetModeLineReply represents the data returned from a GetModeLine request. -type GetModeLineReply 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 - 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 + Flags uint32 + Clocks uint32 + Maxclocks uint32 // padding: 12 bytes - Privsize uint32 - Private []byte // size: xgb.Pad((int(Privsize) * 1)) + Clock []uint32 // size: xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) } -// Reply blocks and returns the reply data for a GetModeLine request. -func (cook GetModeLineCookie) Reply() (*GetModeLineReply, 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 @@ -696,12 +927,12 @@ func (cook GetModeLineCookie) Reply() (*GetModeLineReply, error) { if buf == nil { return nil, nil } - return getModeLineReply(buf), nil + return getDotClocksReply(buf), nil } -// getModeLineReply reads a byte slice into a GetModeLineReply value. -func getModeLineReply(buf []byte) *GetModeLineReply { - v := new(GetModeLineReply) +// 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 @@ -712,56 +943,30 @@ func getModeLineReply(buf []byte) *GetModeLineReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Dotclock = Dotclock(xgb.Get32(buf[b:])) + v.Flags = 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.Get16(buf[b:]) - b += 2 - - 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 += 2 // padding + v.Clocks = xgb.Get32(buf[b:]) + b += 4 - v.Flags = xgb.Get32(buf[b:]) + v.Maxclocks = xgb.Get32(buf[b:]) b += 4 b += 12 // padding - v.Privsize = xgb.Get32(buf[b:]) - b += 4 - - v.Private = make([]byte, v.Privsize) - copy(v.Private[:v.Privsize], buf[b:]) - b += xgb.Pad(int(v.Privsize)) + 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) 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 { +// 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) @@ -769,7 +974,7 @@ func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -783,145 +988,94 @@ func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// ModModeLineCookie is a cookie used only for ModModeLine requests. -type ModModeLineCookie struct { +// GetGammaCookie is a cookie used only for GetGamma requests. +type GetGammaCookie 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 { +// 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 'ModModeLine' 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(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return ModModeLineCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRequest(c, Screen), cookie) + return GetGammaCookie{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 { +// 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 'ModModeLine' 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(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return ModModeLineCookie{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 ModModeLineCookie) 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 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 +// 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 +} - xgb.Put16(buf[b:], Vsyncstart) - b += 2 +// getGammaReply reads a byte slice into a GetGammaReply value. +func getGammaReply(buf []byte) *GetGammaReply { + v := new(GetGammaReply) + 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) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) - - return buf -} - -// SwitchModeCookie is a cookie used only for SwitchMode requests. -type SwitchModeCookie struct { - *xgb.Cookie -} + v.Red = xgb.Get32(buf[b:]) + b += 4 -// 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 { - 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) - return SwitchModeCookie{cookie} -} + v.Green = xgb.Get32(buf[b:]) + b += 4 -// 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 'SwitchMode' 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} -} + v.Blue = xgb.Get32(buf[b:]) + b += 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 SwitchModeCookie) Check() error { - return cook.Cookie.Check() + b += 12 // padding + + return v } -// 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 +// 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] = 3 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -930,58 +1084,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 += 26 // padding return buf } -// GetMonitorCookie is a cookie used only for GetMonitor requests. -type GetMonitorCookie struct { +// GetGammaRampCookie is a cookie used only for GetGammaRamp requests. +type GetGammaRampCookie 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 { +// 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 'GetMonitor' 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(getMonitorRequest(c, Screen), cookie) - return GetMonitorCookie{cookie} + c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} } -// GetMonitorUnchecked 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 GetMonitorUnchecked(c *xgb.Conn, Screen uint16) GetMonitorCookie { +func GetGammaRampUnchecked(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { 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 'GetGammaRamp' 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(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} } -// GetMonitorReply represents the data returned from a GetMonitor request. -type GetMonitorReply 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 - 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)) + 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 GetMonitor request. -func (cook GetMonitorCookie) Reply() (*GetMonitorReply, 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 @@ -989,12 +1137,12 @@ func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { if buf == nil { return nil, nil } - return getMonitorReply(buf), nil + return getGammaRampReply(buf), nil } -// getMonitorReply reads a byte slice into a GetMonitorReply value. -func getMonitorReply(buf []byte) *GetMonitorReply { - v := new(GetMonitorReply) +// 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 @@ -1005,115 +1153,38 @@ 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.NumVsync = buf[b] - b += 1 + v.Size = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding + b += 22 // padding - v.Hsync = make([]Syncrange, v.NumHsync) - for i := 0; i < int(v.NumHsync); i++ { - v.Hsync[i] = Syncrange(xgb.Get32(buf[b:])) - b += 4 + 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.Vsync = make([]Syncrange, v.NumVsync) - for i := 0; i < int(v.NumVsync); i++ { - v.Vsync[i] = Syncrange(xgb.Get32(buf[b:])) - b += 4 + 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) - { - 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)) + 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 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) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - 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.Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// LockModeSwitchCookie is a cookie used only for LockModeSwitch requests. -type LockModeSwitchCookie 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 { - 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) - return LockModeSwitchCookie{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 { - 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.") - } - cookie := c.NewCookie(true, false) - 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 LockModeSwitchCookie) Check() error { - return cook.Cookie.Check() -} - -// 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 { +// 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) @@ -1121,7 +1192,7 @@ func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1130,51 +1201,50 @@ func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { xgb.Put16(buf[b:], Screen) b += 2 - xgb.Put16(buf[b:], Lock) + xgb.Put16(buf[b:], Size) b += 2 return buf } -// GetAllModeLinesCookie is a cookie used only for GetAllModeLines requests. -type GetAllModeLinesCookie struct { +// GetGammaRampSizeCookie is a cookie used only for GetGammaRampSize requests. +type GetGammaRampSizeCookie 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 { +// 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 'GetAllModeLines' 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, true) - c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) - return GetAllModeLinesCookie{cookie} + c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{cookie} } -// GetAllModeLinesUnchecked sends an unchecked request. +// GetGammaRampSizeUnchecked 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 GetGammaRampSizeUnchecked(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { 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 'GetGammaRampSize' 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(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{cookie} } -// GetAllModeLinesReply represents the data returned from a GetAllModeLines request. -type GetAllModeLinesReply struct { +// 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 - Modecount uint32 - // padding: 20 bytes - Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) + Size uint16 + // padding: 22 bytes } -// 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 GetGammaRampSize request. +func (cook GetGammaRampSizeCookie) Reply() (*GetGammaRampSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1182,12 +1252,12 @@ func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { if buf == nil { return nil, nil } - return getAllModeLinesReply(buf), nil + return getGammaRampSizeReply(buf), nil } -// getAllModeLinesReply reads a byte slice into a GetAllModeLinesReply value. -func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { - v := new(GetAllModeLinesReply) +// getGammaRampSizeReply reads a byte slice into a GetGammaRampSizeReply value. +func getGammaRampSizeReply(buf []byte) *GetGammaRampSizeReply { + v := new(GetGammaRampSizeReply) b := 1 // skip reply determinant b += 1 // padding @@ -1198,20 +1268,17 @@ func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Modecount = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding + v.Size = xgb.Get16(buf[b:]) + b += 2 - v.Modeinfo = make([]ModeInfo, v.Modecount) - b += ModeInfoReadList(buf[b:], v.Modeinfo) + b += 22 // padding 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 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) @@ -1219,7 +1286,7 @@ func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1233,277 +1300,197 @@ func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// AddModeLineCookie is a cookie used only for AddModeLine requests. -type AddModeLineCookie struct { +// GetModeLineCookie is a cookie used only for GetModeLine requests. +type GetModeLineCookie 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 { +// 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 'AddModeLine' 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(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(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{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 { +// 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 'AddModeLine' 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(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(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 AddModeLineCookie) 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 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) +// 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] = 7 // 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) - b += 4 - - xgb.Put32(buf[b:], uint32(AfterDotclock)) - b += 4 - - xgb.Put16(buf[b:], AfterHdisplay) - b += 2 - - xgb.Put16(buf[b:], AfterHsyncstart) - b += 2 - - xgb.Put16(buf[b:], AfterHsyncend) - b += 2 - - xgb.Put16(buf[b:], AfterHtotal) - b += 2 - - xgb.Put16(buf[b:], AfterHskew) - b += 2 - - 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) + v.Privsize = xgb.Get32(buf[b:]) 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 { - *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 { - 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.") - } - 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} -} - -// 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 'DeleteModeLine' 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} -} + v.Private = make([]byte, v.Privsize) + copy(v.Private[:v.Privsize], buf[b:]) + b += xgb.Pad(int(v.Privsize)) -// Check returns an error if one occurred 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() + return v } -// 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)))) +// 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] = 8 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Screen) - b += 4 - - xgb.Put32(buf[b:], 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 + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 - xgb.Put16(buf[b:], Vsyncstart) - b += 2 + buf[b] = 1 // 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 } -// 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,173 +1514,168 @@ 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) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Screen) - b += 4 - - xgb.Put32(buf[b:], uint32(Dotclock)) - b += 4 - - xgb.Put16(buf[b:], Hdisplay) - b += 2 +// 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 +} - xgb.Put16(buf[b:], Hsyncstart) - b += 2 +// getPermissionsReply reads a byte slice into a GetPermissionsReply value. +func getPermissionsReply(buf []byte) *GetPermissionsReply { + v := new(GetPermissionsReply) + b := 1 // skip reply determinant - xgb.Put16(buf[b:], Hsyncend) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], Htotal) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Hskew) - b += 2 + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - xgb.Put16(buf[b:], Vdisplay) - b += 2 + v.Permissions = xgb.Get32(buf[b:]) + b += 4 - xgb.Put16(buf[b:], Vsyncstart) - b += 2 + b += 20 // padding - xgb.Put16(buf[b:], Vsyncend) - b += 2 + return v +} - xgb.Put16(buf[b:], Vtotal) - 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) - b += 2 // padding + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 - xgb.Put32(buf[b:], Flags) - b += 4 + buf[b] = 20 // request opcode + b += 1 - b += 12 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - xgb.Put32(buf[b:], Privsize) - b += 4 + xgb.Put16(buf[b:], Screen) + b += 2 - copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) + b += 2 // padding 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 +// Skipping definition for base type 'Bool' -type CursorNotifyEvent struct { - Sequence uint16 - Subtype byte - Window xproto.Window - CursorSerial uint32 - Timestamp xproto.Timestamp - Name xproto.Atom - // padding: 12 bytes -} +// Skipping definition for base type 'Byte' -// 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 +// Skipping definition for base type 'Card8' - v.Subtype = 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.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Double' - v.CursorSerial = xgb.Get32(buf[b:]) - b += 4 +// Skipping definition for base type 'Float' - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Int16' - v.Name = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Int32' - b += 12 // padding +// Skipping definition for base type 'Int8' - return v -} +// Skipping definition for base type 'Card16' -// 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 'Card32' - // write event number - buf[b] = 1 - b += 1 +// ChangeCursorCookie is a cookie used only for ChangeCursor requests. +type ChangeCursorCookie struct { + *xgb.Cookie +} - buf[b] = v.Subtype - b += 1 +// 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} +} - 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, ", ") + "}" +// 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,251 +546,70 @@ 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 { +// CopyRegionCookie is a cookie used only for CopyRegion requests. +type CopyRegionCookie struct { *xgb.Cookie } -// SelectSelectionInput 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 SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { +func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectSelectionInput' 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(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) - return SelectSelectionInputCookie{cookie} + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{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 { +// 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 'SelectSelectionInput' 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(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) - return SelectSelectionInputCookie{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 SelectSelectionInputCookie) Check() error { +func (cook CopyRegionCookie) 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 +// 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) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 2 // 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:], uint32(Selection)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - xgb.Put32(buf[b:], EventMask) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } -// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. -type SelectCursorInputCookie struct { +// CreateRegionCookie is a cookie used only for CreateRegion requests. +type CreateRegionCookie struct { *xgb.Cookie } -// SelectCursorInput 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectCursorInput' 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} -} - -// 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 'SelectCursorInput' 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} -} - -// Check returns an error if one occurred 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 { - 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 { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], 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 - 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] = 4 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// CreateRegionCookie is a cookie used only for CreateRegion requests. -type CreateRegionCookie struct { - *xgb.Cookie -} - -// CreateRegion sends an unchecked request. +// CreateRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { @@ -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,50 +835,50 @@ func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.P return buf } -// DestroyRegionCookie is a cookie used only for DestroyRegion requests. -type DestroyRegionCookie struct { +// CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests. +type CreateRegionFromWindowCookie struct { *xgb.Cookie } -// DestroyRegion sends an unchecked request. +// CreateRegionFromWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyRegion(c *xgb.Conn, Region Region) DestroyRegionCookie { +func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'DestroyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(destroyRegionRequest(c, Region), cookie) - return DestroyRegionCookie{cookie} + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} } -// DestroyRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyRegionCookie.Check() -func DestroyRegionChecked(c *xgb.Conn, Region Region) DestroyRegionCookie { +// 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 'DestroyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(destroyRegionRequest(c, Region), cookie) - return DestroyRegionCookie{cookie} + 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 DestroyRegionCookie) Check() error { +func (cook CreateRegionFromWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyRegion -// destroyRegionRequest writes a DestroyRegion request to a byte slice. -func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { - size := 8 +// 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] = 10 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1108,53 +887,61 @@ func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { 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 } -// SetRegionCookie is a cookie used only for SetRegion requests. -type SetRegionCookie struct { +// DestroyRegionCookie is a cookie used only for DestroyRegion requests. +type DestroyRegionCookie struct { *xgb.Cookie } -// SetRegion sends an unchecked request. +// DestroyRegion 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 DestroyRegion(c *xgb.Conn, Region Region) DestroyRegionCookie { 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 'DestroyRegion' 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(destroyRegionRequest(c, Region), cookie) + return DestroyRegionCookie{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 { +// DestroyRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyRegionCookie.Check() +func DestroyRegionChecked(c *xgb.Conn, Region Region) DestroyRegionCookie { 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 'DestroyRegion' 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(destroyRegionRequest(c, Region), cookie) + return DestroyRegionCookie{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 DestroyRegionCookie) 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 DestroyRegion +// destroyRegionRequest writes a DestroyRegion request to a byte slice. +func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1163,55 +950,53 @@ func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) xgb.Put32(buf[b:], uint32(Region)) b += 4 - b += xproto.RectangleListBytes(buf[b:], Rectangles) - return buf } -// CopyRegionCookie is a cookie used only for CopyRegion requests. -type CopyRegionCookie struct { +// ExpandRegionCookie is a cookie used only for ExpandRegion requests. +type ExpandRegionCookie struct { *xgb.Cookie } -// CopyRegion 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 CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { +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 'CopyRegion' 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(copyRegionRequest(c, Source, Destination), cookie) - return CopyRegionCookie{cookie} + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{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 { +// 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 'CopyRegion' 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(copyRegionRequest(c, Source, Destination), cookie) - return CopyRegionCookie{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 CopyRegionCookie) Check() error { +func (cook ExpandRegionCookie) Check() error { return cook.Cookie.Check() } -// 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 +// 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] = 12 // request opcode + buf[b] = 28 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1223,414 +1008,412 @@ func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { 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 } -// UnionRegionCookie is a cookie used only for UnionRegion requests. -type UnionRegionCookie struct { +// FetchRegionCookie is a cookie used only for FetchRegion requests. +type FetchRegionCookie 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 { +// 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 'UnionRegion' 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(unionRegionRequest(c, Source1, Source2, Destination), cookie) - return UnionRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{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 { +// 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 'UnionRegion' 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(unionRegionRequest(c, Source1, Source2, Destination), cookie) - return UnionRegionCookie{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 UnionRegionCookie) 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 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) +// 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 +} - buf[b] = c.Extensions["XFIXES"] - b += 1 +// fetchRegionReply reads a byte slice into a FetchRegionReply value. +func fetchRegionReply(buf []byte) *FetchRegionReply { + v := new(FetchRegionReply) + b := 1 // skip reply determinant - buf[b] = 13 // 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)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} - -// IntersectRegionCookie is a cookie used only for IntersectRegion requests. -type IntersectRegionCookie struct { - *xgb.Cookie -} + v.Extents = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Extents) -// 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'IntersectRegion' 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} -} + b += 16 // padding -// 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 'IntersectRegion' 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} -} + v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) -// Check returns an error if one occurred 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() + return v } -// 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 +// 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] = 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 - 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(Region)) b += 4 return buf } -// SubtractRegionCookie is a cookie used only for SubtractRegion requests. -type SubtractRegionCookie struct { +// GetCursorImageCookie is a cookie used only for GetCursorImage requests. +type GetCursorImageCookie 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 { +// 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 'SubtractRegion' 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(subtractRegionRequest(c, Source1, Source2, Destination), cookie) - return SubtractRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{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 { +// 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 'SubtractRegion' 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(subtractRegionRequest(c, Source1, Source2, Destination), cookie) - return SubtractRegionCookie{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 SubtractRegionCookie) 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 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) +// 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 +} - buf[b] = c.Extensions["XFIXES"] - b += 1 +// getCursorImageReply reads a byte slice into a GetCursorImageReply value. +func getCursorImageReply(buf []byte) *GetCursorImageReply { + v := new(GetCursorImageReply) + b := 1 // skip reply determinant - buf[b] = 15 // 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)) - b += 4 + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - return buf -} + v.Width = xgb.Get16(buf[b:]) + b += 2 -// InvertRegionCookie is a cookie used only for InvertRegion requests. -type InvertRegionCookie struct { - *xgb.Cookie -} + v.Height = xgb.Get16(buf[b:]) + b += 2 -// InvertRegion 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'InvertRegion' 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} -} + v.Xhot = xgb.Get16(buf[b:]) + b += 2 -// 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 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) - return InvertRegionCookie{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 InvertRegionCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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] = 16 // 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(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 } -// TranslateRegionCookie is a cookie used only for TranslateRegion requests. -type TranslateRegionCookie struct { +// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. +type GetCursorImageAndNameCookie struct { *xgb.Cookie } -// TranslateRegion 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 { +// 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 'TranslateRegion' 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(translateRegionRequest(c, Region, Dx, Dy), cookie) - return TranslateRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{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 { +// 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 'TranslateRegion' 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(translateRegionRequest(c, Region, Dx, Dy), cookie) - return TranslateRegionCookie{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 TranslateRegionCookie) 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 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) +// 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] = 17 // 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(Region)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], uint16(Dx)) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], uint16(Dy)) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - return buf -} + v.Width = xgb.Get16(buf[b:]) + b += 2 -// RegionExtentsCookie is a cookie used only for RegionExtents requests. -type RegionExtentsCookie struct { - *xgb.Cookie -} + v.Height = xgb.Get16(buf[b:]) + b += 2 -// RegionExtents 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + 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 + + b += 2 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) } - cookie := c.NewCookie(false, false) - c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) - return RegionExtentsCookie{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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) - return RegionExtentsCookie{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 RegionExtentsCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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] = 18 // 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(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - return buf } -// FetchRegionCookie is a cookie used only for FetchRegion requests. -type FetchRegionCookie struct { +// GetCursorNameCookie is a cookie used only for GetCursorName requests. +type GetCursorNameCookie 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 { +// 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 'FetchRegion' 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, true) - c.NewRequest(fetchRegionRequest(c, Region), cookie) - return FetchRegionCookie{cookie} + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} } -// FetchRegionUnchecked sends an unchecked request. +// GetCursorNameUnchecked 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 GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { 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 'GetCursorName' 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(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} } -// FetchRegionReply represents the data returned from a FetchRegion request. -type FetchRegionReply struct { +// 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 - Extents xproto.Rectangle - // padding: 16 bytes - Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) + Atom xproto.Atom + Nbytes uint16 + // padding: 18 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) } -// 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 GetCursorName request. +func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1638,12 +1421,12 @@ func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { if buf == nil { return nil, nil } - return fetchRegionReply(buf), nil + return getCursorNameReply(buf), nil } -// fetchRegionReply reads a byte slice into a FetchRegionReply value. -func fetchRegionReply(buf []byte) *FetchRegionReply { - v := new(FetchRegionReply) +// 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 @@ -1654,20 +1437,27 @@ 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.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 - b += 16 // padding + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 - v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) - b += xproto.RectangleReadList(buf[b:], v.Rectangles) + 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 FetchRegion -// fetchRegionRequest writes a FetchRegion request to a byte slice. -func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { +// 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) @@ -1675,318 +1465,237 @@ func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 19 // 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(Region)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 return buf } -// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests. -type SetGCClipRegionCookie struct { +// HideCursorCookie is a cookie used only for HideCursor requests. +type HideCursorCookie struct { *xgb.Cookie } -// SetGCClipRegion 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 SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { +func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { 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 'HideCursor' 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(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{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 { +// 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 'SetGCClipRegion' 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(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) - return SetGCClipRegionCookie{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 SetGCClipRegionCookie) Check() error { +func (cook HideCursorCookie) 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 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] = 20 // 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(Gc)) - b += 4 - - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Window)) 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 { +// IntersectRegionCookie is a cookie used only for IntersectRegion requests. +type IntersectRegionCookie struct { *xgb.Cookie } -// SetWindowShapeRegion 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 SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { +func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { 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 'IntersectRegion' 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(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{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 { +// 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 'SetWindowShapeRegion' 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(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) - return SetWindowShapeRegionCookie{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 SetWindowShapeRegionCookie) Check() error { +func (cook IntersectRegionCookie) 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 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] = 21 // 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(Dest)) + xgb.Put32(buf[b:], uint32(Source1)) 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(Source2)) + b += 4 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } -// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests. -type SetPictureClipRegionCookie struct { +// InvertRegionCookie is a cookie used only for InvertRegion requests. +type InvertRegionCookie struct { *xgb.Cookie } -// SetPictureClipRegion 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 SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { +func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { 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 'InvertRegion' 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(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{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 { +// 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 'SetPictureClipRegion' 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(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) - return SetPictureClipRegionCookie{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 SetPictureClipRegionCookie) Check() error { +func (cook InvertRegionCookie) 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 { - size := 16 +// 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] = 22 // 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(Picture)) - b += 4 - - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - xgb.Put16(buf[b:], uint16(XOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOrigin)) - b += 2 - - return buf -} - -// SetCursorNameCookie is a cookie used only for SetCursorName requests. -type SetCursorNameCookie struct { - *xgb.Cookie -} - -// SetCursorName sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetCursorName(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) - return SetCursorNameCookie{cookie} -} - -// SetCursorNameChecked sends a checked request. -// If an error occurs, it can be retrieved using SetCursorNameCookie.Check() -func SetCursorNameChecked(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + { + structBytes := Bounds.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } - cookie := c.NewCookie(true, false) - c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) - return SetCursorNameCookie{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 SetCursorNameCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetCursorName -// setCursorNameRequest writes a SetCursorName request to a byte slice. -func setCursorNameRequest(c *xgb.Conn, Cursor 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] = 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(Cursor)) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - xgb.Put16(buf[b:], Nbytes) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:Nbytes]) - b += xgb.Pad(int(Nbytes)) - return buf } -// GetCursorNameCookie is a cookie used only for GetCursorName requests. -type GetCursorNameCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie 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 { +// 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 'GetCursorName' 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(getCursorNameRequest(c, Cursor), cookie) - return GetCursorNameCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetCursorNameUnchecked 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 GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { 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 'QueryVersion' 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} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetCursorNameReply represents the data returned from a GetCursorName request. -type GetCursorNameReply 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 - Atom xproto.Atom - Nbytes uint16 - // padding: 18 bytes - Name string // size: xgb.Pad((int(Nbytes) * 1)) + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes } -// Reply blocks and returns the reply data for a GetCursorName request. -func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, 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 @@ -1994,12 +1703,12 @@ func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { if buf == nil { return nil, nil } - return getCursorNameReply(buf), nil + return queryVersionReply(buf), nil } -// getCursorNameReply reads a byte slice into a GetCursorNameReply value. -func getCursorNameReply(buf []byte) *GetCursorNameReply { - v := new(GetCursorNameReply) +// 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 @@ -2010,478 +1719,769 @@ func getCursorNameReply(buf []byte) *GetCursorNameReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Atom = xproto.Atom(xgb.Get32(buf[b:])) + v.MajorVersion = xgb.Get32(buf[b:]) b += 4 - v.Nbytes = xgb.Get16(buf[b:]) - b += 2 - - b += 18 // padding + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Nbytes)) - } + b += 16 // padding 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 +// 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] = 24 // 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(Cursor)) + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) b += 4 return buf } -// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. -type GetCursorImageAndNameCookie struct { +// RegionExtentsCookie is a cookie used only for RegionExtents requests. +type RegionExtentsCookie 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 { +// RegionExtents 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 { 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 'RegionExtents' 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(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{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 { +// 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 'GetCursorImageAndName' 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, true) - c.NewRequest(getCursorImageAndNameRequest(c), cookie) - return GetCursorImageAndNameCookie{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)) + cookie := c.NewCookie(true, false) + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} } -// 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 +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value. -func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { - v := new(GetCursorImageAndNameReply) - b := 1 // skip reply determinant +// 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) - b += 1 // padding + buf[b] = c.Extensions["XFIXES"] + 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 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Source)) b += 4 - v.X = int16(xgb.Get16(buf[b:])) + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. +type SelectCursorInputCookie struct { + *xgb.Cookie +} + +// SelectCursorInput 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SelectCursorInput' 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} +} + +// 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 'SelectCursorInput' 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} +} + +// Check returns an error if one occurred 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 { + 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 { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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 - v.Y = int16(xgb.Get16(buf[b:])) + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + 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 - v.Width = xgb.Get16(buf[b:]) + 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 +} + +// SetCursorNameCookie is a cookie used only for SetCursorName requests. +type SetCursorNameCookie struct { + *xgb.Cookie +} + +// SetCursorName sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetCursorName(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) + return SetCursorNameCookie{cookie} +} + +// SetCursorNameChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCursorNameCookie.Check() +func SetCursorNameChecked(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) + return SetCursorNameCookie{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 SetCursorNameCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCursorName +// setCursorNameRequest writes a SetCursorName request to a byte slice. +func setCursorNameRequest(c *xgb.Conn, Cursor 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] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Height = xgb.Get16(buf[b:]) + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put16(buf[b:], Nbytes) b += 2 - v.Xhot = xgb.Get16(buf[b:]) + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) + + return buf +} + +// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests. +type SetGCClipRegionCookie struct { + *xgb.Cookie +} + +// SetGCClipRegion 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetGCClipRegion' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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 - v.Yhot = xgb.Get16(buf[b:]) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOrigin)) b += 2 - v.CursorSerial = xgb.Get32(buf[b:]) + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + + return buf +} + +// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests. +type SetPictureClipRegionCookie struct { + *xgb.Cookie +} + +// 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 'SetPictureClipRegion' 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} +} + +// 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 'SetPictureClipRegion' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + 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(Picture)) b += 4 - v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Region)) b += 4 - v.Nbytes = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(XOrigin)) b += 2 - b += 2 // padding + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Nbytes)) + return buf +} + +// SetRegionCookie is a cookie used only for SetRegion requests. +type SetRegionCookie struct { + *xgb.Cookie +} + +// 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 - return buf -} + b += 2 // skip sequence number -// 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 -} + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 -type DeviceTimeCoord struct { - Time xproto.Timestamp -} + buf[b] = v.Request + b += 1 -// DeviceTimeCoordRead reads a byte slice into a DeviceTimeCoord value. -func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { - b := 0 + b += 23 // padding - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + return buf +} - 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 } -// 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) +// 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, ", ") + "}" } -// Bytes writes a DeviceTimeCoord value to a byte slice. -func (v DeviceTimeCoord) Bytes() []byte { - buf := make([]byte, 4) - b := 0 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew +} - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 +// BadClass is the error number for a BadClass. +const BadClass = 4 - return buf +type ClassError struct { + Sequence uint16 + NiceName string } -// 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 -} +// ClassErrorNew constructs a ClassError value that implements xgb.Error from a byte slice. +func ClassErrorNew(buf []byte) xgb.Error { + v := ClassError{} + v.NiceName = "Class" -type FeedbackState struct { - ClassId byte - Id byte - Len uint16 -} + b := 1 // skip error determinant + b += 1 // don't read error number -// FeedbackStateRead reads a byte slice into a FeedbackState value. -func FeedbackStateRead(buf []byte, v *FeedbackState) int { - b := 0 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - v.ClassId = buf[b] - b += 1 + return v +} - v.Id = buf[b] - b += 1 +// SequenceId returns the sequence id attached to the BadClass error. +// This is mostly used internally. +func (err ClassError) SequenceId() uint16 { + return err.Sequence +} - v.Len = xgb.Get16(buf[b:]) - b += 2 +// 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 +} - return b +// Error returns a rudimentary string representation of the BadClass error. + +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 DeviceAbsAreaState struct { + ControlId uint16 + Len uint16 + OffsetX uint32 + OffsetY uint32 + Width uint32 + Height uint32 + Screen uint32 + Following uint32 } -type PtrFeedbackState struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - AccelNum uint16 - AccelDenom uint16 - Threshold uint16 -} - -// 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] +// DeviceButtonStateNotify is the event number for a DeviceButtonStateNotifyEvent. +const DeviceButtonStateNotify = 14 + +type DeviceButtonStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Buttons []byte // size: 28 +} + +// 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.DeviceId = buf[b] b += 1 - v.Len = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.LedMask = xgb.Get32(buf[b:]) - b += 4 - - v.LedValues = xgb.Get32(buf[b:]) - b += 4 + v.Buttons = make([]byte, 28) + copy(v.Buttons[:28], buf[b:]) + b += xgb.Pad(int(28)) - return b + return v } -// 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) -} - -// 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.ControlId) + b += 2 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)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Threshold)) - 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 -} - -// LedFeedbackCtlRead reads a byte slice into a LedFeedbackCtl value. -func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 +const ( + DeviceInputModeAsyncThisDevice = 0 + DeviceInputModeSyncThisDevice = 1 + DeviceInputModeReplayThisDevice = 2 + DeviceInputModeAsyncOtherDevices = 3 + DeviceInputModeAsyncAll = 4 + DeviceInputModeSyncAll = 5 +) - v.Id = buf[b] - b += 1 +// DeviceKeyPress is the event number for a DeviceKeyPressEvent. +const DeviceKeyPress = 1 - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.LedMask = xgb.Get32(buf[b:]) - b += 4 - - v.LedValues = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// 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) +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 } -// Bytes writes a LedFeedbackCtl value to a byte slice. -func (v LedFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 +// 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 - buf[b] = v.Id + v.Detail = buf[b] b += 1 - xgb.Put16(buf[b:], v.Len) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], v.LedMask) + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.LedValues) + v.Root = xproto.Window(xgb.Get32(buf[b:])) b += 4 - return buf -} + v.Event = xproto.Window(xgb.Get32(buf[b:])) + 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 -} + v.Child = xproto.Window(xgb.Get32(buf[b:])) + b += 4 -type InputState struct { - ClassId byte - Len byte - NumItems byte -} + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 -// InputStateRead reads a byte slice into a InputState value. -func InputStateRead(buf []byte, v *InputState) int { - b := 0 + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 - v.ClassId = buf[b] - b += 1 + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 - v.Len = buf[b] - b += 1 + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 - v.NumItems = buf[b] + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } b += 1 - return b -} + v.DeviceId = buf[b] + b += 1 -// 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) + return v } -// Bytes writes a InputState value to a byte slice. -func (v InputState) Bytes() []byte { - buf := make([]byte, 3) +// Bytes writes a DeviceKeyPressEvent value to a byte slice. +func (v DeviceKeyPressEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len + // write event number + buf[b] = 1 b += 1 - buf[b] = v.NumItems + buf[b] = v.Detail b += 1 - return buf -} + b += 2 // skip sequence number -// 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 -} + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 -type KeyState struct { - ClassId byte - Len byte - NumKeys byte - // padding: 1 bytes - Keys []byte // size: 32 -} + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 -// KeyStateRead reads a byte slice into a KeyState value. -func KeyStateRead(buf []byte, v *KeyState) int { - b := 0 + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 - v.ClassId = buf[b] - b += 1 + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 - v.Len = buf[b] - b += 1 + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 - v.NumKeys = buf[b] - b += 1 + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += xgb.Pad(int(32)) + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 - return b -} + xgb.Put16(buf[b:], v.State) + 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]) + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 } - return xgb.Pad(b) -} - -// Bytes writes a KeyState value to a byte slice. -func (v KeyState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len b += 1 - buf[b] = v.NumKeys + buf[b] = v.DeviceId b += 1 - b += 1 // padding - - copy(buf[b:], v.Keys[:32]) - b += xgb.Pad(int(32)) - 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 DeviceKeyPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceKeyPressEvent) 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 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, ", ") + "}" } -type ButtonState struct { - ClassId byte - Len byte - NumButtons byte - // padding: 1 bytes - Buttons []byte // size: 32 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][1] = DeviceKeyPressEventNew } -// ButtonStateRead reads a byte slice into a ButtonState value. -func ButtonStateRead(buf []byte, v *ButtonState) int { - b := 0 +// DeviceKeyRelease is the event number for a DeviceKeyReleaseEvent. +const DeviceKeyRelease = 2 - v.ClassId = buf[b] - b += 1 +type DeviceKeyReleaseEvent DeviceKeyPressEvent - v.Len = buf[b] - b += 1 +// DeviceKeyReleaseEventNew constructs a DeviceKeyReleaseEvent value that implements xgb.Event from a byte slice. +func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { + return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} - v.NumButtons = buf[b] - b += 1 +// Bytes writes a DeviceKeyReleaseEvent value to a byte slice. +func (v DeviceKeyReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} - b += 1 // padding +// 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 +} - v.Buttons = make([]byte, 32) - copy(v.Buttons[:32], buf[b:]) - b += xgb.Pad(int(32)) +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, ", ") + "}" +} - return b +func init() { + xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew } -// 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) +// DeviceKeyStateNotify is the event number for a DeviceKeyStateNotifyEvent. +const DeviceKeyStateNotify = 13 + +type DeviceKeyStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Keys []byte // size: 28 } -// Bytes writes a ButtonState value to a byte slice. -func (v ButtonState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 +// 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 - buf[b] = v.ClassId + v.DeviceId = buf[b] b += 1 - buf[b] = v.Len + 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 b += 1 - buf[b] = v.NumButtons + buf[b] = v.DeviceId b += 1 - b += 1 // padding + b += 2 // skip sequence number - copy(buf[b:], v.Buttons[:32]) - b += xgb.Pad(int(32)) + copy(buf[b:], v.Keys[:28]) + b += xgb.Pad(int(28)) 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 DeviceKeyStateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceKeyStateNotifyEvent) 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 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 ValuatorState struct { - ClassId byte - Len byte - NumValuators byte - Mode byte - Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +func init() { + xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew } -// ValuatorStateRead reads a byte slice into a ValuatorState value. -func ValuatorStateRead(buf []byte, v *ValuatorState) int { - b := 0 +// DeviceMappingNotify is the event number for a DeviceMappingNotifyEvent. +const DeviceMappingNotify = 11 - v.ClassId = buf[b] +type DeviceMappingNotifyEvent struct { + Sequence uint16 + DeviceId byte + Request byte + FirstKeycode KeyCode + Count byte + // padding: 1 bytes + Time xproto.Timestamp + // padding: 20 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 + + 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.NumValuators = buf[b] + v.FirstKeycode = KeyCode(buf[b]) b += 1 - v.Mode = buf[b] + v.Count = 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) + b += 1 // padding - return b -} + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// 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) + b += 20 // padding + + 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 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.NumValuators + b += 2 // skip sequence number + + buf[b] = v.Request b += 1 - buf[b] = v.Mode + buf[b] = byte(v.FirstKeycode) b += 1 - for i := 0; i < int(v.NumValuators); i++ { - xgb.Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = xgb.Pad(b) + buf[b] = v.Count + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + 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 DeviceMappingNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceMappingNotifyEvent) 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 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 DeviceState struct { - ControlId uint16 - Len uint16 +func init() { + xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew } -// DeviceStateRead reads a byte slice into a DeviceState value. -func DeviceStateRead(buf []byte, v *DeviceState) int { +// 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, ", ") + "}" +} + +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.DeviceId = buf[b] + b += 1 + + v.Control = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Bytes writes a DevicePresenceNotifyEvent value to a byte slice. +func (v DevicePresenceNotifyEvent) 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.Time)) + b += 4 + + buf[b] = v.Devchange + b += 1 + + buf[b] = v.DeviceId + b += 1 + + xgb.Put16(buf[b:], v.Control) + 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 +} + +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 -} - -// DeviceEnableStateRead reads a byte slice into a DeviceEnableState value. -func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { - b := 0 +const ( + DeviceUseIsXPointer = 0 + DeviceUseIsXKeyboard = 1 + DeviceUseIsXExtensionDevice = 2 + DeviceUseIsXExtensionKeyboard = 3 + DeviceUseIsXExtensionPointer = 4 +) - v.ControlId = xgb.Get16(buf[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 +} + +// 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.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)))) - b := 0 - - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 +// Bytes writes a FeedbackState value to a byte slice. +func (v FeedbackState) Bytes() []byte { + buf := make([]byte, 4) + b := 0 - 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,905 +3135,846 @@ 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 + xgb.Put32(buf[b:], uint32(v.IntToDisplay)) + b += 4 - buf[b] = v.FirstValuator - b += 1 + return buf +} - for i := 0; i < int(6); i++ { - xgb.Put32(buf[b:], uint32(v.Valuators[i])) - b += 4 +// 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)) } - b = xgb.Pad(b) - - return buf + 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 IntegerFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Resolution uint32 + MinValue int32 + MaxValue int32 } -// 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, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew -} - -// 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.Put32(buf[b:], uint32(v.Time)) - b += 4 + xgb.Put16(buf[b:], v.Len) + b += 2 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + buf[b] = byte(v.Key) + b += 1 - buf[b] = v.Mode + buf[b] = v.AutoRepeatMode b += 1 - buf[b] = v.DeviceId + buf[b] = byte(v.KeyClickPercent) b += 1 - b += 18 // padding + buf[b] = byte(v.BellPercent) + 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 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.Len = buf[b] + b += 1 - v.Request = buf[b] + v.MinKeycode = KeyCode(buf[b]) b += 1 - v.FirstKeycode = 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, ", ") + "}" +// 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 } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew +type KeyState struct { + ClassId byte + Len byte + NumKeys byte + // padding: 1 bytes + Keys []byte // size: 32 } -// 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 -} +// KeyStateRead reads a byte slice into a KeyState value. +func KeyStateRead(buf []byte, v *KeyState) 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] + b += 1 - v.DeviceId = buf[b] + v.Len = buf[b] b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.NumKeys = buf[b] + b += 1 - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + b += 1 // padding - v.Request = buf[b] - b += 1 + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) - b += 23 // padding + return b +} - return v +// 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) } -// Bytes writes a ChangeDeviceNotifyEvent value to a byte slice. -func (v ChangeDeviceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// Bytes writes a KeyState value to a byte slice. +func (v KeyState) Bytes() []byte { + buf := make([]byte, 36) b := 0 - // write event number - buf[b] = 12 + buf[b] = v.ClassId b += 1 - buf[b] = v.DeviceId + buf[b] = v.Len b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.Request + buf[b] = v.NumKeys b += 1 - b += 23 // padding + b += 1 // padding + + copy(buf[b:], v.Keys[:32]) + b += xgb.Pad(int(32)) 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 +// 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 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, ", ") + "}" +// 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"][12] = ChangeDeviceNotifyEventNew +type LedFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 } -// DeviceKeyStateNotify is the event number for a DeviceKeyStateNotifyEvent. -const DeviceKeyStateNotify = 13 - -type DeviceKeyStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Keys []byte // size: 28 -} +// LedFeedbackCtlRead reads a byte slice into a LedFeedbackCtl value. +func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { + b := 0 -// 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.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.Keys = make([]byte, 28) - copy(v.Keys[: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 DeviceKeyStateNotifyEvent value to a byte slice. -func (v DeviceKeyStateNotifyEvent) 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] = 13 +// Bytes writes a LedFeedbackCtl value to a byte slice. +func (v LedFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + 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.Len) + b += 2 - copy(buf[b:], v.Keys[:28]) - b += xgb.Pad(int(28)) + 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 DeviceKeyStateNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceKeyStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// 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, ", ") + "}" +// 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 } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew +type LedFeedbackState 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 -} +// LedFeedbackStateRead reads a byte slice into a LedFeedbackState value. +func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) 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) +// 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] = 14 - b += 1 +// Bytes writes a LedFeedbackState value to a byte slice. +func (v LedFeedbackState) 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 +// 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 } -// DevicePresenceNotify is the event number for a DevicePresenceNotifyEvent. -const DevicePresenceNotify = 15 +// BadMode is the error number for a BadMode. +const BadMode = 2 -type DevicePresenceNotifyEvent struct { +type ModeError struct { Sequence uint16 - // padding: 1 bytes - Time xproto.Timestamp - Devchange byte - DeviceId byte - Control uint16 - // padding: 20 bytes + NiceName string } -// 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 +// ModeErrorNew constructs a ModeError value that implements xgb.Error from a byte slice. +func ModeErrorNew(buf []byte) xgb.Error { + v := ModeError{} + v.NiceName = "Mode" - b += 1 // padding + b := 1 // skip error determinant + b += 1 // don't read error number 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.DeviceId = buf[b] - b += 1 - - v.Control = xgb.Get16(buf[b:]) - b += 2 - - b += 20 // padding - return v } -// Bytes writes a DevicePresenceNotifyEvent value to a byte slice. -func (v DevicePresenceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 +// SequenceId returns the sequence id attached to the BadMode error. +// This is mostly used internally. +func (err ModeError) SequenceId() uint16 { + return err.Sequence +} - // write event number - buf[b] = 15 - b += 1 +// 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 +} - b += 1 // padding +// Error returns a rudimentary string representation of the BadMode error. - b += 2 // skip sequence number +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, ", ") + "}" +} - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew +} - buf[b] = v.Devchange - b += 1 +const ( + PropagateModeAddToList = 0 + PropagateModeDeleteFromList = 1 +) - buf[b] = v.DeviceId - b += 1 +// ProximityIn is the event number for a ProximityInEvent. +const ProximityIn = 8 - xgb.Put16(buf[b:], v.Control) - b += 2 +type ProximityInEvent DeviceKeyPressEvent - b += 20 // padding +// ProximityInEventNew constructs a ProximityInEvent value that implements xgb.Event from a byte slice. +func ProximityInEventNew(buf []byte) xgb.Event { + return ProximityInEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} - return buf +// Bytes writes a ProximityInEvent value to a byte slice. +func (v ProximityInEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() } -// SequenceId returns the sequence id attached to the DevicePresenceNotify event. +// SequenceId returns the sequence id attached to the ProximityIn event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v DevicePresenceNotifyEvent) SequenceId() uint16 { +func (v ProximityInEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of DevicePresenceNotifyEvent. -func (v DevicePresenceNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) +func (v ProximityInEvent) 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("Devchange: %d", v.Devchange)) + 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)) - fieldVals = append(fieldVals, xgb.Sprintf("Control: %d", v.Control)) - return "DevicePresenceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "ProximityIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtEventFuncs["XInputExtension"][15] = DevicePresenceNotifyEventNew + xgb.NewExtEventFuncs["XInputExtension"][8] = ProximityInEventNew } -// DeviceKeyRelease is the event number for a DeviceKeyReleaseEvent. -const DeviceKeyRelease = 2 +// ProximityOut is the event number for a ProximityOutEvent. +const ProximityOut = 9 -type DeviceKeyReleaseEvent DeviceKeyPressEvent +type ProximityOutEvent DeviceKeyPressEvent -// DeviceKeyReleaseEventNew constructs a DeviceKeyReleaseEvent value that implements xgb.Event from a byte slice. -func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { - return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +// ProximityOutEventNew constructs a ProximityOutEvent value that implements xgb.Event from a byte slice. +func ProximityOutEventNew(buf []byte) xgb.Event { + return ProximityOutEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } -// Bytes writes a DeviceKeyReleaseEvent value to a byte slice. -func (v DeviceKeyReleaseEvent) Bytes() []byte { +// Bytes writes a ProximityOutEvent value to a byte slice. +func (v ProximityOutEvent) Bytes() []byte { return DeviceKeyPressEvent(v).Bytes() } -// SequenceId returns the sequence id attached to the DeviceKeyRelease event. +// SequenceId returns the sequence id attached to the ProximityOut event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v DeviceKeyReleaseEvent) SequenceId() uint16 { +func (v ProximityOutEvent) SequenceId() uint16 { return v.Sequence } -func (v DeviceKeyReleaseEvent) String() string { +func (v ProximityOutEvent) 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)) @@ -4080,739 +3989,829 @@ func (v DeviceKeyReleaseEvent) String() string { 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, ", ") + "}" + return "ProximityOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew + xgb.NewExtEventFuncs["XInputExtension"][9] = ProximityOutEventNew } -// DeviceButtonPress is the event number for a DeviceButtonPressEvent. -const DeviceButtonPress = 3 +type PtrFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + Num int16 + Denom int16 + Threshold int16 +} -type DeviceButtonPressEvent DeviceKeyPressEvent +// PtrFeedbackCtlRead reads a byte slice into a PtrFeedbackCtl value. +func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { + b := 0 -// 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.ClassId = buf[b] + b += 1 -// Bytes writes a DeviceButtonPressEvent value to a byte slice. -func (v DeviceButtonPressEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() -} + v.Id = buf[b] + 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 -} + v.Len = xgb.Get16(buf[b:]) + b += 2 -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, ", ") + "}" -} + b += 2 // padding -func init() { - xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew -} + v.Num = int16(xgb.Get16(buf[b:])) + b += 2 -// DeviceButtonRelease is the event number for a DeviceButtonReleaseEvent. -const DeviceButtonRelease = 4 + v.Denom = int16(xgb.Get16(buf[b:])) + b += 2 -type DeviceButtonReleaseEvent DeviceKeyPressEvent + v.Threshold = int16(xgb.Get16(buf[b:])) + b += 2 -// DeviceButtonReleaseEventNew constructs a DeviceButtonReleaseEvent value that implements xgb.Event from a byte slice. -func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { - return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) + return b } -// Bytes writes a DeviceButtonReleaseEvent value to a byte slice. -func (v DeviceButtonReleaseEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() +// 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) } -// 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 -} +// Bytes writes a PtrFeedbackCtl value to a byte slice. +func (v PtrFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + 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, ", ") + "}" -} + buf[b] = v.ClassId + b += 1 -func init() { - xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew -} + buf[b] = v.Id + b += 1 -// DeviceMotionNotify is the event number for a DeviceMotionNotifyEvent. -const DeviceMotionNotify = 5 + xgb.Put16(buf[b:], v.Len) + b += 2 -type DeviceMotionNotifyEvent DeviceKeyPressEvent + b += 2 // padding -// DeviceMotionNotifyEventNew constructs a DeviceMotionNotifyEvent value that implements xgb.Event from a byte slice. -func DeviceMotionNotifyEventNew(buf []byte) xgb.Event { - return DeviceMotionNotifyEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) + xgb.Put16(buf[b:], uint16(v.Num)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Denom)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Threshold)) + b += 2 + + return buf } -// Bytes writes a DeviceMotionNotifyEvent value to a byte slice. -func (v DeviceMotionNotifyEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() +// 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 } -// 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 +type PtrFeedbackState struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + AccelNum uint16 + AccelDenom uint16 + Threshold uint16 } -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, ", ") + "}" +// PtrFeedbackStateRead reads a byte slice into a PtrFeedbackState value. +func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) 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.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.NewExtEventFuncs["XInputExtension"][5] = DeviceMotionNotifyEventNew +// 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) } -// ProximityIn is the event number for a ProximityInEvent. -const ProximityIn = 8 +// Bytes writes a PtrFeedbackState value to a byte slice. +func (v PtrFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 -type ProximityInEvent DeviceKeyPressEvent + buf[b] = v.ClassId + b += 1 -// ProximityInEventNew constructs a ProximityInEvent value that implements xgb.Event from a byte slice. -func ProximityInEventNew(buf []byte) xgb.Event { - return ProximityInEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], v.AccelNum) + b += 2 + + xgb.Put16(buf[b:], v.AccelDenom) + b += 2 + + xgb.Put16(buf[b:], v.Threshold) + b += 2 + + return buf } -// Bytes writes a ProximityInEvent value to a byte slice. -func (v ProximityInEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() +// 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 } -// SequenceId returns the sequence id attached to the ProximityIn event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ProximityInEvent) SequenceId() uint16 { - return v.Sequence +type StringFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) } -func (v ProximityInEvent) 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 "ProximityIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// StringFeedbackCtlRead reads a byte slice into a StringFeedbackCtl value. +func StringFeedbackCtlRead(buf []byte, v *StringFeedbackCtl) 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.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.NewExtEventFuncs["XInputExtension"][8] = ProximityInEventNew +// 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) } -// ProximityOut is the event number for a ProximityOutEvent. -const ProximityOut = 9 +// 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 ProximityOutEvent DeviceKeyPressEvent + buf[b] = v.ClassId + b += 1 -// ProximityOutEventNew constructs a ProximityOutEvent value that implements xgb.Event from a byte slice. -func ProximityOutEventNew(buf []byte) xgb.Event { - return ProximityOutEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) -} + buf[b] = v.Id + b += 1 -// Bytes writes a ProximityOutEvent value to a byte slice. -func (v ProximityOutEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + 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 ProximityOut event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ProximityOutEvent) SequenceId() uint16 { - return v.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 } -func (v ProximityOutEvent) 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 "ProximityOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// 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 } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][9] = ProximityOutEventNew +type StringFeedbackState struct { + ClassId byte + Id byte + Len uint16 + MaxSymbols uint16 + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) } -// FocusOut is the event number for a FocusOutEvent. -const FocusOut = 7 +// StringFeedbackStateRead reads a byte slice into a StringFeedbackState value. +func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { + b := 0 -type FocusOutEvent FocusInEvent + v.ClassId = 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)) + 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 } -// Bytes writes a FocusOutEvent value to a byte slice. -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() +// 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) } -// 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 StringFeedbackState value to a byte slice. +func (v StringFeedbackState) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) + 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.MaxSymbols) + b += 2 + + 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 } -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, ", ") + "}" +// 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 } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew +// 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 } -// BadDevice is the error number for a BadDevice. -const BadDevice = 0 - -type DeviceError struct { - Sequence uint16 - NiceName string +type ValuatorInfo struct { + ClassId byte + Len byte + AxesLen byte + Mode byte + MotionSize uint32 + Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) } -// DeviceErrorNew constructs a DeviceError value that implements xgb.Error from a byte slice. -func DeviceErrorNew(buf []byte) xgb.Error { - v := DeviceError{} - v.NiceName = "Device" +// ValuatorInfoRead reads a byte slice into a ValuatorInfo value. +func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { + b := 0 - b := 1 // skip error determinant - b += 1 // don't read error number + v.ClassId = buf[b] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.Len = buf[b] + b += 1 - return v -} + v.AxesLen = buf[b] + b += 1 -// SequenceId returns the sequence id attached to the BadDevice error. -// This is mostly used internally. -func (err DeviceError) SequenceId() uint16 { - return err.Sequence -} + v.Mode = buf[b] + b += 1 -// 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 -} + v.MotionSize = xgb.Get32(buf[b:]) + b += 4 -// Error returns a rudimentary string representation of the BadDevice error. + v.Axes = make([]AxisInfo, v.AxesLen) + b += AxisInfoReadList(buf[b:], v.Axes) -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, ", ") + "}" + return b } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew +// 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) } -// BadEvent is the error number for a BadEvent. -const BadEvent = 1 +// 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 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.Len + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = v.AxesLen + b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + buf[b] = v.Mode + b += 1 - return v -} + xgb.Put32(buf[b:], v.MotionSize) + b += 4 -// SequenceId returns the sequence id attached to the BadEvent error. -// This is mostly used internally. -func (err EventError) SequenceId() uint16 { - return err.Sequence -} + b += AxisInfoListBytes(buf[b:], v.Axes) -// 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 + return buf } -// 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, ", ") + "}" +// 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 } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][1] = EventErrorNew +// 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 } -// BadMode is the error number for a BadMode. -const BadMode = 2 +const ( + ValuatorModeRelative = 0 + ValuatorModeAbsolute = 1 +) -type ModeError struct { - Sequence uint16 - NiceName string +type ValuatorState struct { + ClassId byte + Len byte + NumValuators byte + Mode byte + Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) } -// ModeErrorNew constructs a ModeError value that implements xgb.Error from a byte slice. -func ModeErrorNew(buf []byte) xgb.Error { - v := ModeError{} - v.NiceName = "Mode" - - b := 1 // skip error determinant - b += 1 // don't read error number +// ValuatorStateRead reads a byte slice into a ValuatorState value. +func ValuatorStateRead(buf []byte, v *ValuatorState) int { + b := 0 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.ClassId = buf[b] + b += 1 - return v -} + v.Len = buf[b] + b += 1 -// SequenceId returns the sequence id attached to the BadMode error. -// This is mostly used internally. -func (err ModeError) SequenceId() uint16 { - return err.Sequence -} + v.NumValuators = buf[b] + b += 1 -// 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 -} + v.Mode = buf[b] + b += 1 -// Error returns a rudimentary string representation of the BadMode error. + 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) -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, ", ") + "}" + return b } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew +// 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) } -// BadDeviceBusy is the error number for a BadDeviceBusy. -const BadDeviceBusy = 3 +// 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 -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.Len + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = v.NumValuators + b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + buf[b] = v.Mode + b += 1 - return v -} + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 + } + b = xgb.Pad(b) -// SequenceId returns the sequence id attached to the BadDeviceBusy error. -// This is mostly used internally. -func (err DeviceBusyError) SequenceId() uint16 { - return err.Sequence + return buf } -// 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 +// 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 } -// Error returns a rudimentary string representation of the BadDeviceBusy error. - -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, ", ") + "}" +// 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 } -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew -} +// Skipping definition for base type 'Bool' -// BadClass is the error number for a BadClass. -const BadClass = 4 +// Skipping definition for base type 'Byte' -type ClassError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Card8' -// ClassErrorNew constructs a ClassError value that implements xgb.Error from a byte slice. -func ClassErrorNew(buf []byte) xgb.Error { - v := ClassError{} - v.NiceName = "Class" +// 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 BadClass error. -// This is mostly used internally. -func (err ClassError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Int16' -// 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 -} +// Skipping definition for base type 'Int32' -// Error returns a rudimentary string representation of the BadClass error. +// Skipping definition for base type 'Int8' -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, ", ") + "}" -} +// Skipping definition for base type 'Card16' -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew -} +// Skipping definition for base type 'Card32' -// GetExtensionVersionCookie is a cookie used only for GetExtensionVersion requests. -type GetExtensionVersionCookie struct { +// 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetExtensionVersion' 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} -} - -// GetExtensionVersionUnchecked sends an unchecked request. +// AllowDeviceEvents 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 { +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(false, true) - c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) - return GetExtensionVersionCookie{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 + cookie := c.NewCookie(false, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} } -// 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 - } - if buf == nil { - return nil, nil +// 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.") } - return getExtensionVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} } -// 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 - - 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 - - if buf[b] == 1 { - v.Present = true - } else { - v.Present = false - } - b += 1 - - b += 19 // 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 AllowDeviceEventsCookie) Check() error { + return cook.Cookie.Check() } -// 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)))) +// 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] = 1 // 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.Put16(buf[b:], NameLen) - b += 2 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 - b += 2 // padding + buf[b] = Mode + b += 1 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + buf[b] = DeviceId + b += 1 return buf } -// ListInputDevicesCookie is a cookie used only for ListInputDevices requests. -type ListInputDevicesCookie struct { +// ChangeDeviceDontPropagateListCookie is a cookie used only for ChangeDeviceDontPropagateList requests. +type ChangeDeviceDontPropagateListCookie 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 { +// 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 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeDeviceDontPropagateList' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} } -// 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 { +// 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 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeDeviceDontPropagateList' 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} + cookie := c.NewCookie(true, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} } -// 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)) +// Check returns an error if one occurred 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() } -// 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 -} +// 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) -// listInputDevicesReply reads a byte slice into a ListInputDevicesReply value. -func listInputDevicesReply(buf []byte) *ListInputDevicesReply { - v := new(ListInputDevicesReply) - b := 1 // skip reply determinant + 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 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = Mode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + return buf +} - v.DevicesLen = buf[b] - b += 1 +// ChangeDeviceKeyMappingCookie is a cookie used only for ChangeDeviceKeyMapping requests. +type ChangeDeviceKeyMappingCookie struct { + *xgb.Cookie +} - b += 23 // padding +// 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} +} - v.Devices = make([]DeviceInfo, v.DevicesLen) - b += DeviceInfoReadList(buf[b:], v.Devices) +// 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} +} - 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 ChangeDeviceKeyMappingCookie) Check() error { + return cook.Cookie.Check() } -// 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 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] = 2 // 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 + buf[b] = DeviceId + b += 1 + + buf[b] = byte(FirstKeycode) + b += 1 + + 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 } -// OpenDeviceCookie is a cookie used only for OpenDevice requests. -type OpenDeviceCookie struct { +// ChangeKeyboardDeviceCookie is a cookie used only for ChangeKeyboardDevice requests. +type ChangeKeyboardDeviceCookie 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 { +// 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 'OpenDevice' 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(openDeviceRequest(c, DeviceId), cookie) - return OpenDeviceCookie{cookie} + c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} } -// OpenDeviceUnchecked 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 OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { +func ChangeKeyboardDeviceUnchecked(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { 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 'ChangeKeyboardDevice' 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(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} } -// OpenDeviceReply represents the data returned from a OpenDevice request. -type OpenDeviceReply 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 - 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 ChangeKeyboardDevice request. +func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4820,12 +4819,12 @@ func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { if buf == nil { return nil, nil } - return openDeviceReply(buf), nil + return changeKeyboardDeviceReply(buf), nil } -// openDeviceReply reads a byte slice into a OpenDeviceReply value. -func openDeviceReply(buf []byte) *OpenDeviceReply { - v := new(OpenDeviceReply) +// 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 @@ -4836,77 +4835,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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - 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 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// CloseDeviceCookie is a cookie used only for CloseDevice requests. -type CloseDeviceCookie struct { - *xgb.Cookie -} - -// CloseDevice sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CloseDevice(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'CloseDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) - return CloseDeviceCookie{cookie} -} - -// CloseDeviceChecked sends a checked request. -// If an error occurs, it can be retrieved using CloseDeviceCookie.Check() -func CloseDeviceChecked(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'CloseDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) - return CloseDeviceCookie{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 CloseDeviceCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CloseDevice -// closeDeviceRequest writes a CloseDevice request to a byte slice. -func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { +// 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) @@ -4914,7 +4853,7 @@ func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4928,35 +4867,35 @@ func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// SetDeviceModeCookie is a cookie used only for SetDeviceMode requests. -type SetDeviceModeCookie struct { +// ChangePointerDeviceCookie is a cookie used only for ChangePointerDevice requests. +type ChangePointerDeviceCookie 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 { +// 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 'SetDeviceMode' 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(setDeviceModeRequest(c, DeviceId, Mode), cookie) - return SetDeviceModeCookie{cookie} + c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} } -// SetDeviceModeUnchecked 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 SetDeviceModeUnchecked(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { +func ChangePointerDeviceUnchecked(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { 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 'ChangePointerDevice' 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(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} } -// SetDeviceModeReply represents the data returned from a SetDeviceMode request. -type SetDeviceModeReply 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 @@ -4964,8 +4903,8 @@ type SetDeviceModeReply struct { // padding: 23 bytes } -// 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 ChangePointerDevice request. +func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4973,33 +4912,96 @@ func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { if buf == nil { return nil, nil } - return setDeviceModeReply(buf), nil + return changePointerDeviceReply(buf), nil } -// setDeviceModeReply reads a byte slice into a SetDeviceModeReply value. -func setDeviceModeReply(buf []byte) *SetDeviceModeReply { - v := new(SetDeviceModeReply) +// 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 + 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 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) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = 12 // 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 - b += 4 + buf[b] = XAxis + b += 1 - v.Status = buf[b] + buf[b] = YAxis b += 1 - b += 23 // padding + buf[b] = DeviceId + b += 1 - return v + b += 1 // padding + + return buf } -// 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 { +// CloseDeviceCookie is a cookie used only for CloseDevice requests. +type CloseDeviceCookie struct { + *xgb.Cookie +} + +// CloseDevice sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CloseDevice(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'CloseDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) + return CloseDeviceCookie{cookie} +} + +// CloseDeviceChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseDeviceCookie.Check() +func CloseDeviceChecked(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'CloseDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) + return CloseDeviceCookie{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 CloseDeviceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseDevice +// closeDeviceRequest writes a CloseDevice request to a byte slice. +func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -5007,7 +5009,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] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5016,121 +5018,114 @@ 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 { +// DeviceBellCookie is a cookie used only for DeviceBell requests. +type DeviceBellCookie struct { *xgb.Cookie } -// SelectExtensionEvent sends an unchecked request. +// DeviceBell 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 { +func DeviceBell(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { 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 'DeviceBell' 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} + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{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 { +// 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 'SelectExtensionEvent' 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(true, false) - c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) - return SelectExtensionEventCookie{cookie} + 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 SelectExtensionEventCookie) Check() error { +func (cook DeviceBellCookie) Check() error { return cook.Cookie.Check() } -// 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)))) +// 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] = 6 // 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(Window)) - b += 4 + buf[b] = DeviceId + b += 1 - xgb.Put16(buf[b:], NumClasses) - b += 2 + buf[b] = FeedbackId + b += 1 - b += 2 // padding + buf[b] = FeedbackClass + b += 1 - for i := 0; i < int(NumClasses); i++ { - xgb.Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = xgb.Pad(b) + buf[b] = byte(Percent) + b += 1 return buf } -// GetSelectedExtensionEventsCookie is a cookie used only for GetSelectedExtensionEvents requests. -type GetSelectedExtensionEventsCookie struct { +// GetDeviceButtonMappingCookie is a cookie used only for GetDeviceButtonMapping requests. +type GetDeviceButtonMappingCookie 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 { +// 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 'GetSelectedExtensionEvents' 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(true, true) - c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) - return GetSelectedExtensionEventsCookie{cookie} + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} } -// GetSelectedExtensionEventsUnchecked 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 GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { +func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { 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 'GetDeviceButtonMapping' 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(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} } -// GetSelectedExtensionEventsReply represents the data returned from a GetSelectedExtensionEvents request. -type GetSelectedExtensionEventsReply 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 - NumThisClasses uint16 - NumAllClasses uint16 - // padding: 20 bytes - ThisClasses []EventClass // size: xgb.Pad((int(NumThisClasses) * 4)) - AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) + MapSize byte + // padding: 23 bytes + Map []byte // size: xgb.Pad((int(MapSize) * 1)) } -// 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 GetDeviceButtonMapping request. +func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5138,12 +5133,12 @@ func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEvent if buf == nil { return nil, nil } - return getSelectedExtensionEventsReply(buf), nil + return getDeviceButtonMappingReply(buf), nil } -// getSelectedExtensionEventsReply reads a byte slice into a GetSelectedExtensionEventsReply value. -func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { - v := new(GetSelectedExtensionEventsReply) +// 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 @@ -5154,34 +5149,21 @@ 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:]) - b += 2 - - b += 20 // padding + v.MapSize = buf[b] + b += 1 - 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 += 23 // padding - 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) + 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 GetSelectedExtensionEvents -// getSelectedExtensionEventsRequest writes a GetSelectedExtensionEvents request to a byte slice. -func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []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) @@ -5189,84 +5171,113 @@ func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 7 // 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(Window)) - b += 4 + buf[b] = DeviceId + b += 1 + + b += 3 // padding return buf } -// ChangeDeviceDontPropagateListCookie is a cookie used only for ChangeDeviceDontPropagateList requests. -type ChangeDeviceDontPropagateListCookie struct { +// GetDeviceControlCookie is a cookie used only for GetDeviceControl requests. +type GetDeviceControlCookie 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 { +// 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 'ChangeDeviceDontPropagateList' 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(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) - return ChangeDeviceDontPropagateListCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{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 { +// 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 'ChangeDeviceDontPropagateList' 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, 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) - return ChangeDeviceDontPropagateListCookie{cookie} + if buf == nil { + return nil, nil + } + return getDeviceControlReply(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 ChangeDeviceDontPropagateListCookie) Check() error { - return cook.Cookie.Check() +// 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 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)))) +// 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] = 8 // 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 - buf[b] = Mode + buf[b] = DeviceId b += 1 b += 1 // padding - for i := 0; i < int(NumClasses); i++ { - xgb.Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } @@ -5369,46 +5380,46 @@ func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte return buf } -// GetDeviceMotionEventsCookie is a cookie used only for GetDeviceMotionEvents requests. -type GetDeviceMotionEventsCookie struct { +// GetDeviceFocusCookie is a cookie used only for GetDeviceFocus requests. +type GetDeviceFocusCookie struct { *xgb.Cookie } -// GetDeviceMotionEvents sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceMotionEventsCookie.Reply() -func GetDeviceMotionEvents(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { +// 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 'GetDeviceMotionEvents' 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, true) - c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) - return GetDeviceMotionEventsCookie{cookie} + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{cookie} } -// GetDeviceMotionEventsUnchecked sends an unchecked request. +// GetDeviceFocusUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceMotionEventsUnchecked(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { +func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceMotionEvents' 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, true) - c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) - return GetDeviceMotionEventsCookie{cookie} + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{cookie} } -// GetDeviceMotionEventsReply represents the data returned from a GetDeviceMotionEvents request. -type GetDeviceMotionEventsReply struct { +// 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 - NumCoords uint32 - NumAxes byte - DeviceMode byte - // padding: 18 bytes + Focus xproto.Window + Time xproto.Timestamp + RevertTo byte + // padding: 15 bytes } -// Reply blocks and returns the reply data for a GetDeviceMotionEvents request. -func (cook GetDeviceMotionEventsCookie) Reply() (*GetDeviceMotionEventsReply, error) { +// 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 @@ -5416,12 +5427,12 @@ func (cook GetDeviceMotionEventsCookie) Reply() (*GetDeviceMotionEventsReply, er if buf == nil { return nil, nil } - return getDeviceMotionEventsReply(buf), nil + return getDeviceFocusReply(buf), nil } -// getDeviceMotionEventsReply reads a byte slice into a GetDeviceMotionEventsReply value. -func getDeviceMotionEventsReply(buf []byte) *GetDeviceMotionEventsReply { - v := new(GetDeviceMotionEventsReply) +// 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 @@ -5432,86 +5443,83 @@ func getDeviceMotionEventsReply(buf []byte) *GetDeviceMotionEventsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumCoords = xgb.Get32(buf[b:]) + v.Focus = xproto.Window(xgb.Get32(buf[b:])) b += 4 - v.NumAxes = buf[b] - b += 1 + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 - v.DeviceMode = buf[b] + v.RevertTo = buf[b] b += 1 - b += 18 // padding + b += 15 // padding return v } -// Write request to wire for GetDeviceMotionEvents -// getDeviceMotionEventsRequest writes a GetDeviceMotionEvents request to a byte slice. -func getDeviceMotionEventsRequest(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) []byte { - size := 16 +// 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] = 10 // 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(Start)) - b += 4 - - xgb.Put32(buf[b:], uint32(Stop)) - b += 4 - buf[b] = DeviceId b += 1 + b += 3 // padding + return buf } -// ChangeKeyboardDeviceCookie is a cookie used only for ChangeKeyboardDevice requests. -type ChangeKeyboardDeviceCookie struct { +// GetDeviceKeyMappingCookie is a cookie used only for GetDeviceKeyMapping requests. +type GetDeviceKeyMappingCookie 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 { +// 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 'ChangeKeyboardDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceKeyMapping' 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(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} } -// ChangeKeyboardDeviceUnchecked sends an unchecked request. +// GetDeviceKeyMappingUnchecked 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 GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { 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 'GetDeviceKeyMapping' 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(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} } -// ChangeKeyboardDeviceReply represents the data returned from a ChangeKeyboardDevice request. -type ChangeKeyboardDeviceReply struct { +// 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 - Status byte + KeysymsPerKeycode byte // padding: 23 bytes + Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) } -// 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 GetDeviceKeyMapping request. +func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5519,12 +5527,12 @@ func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, erro if buf == nil { return nil, nil } - return changeKeyboardDeviceReply(buf), nil + return getDeviceKeyMappingReply(buf), nil } -// changeKeyboardDeviceReply reads a byte slice into a ChangeKeyboardDeviceReply value. -func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { - v := new(ChangeKeyboardDeviceReply) +// 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 @@ -5535,17 +5543,24 @@ func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = buf[b] + v.KeysymsPerKeycode = 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 ChangeKeyboardDevice -// changeKeyboardDeviceRequest writes a ChangeKeyboardDevice request to a byte slice. -func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { +// 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) @@ -5553,7 +5568,7 @@ func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 24 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -5562,49 +5577,54 @@ func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = DeviceId b += 1 - b += 3 // padding + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 return buf } -// ChangePointerDeviceCookie is a cookie used only for ChangePointerDevice requests. -type ChangePointerDeviceCookie struct { +// GetDeviceModifierMappingCookie is a cookie used only for GetDeviceModifierMapping requests. +type GetDeviceModifierMappingCookie 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 { +// 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 'ChangePointerDevice' 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(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) - return ChangePointerDeviceCookie{cookie} + c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} } -// ChangePointerDeviceUnchecked 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 ChangePointerDeviceUnchecked(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { +func GetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { 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 'GetDeviceModifierMapping' 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(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} } -// ChangePointerDeviceReply represents the data returned from a ChangePointerDevice request. -type ChangePointerDeviceReply 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 - Status byte + KeycodesPerModifier byte // padding: 23 bytes + Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) } -// 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 GetDeviceModifierMapping request. +func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5612,12 +5632,12 @@ func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) if buf == nil { return nil, nil } - return changePointerDeviceReply(buf), nil + return getDeviceModifierMappingReply(buf), nil } -// changePointerDeviceReply reads a byte slice into a ChangePointerDeviceReply value. -func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { - v := new(ChangePointerDeviceReply) +// 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 @@ -5628,17 +5648,21 @@ func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = buf[b] + v.KeycodesPerModifier = 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 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 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) @@ -5646,64 +5670,60 @@ 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] = 26 // 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 += 1 // padding + b += 3 // padding return buf } -// GrabDeviceCookie is a cookie used only for GrabDevice requests. -type GrabDeviceCookie struct { +// GetDeviceMotionEventsCookie is a cookie used only for GetDeviceMotionEvents requests. +type GetDeviceMotionEventsCookie struct { *xgb.Cookie } -// GrabDevice sends a checked request. -// If an error occurs, it will be returned with the reply by calling GrabDeviceCookie.Reply() -func GrabDevice(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { +// GetDeviceMotionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceMotionEventsCookie.Reply() +func GetDeviceMotionEvents(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceMotionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) - return GrabDeviceCookie{cookie} + c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) + return GetDeviceMotionEventsCookie{cookie} } -// GrabDeviceUnchecked sends an unchecked request. +// GetDeviceMotionEventsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabDeviceUnchecked(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { +func GetDeviceMotionEventsUnchecked(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceMotionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) - return GrabDeviceCookie{cookie} + c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) + return GetDeviceMotionEventsCookie{cookie} } -// GrabDeviceReply represents the data returned from a GrabDevice request. -type GrabDeviceReply struct { +// GetDeviceMotionEventsReply represents the data returned from a GetDeviceMotionEvents request. +type GetDeviceMotionEventsReply 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 + NumCoords uint32 + NumAxes byte + DeviceMode byte + // padding: 18 bytes } -// Reply blocks and returns the reply data for a GrabDevice request. -func (cook GrabDeviceCookie) Reply() (*GrabDeviceReply, error) { +// Reply blocks and returns the reply data for a GetDeviceMotionEvents request. +func (cook GetDeviceMotionEventsCookie) Reply() (*GetDeviceMotionEventsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -5711,12 +5731,12 @@ func (cook GrabDeviceCookie) Reply() (*GrabDeviceReply, error) { if buf == nil { return nil, nil } - return grabDeviceReply(buf), nil + return getDeviceMotionEventsReply(buf), nil } -// grabDeviceReply reads a byte slice into a GrabDeviceReply value. -func grabDeviceReply(buf []byte) *GrabDeviceReply { - v := new(GrabDeviceReply) +// getDeviceMotionEventsReply reads a byte slice into a GetDeviceMotionEventsReply value. +func getDeviceMotionEventsReply(buf []byte) *GetDeviceMotionEventsReply { + v := new(GetDeviceMotionEventsReply) b := 1 // skip reply determinant b += 1 // padding @@ -5727,537 +5747,398 @@ func grabDeviceReply(buf []byte) *GrabDeviceReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = buf[b] + v.NumCoords = xgb.Get32(buf[b:]) + b += 4 + + v.NumAxes = buf[b] b += 1 - b += 23 // padding + v.DeviceMode = buf[b] + b += 1 + + b += 18 // padding return v } -// Write request to wire for GrabDevice -// grabDeviceRequest writes a GrabDevice request to a byte slice. -func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) []byte { - size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +// Write request to wire for GetDeviceMotionEvents +// getDeviceMotionEventsRequest writes a GetDeviceMotionEvents request to a byte slice. +func getDeviceMotionEventsRequest(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 13 // 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(GrabWindow)) + xgb.Put32(buf[b:], uint32(Start)) b += 4 - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Stop)) b += 4 - xgb.Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - buf[b] = DeviceId 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 } -// UngrabDeviceCookie is a cookie used only for UngrabDevice requests. -type UngrabDeviceCookie struct { +// GetExtensionVersionCookie is a cookie used only for GetExtensionVersion requests. +type GetExtensionVersionCookie struct { *xgb.Cookie } -// UngrabDevice 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 { +// 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 'UngrabDevice' 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, false) - c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) - return UngrabDeviceCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{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 { +// 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 { 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 'GetExtensionVersion' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - 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(Time)) - b += 4 - - buf[b] = DeviceId - b += 1 - - return buf + cookie := c.NewCookie(false, true) + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{cookie} } -// GrabDeviceKeyCookie is a cookie used only for GrabDeviceKey requests. -type GrabDeviceKeyCookie struct { - *xgb.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 } -// GrabDeviceKey sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") +// 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 } - cookie := c.NewCookie(false, false) - c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) - return GrabDeviceKeyCookie{cookie} -} - -// GrabDeviceKeyChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabDeviceKeyCookie.Check() -func GrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + if buf == nil { + return nil, nil } - cookie := c.NewCookie(true, false) - c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) - return GrabDeviceKeyCookie{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 GrabDeviceKeyCookie) Check() error { - return cook.Cookie.Check() + return getExtensionVersionReply(buf), nil } -// Write request to wire for GrabDeviceKey -// grabDeviceKeyRequest writes a GrabDeviceKey request to a byte slice. -func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, 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] = 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(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], NumClasses) - b += 2 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - buf[b] = Key - b += 1 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 +// getExtensionVersionReply reads a byte slice into a GetExtensionVersionReply value. +func getExtensionVersionReply(buf []byte) *GetExtensionVersionReply { + v := new(GetExtensionVersionReply) + b := 1 // skip reply determinant - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding - b += 2 // padding + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - for i := 0; i < int(NumClasses); i++ { - xgb.Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = xgb.Pad(b) + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - return buf -} + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 -// UngrabDeviceKeyCookie is a cookie used only for UngrabDeviceKey requests. -type UngrabDeviceKeyCookie struct { - *xgb.Cookie -} + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 -// 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false } - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return UngrabDeviceKeyCookie{cookie} -} + b += 1 -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return UngrabDeviceKeyCookie{cookie} -} + b += 19 // 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 UngrabDeviceKeyCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 +// 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] = 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(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], Modifiers) + xgb.Put16(buf[b:], NameLen) b += 2 - buf[b] = ModifierDevice - b += 1 - - buf[b] = Key - b += 1 + b += 2 // padding - buf[b] = GrabbedDevice - b += 1 + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// GrabDeviceButtonCookie is a cookie used only for GrabDeviceButton requests. -type GrabDeviceButtonCookie struct { +// GetFeedbackControlCookie is a cookie used only for GetFeedbackControl requests. +type GetFeedbackControlCookie 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 { +// 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 'GrabDeviceButton' 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, false) - c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return GrabDeviceButtonCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDeviceButton' 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, false) - c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return GrabDeviceButtonCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{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 GrabDeviceButtonCookie) Check() error { - return cook.Cookie.Check() +// 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 } -// 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) +// 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 +} - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 +// getFeedbackControlReply reads a byte slice into a GetFeedbackControlReply value. +func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { + v := new(GetFeedbackControlReply) + b := 1 // skip reply determinant - buf[b] = 17 // 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 - buf[b] = GrabbedDevice - b += 1 + v.NumFeedback = xgb.Get16(buf[b:]) + b += 2 - buf[b] = ModifierDevice - b += 1 + b += 22 // padding - xgb.Put16(buf[b:], NumClasses) - b += 2 + return v +} - xgb.Put16(buf[b:], Modifiers) - b += 2 +// 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] = ThisDeviceMode + buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = OtherDeviceMode + buf[b] = 22 // request opcode b += 1 - buf[b] = Button - b += 1 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - buf[b] = OwnerEvents + buf[b] = DeviceId 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) + b += 3 // padding return buf } -// UngrabDeviceButtonCookie is a cookie used only for UngrabDeviceButton requests. -type UngrabDeviceButtonCookie struct { +// GetSelectedExtensionEventsCookie is a cookie used only for GetSelectedExtensionEvents requests. +type GetSelectedExtensionEventsCookie 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 { +// 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 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectedExtensionEvents' 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(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{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 { +// 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 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectedExtensionEvents' 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(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{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() +// 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)) } -// 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 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 +} - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 +// getSelectedExtensionEventsReply reads a byte slice into a GetSelectedExtensionEventsReply value. +func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { + v := new(GetSelectedExtensionEventsReply) + 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) + v.NumThisClasses = xgb.Get16(buf[b:]) b += 2 - buf[b] = ModifierDevice - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - return buf -} + v.NumAllClasses = xgb.Get16(buf[b:]) + b += 2 -// AllowDeviceEventsCookie is a cookie used only for AllowDeviceEvents requests. -type AllowDeviceEventsCookie struct { - *xgb.Cookie -} + b += 20 // padding -// 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.") + v.ThisClasses = make([]EventClass, v.NumThisClasses) + for i := 0; i < int(v.NumThisClasses); i++ { + v.ThisClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(false, false) - c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) - return AllowDeviceEventsCookie{cookie} -} + b = xgb.Pad(b) -// 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.") + v.AllClasses = make([]EventClass, v.NumAllClasses) + for i := 0; i < int(v.NumAllClasses); i++ { + v.AllClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(true, false) - c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) - return AllowDeviceEventsCookie{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 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 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] = 19 // 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(Time)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - buf[b] = Mode - b += 1 - - buf[b] = DeviceId - b += 1 - return buf } -// GetDeviceFocusCookie is a cookie used only for GetDeviceFocus requests. -type GetDeviceFocusCookie struct { +// GrabDeviceCookie is a cookie used only for GrabDevice requests. +type GrabDeviceCookie 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 { +// GrabDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabDeviceCookie.Reply() +func GrabDevice(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { 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 'GrabDevice' 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(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) + return GrabDeviceCookie{cookie} } -// GetDeviceFocusUnchecked sends an unchecked request. +// GrabDeviceUnchecked 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 GrabDeviceUnchecked(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { 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 'GrabDevice' 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(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) + return GrabDeviceCookie{cookie} } -// GetDeviceFocusReply represents the data returned from a GetDeviceFocus request. -type GetDeviceFocusReply struct { +// GrabDeviceReply represents the data returned from a GrabDevice request. +type GrabDeviceReply 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 + Status 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 GrabDevice request. +func (cook GrabDeviceCookie) Reply() (*GrabDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -6265,12 +6146,12 @@ func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { if buf == nil { return nil, nil } - return getDeviceFocusReply(buf), nil + return grabDeviceReply(buf), nil } -// getDeviceFocusReply reads a byte slice into a GetDeviceFocusReply value. -func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { - v := new(GetDeviceFocusReply) +// grabDeviceReply reads a byte slice into a GrabDeviceReply value. +func grabDeviceReply(buf []byte) *GrabDeviceReply { + v := new(GrabDeviceReply) b := 1 // skip reply determinant b += 1 // padding @@ -6281,240 +6162,283 @@ 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.Status = 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 { - size := 8 +// Write request to wire for GrabDevice +// grabDeviceRequest writes a GrabDevice request to a byte slice. +func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId 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] = 20 // 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(GrabWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + buf[b] = DeviceId b += 1 - b += 3 // padding + 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 } -// SetDeviceFocusCookie is a cookie used only for SetDeviceFocus requests. -type SetDeviceFocusCookie struct { +// GrabDeviceButtonCookie is a cookie used only for GrabDeviceButton requests. +type GrabDeviceButtonCookie struct { *xgb.Cookie } -// SetDeviceFocus 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 SetDeviceFocus(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { +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 'SetDeviceFocus' 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(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) - return SetDeviceFocusCookie{cookie} + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{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 { +// 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 'SetDeviceFocus' 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(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) - return SetDeviceFocusCookie{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 SetDeviceFocusCookie) Check() error { +func (cook GrabDeviceButtonCookie) 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 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] = 21 // 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(Focus)) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 + buf[b] = GrabbedDevice + b += 1 - buf[b] = RevertTo + buf[b] = ModifierDevice b += 1 - buf[b] = DeviceId + 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 } -// GetFeedbackControlCookie is a cookie used only for GetFeedbackControl requests. -type GetFeedbackControlCookie struct { +// GrabDeviceKeyCookie is a cookie used only for GrabDeviceKey requests. +type GrabDeviceKeyCookie 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 { +// GrabDeviceKey sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { 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 'GrabDeviceKey' 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(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) + return GrabDeviceKeyCookie{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 { +// GrabDeviceKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabDeviceKeyCookie.Check() +func GrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { 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 'GrabDeviceKey' 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(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) + return GrabDeviceKeyCookie{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 GrabDeviceKeyCookie) 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 GrabDeviceKey +// grabDeviceKeyRequest writes a GrabDeviceKey request to a byte slice. +func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) []byte { + size := xgb.Pad((20 + 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] = 15 // 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(GrabWindow)) b += 4 - v.NumFeedback = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], NumClasses) b += 2 - b += 22 // padding + xgb.Put16(buf[b:], Modifiers) + b += 2 - return v -} + buf[b] = ModifierDevice + b += 1 -// 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] = GrabbedDevice + b += 1 - buf[b] = c.Extensions["XINPUTEXTENSION"] + buf[b] = Key b += 1 - buf[b] = 22 // request opcode + buf[b] = ThisDeviceMode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + buf[b] = OtherDeviceMode + b += 1 - buf[b] = DeviceId + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - b += 3 // padding + 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 } -// GetDeviceKeyMappingCookie is a cookie used only for GetDeviceKeyMapping requests. -type GetDeviceKeyMappingCookie struct { +// ListInputDevicesCookie is a cookie used only for ListInputDevices requests. +type ListInputDevicesCookie 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 { +// 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 'GetDeviceKeyMapping' 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, true) - c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) - return GetDeviceKeyMappingCookie{cookie} + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} } -// GetDeviceKeyMappingUnchecked sends an unchecked request. +// ListInputDevicesUnchecked 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 ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { 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 'ListInputDevices' 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(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} } -// GetDeviceKeyMappingReply represents the data returned from a GetDeviceKeyMapping request. -type GetDeviceKeyMappingReply struct { +// 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 - KeysymsPerKeycode byte + DevicesLen byte // padding: 23 bytes - Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) + Devices []DeviceInfo // size: xgb.Pad((int(DevicesLen) * 8)) } -// 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 ListInputDevices request. +func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -6522,12 +6446,12 @@ func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) if buf == nil { return nil, nil } - return getDeviceKeyMappingReply(buf), nil + return listInputDevicesReply(buf), nil } -// getDeviceKeyMappingReply reads a byte slice into a GetDeviceKeyMappingReply value. -func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { - v := new(GetDeviceKeyMappingReply) +// listInputDevicesReply reads a byte slice into a ListInputDevicesReply value. +func listInputDevicesReply(buf []byte) *ListInputDevicesReply { + v := new(ListInputDevicesReply) b := 1 // skip reply determinant b += 1 // padding @@ -6538,158 +6462,75 @@ func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.KeysymsPerKeycode = buf[b] + v.DevicesLen = 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) + v.Devices = make([]DeviceInfo, v.DevicesLen) + b += DeviceInfoReadList(buf[b:], v.Devices) 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 -} - -// ChangeDeviceKeyMappingCookie is a cookie used only for ChangeDeviceKeyMapping requests. -type ChangeDeviceKeyMappingCookie struct { - *xgb.Cookie -} - -// 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)))) +// 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] = 25 // 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 - - buf[b] = DeviceId - b += 1 - - buf[b] = byte(FirstKeycode) - b += 1 - - 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) + b += 2 return buf } -// GetDeviceModifierMappingCookie is a cookie used only for GetDeviceModifierMapping requests. -type GetDeviceModifierMappingCookie struct { +// OpenDeviceCookie is a cookie used only for OpenDevice requests. +type OpenDeviceCookie 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 { +// 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 'GetDeviceModifierMapping' 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, true) - c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) - return GetDeviceModifierMappingCookie{cookie} + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{cookie} } -// GetDeviceModifierMappingUnchecked sends an unchecked request. +// OpenDeviceUnchecked 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 OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { 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 'OpenDevice' 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(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{cookie} } -// GetDeviceModifierMappingReply represents the data returned from a GetDeviceModifierMapping request. -type GetDeviceModifierMappingReply struct { +// 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 - KeycodesPerModifier byte + NumClasses byte // padding: 23 bytes - Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) + ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) } -// 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 OpenDevice request. +func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -6697,12 +6538,12 @@ func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingRep if buf == nil { return nil, nil } - return getDeviceModifierMappingReply(buf), nil + return openDeviceReply(buf), nil } -// getDeviceModifierMappingReply reads a byte slice into a GetDeviceModifierMappingReply value. -func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { - v := new(GetDeviceModifierMappingReply) +// openDeviceReply reads a byte slice into a OpenDeviceReply value. +func openDeviceReply(buf []byte) *OpenDeviceReply { + v := new(OpenDeviceReply) b := 1 // skip reply determinant b += 1 // padding @@ -6713,21 +6554,20 @@ func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.KeycodesPerModifier = buf[b] + v.NumClasses = 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))) + v.ClassInfo = make([]InputClassInfo, v.NumClasses) + b += InputClassInfoReadList(buf[b:], v.ClassInfo) 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 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) @@ -6735,7 +6575,7 @@ func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6749,44 +6589,44 @@ func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// SetDeviceModifierMappingCookie is a cookie used only for SetDeviceModifierMapping requests. -type SetDeviceModifierMappingCookie struct { +// QueryDeviceStateCookie is a cookie used only for QueryDeviceState requests. +type QueryDeviceStateCookie struct { *xgb.Cookie } -// SetDeviceModifierMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetDeviceModifierMappingCookie.Reply() -func SetDeviceModifierMapping(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { +// 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 'SetDeviceModifierMapping' 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(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) - return SetDeviceModifierMappingCookie{cookie} + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} } -// SetDeviceModifierMappingUnchecked 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 SetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { +func QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceModifierMapping' 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(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) - return SetDeviceModifierMappingCookie{cookie} + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} } -// SetDeviceModifierMappingReply represents the data returned from a SetDeviceModifierMapping request. -type SetDeviceModifierMappingReply 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 - Status byte + NumClasses byte // padding: 23 bytes } -// Reply blocks and returns the reply data for a SetDeviceModifierMapping request. -func (cook SetDeviceModifierMappingCookie) Reply() (*SetDeviceModifierMappingReply, 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 @@ -6794,12 +6634,12 @@ func (cook SetDeviceModifierMappingCookie) Reply() (*SetDeviceModifierMappingRep if buf == nil { return nil, nil } - return setDeviceModifierMappingReply(buf), nil + return queryDeviceStateReply(buf), nil } -// setDeviceModifierMappingReply reads a byte slice into a SetDeviceModifierMappingReply value. -func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { - v := new(SetDeviceModifierMappingReply) +// 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 @@ -6810,7 +6650,7 @@ func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = buf[b] + v.NumClasses = buf[b] b += 1 b += 23 // padding @@ -6818,17 +6658,17 @@ func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { return v } -// Write request to wire for SetDeviceModifierMapping -// setDeviceModifierMappingRequest writes a SetDeviceModifierMapping request to a byte slice. -func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) []byte { - size := xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +// 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"] 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 @@ -6837,112 +6677,156 @@ func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModi buf[b] = DeviceId b += 1 - buf[b] = KeycodesPerModifier - b += 1 - - b += 1 // padding - - copy(buf[b:], Keymaps[:(int(KeycodesPerModifier)*8)]) - b += xgb.Pad(int((int(KeycodesPerModifier) * 8))) + b += 3 // padding return buf } -// GetDeviceButtonMappingCookie is a cookie used only for GetDeviceButtonMapping requests. -type GetDeviceButtonMappingCookie struct { +// SelectExtensionEventCookie is a cookie used only for SelectExtensionEvent requests. +type SelectExtensionEventCookie 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 { +// 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 { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceButtonMapping' 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, true) - c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) - return GetDeviceButtonMappingCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{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 { +// 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 'GetDeviceButtonMapping' 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, true) - c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) - return GetDeviceButtonMappingCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{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)) +// Check returns an error if one occurred 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() } -// 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 -} +// 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) -// getDeviceButtonMappingReply reads a byte slice into a GetDeviceButtonMappingReply value. -func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { - v := new(GetDeviceButtonMappingReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 - b += 1 // padding + buf[b] = 6 // 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(Window)) b += 4 - v.MapSize = buf[b] - b += 1 + xgb.Put16(buf[b:], NumClasses) + b += 2 - b += 23 // padding + b += 2 // padding - v.Map = make([]byte, v.MapSize) - copy(v.Map[:v.MapSize], buf[b:]) - b += xgb.Pad(int(v.MapSize)) + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) - return v + return buf } -// 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 +// SendExtensionEventCookie is a cookie used only for SendExtensionEvent requests. +type SendExtensionEventCookie struct { + *xgb.Cookie +} + +// 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 'SendExtensionEvent' 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} +} + +// 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 'SendExtensionEvent' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 28 // 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(Destination)) + 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 } @@ -7045,44 +6929,108 @@ func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map return buf } -// QueryDeviceStateCookie is a cookie used only for QueryDeviceState requests. -type QueryDeviceStateCookie struct { +// SetDeviceFocusCookie is a cookie used only for SetDeviceFocus requests. +type SetDeviceFocusCookie 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 { +// SetDeviceFocus 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 { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'QueryDeviceState' 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(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) + return SetDeviceFocusCookie{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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'SetDeviceFocus' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 + + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = RevertTo + b += 1 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// SetDeviceModeCookie is a cookie used only for SetDeviceMode requests. +type SetDeviceModeCookie 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'SetDeviceMode' 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} + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} } -// QueryDeviceStateUnchecked 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 QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { +func SetDeviceModeUnchecked(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'QueryDeviceState' 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(queryDeviceStateRequest(c, DeviceId), cookie) - return QueryDeviceStateCookie{cookie} + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} } -// QueryDeviceStateReply represents the data returned from a QueryDeviceState request. -type QueryDeviceStateReply 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 - NumClasses byte + Status byte // padding: 23 bytes } -// Reply blocks and returns the reply data for a QueryDeviceState request. -func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, 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 @@ -7090,12 +7038,12 @@ func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { if buf == nil { return nil, nil } - return queryDeviceStateReply(buf), nil + return setDeviceModeReply(buf), nil } -// queryDeviceStateReply reads a byte slice into a QueryDeviceStateReply value. -func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { - v := new(QueryDeviceStateReply) +// 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 @@ -7106,7 +7054,7 @@ func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumClasses = buf[b] + v.Status = buf[b] b += 1 b += 23 // padding @@ -7114,9 +7062,9 @@ func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { 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 { +// 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) @@ -7124,7 +7072,7 @@ func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 30 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7133,137 +7081,94 @@ func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { buf[b] = DeviceId b += 1 - b += 3 // padding + buf[b] = Mode + b += 1 + + b += 2 // padding return buf } -// SendExtensionEventCookie is a cookie used only for SendExtensionEvent requests. -type SendExtensionEventCookie struct { +// SetDeviceModifierMappingCookie is a cookie used only for SetDeviceModifierMapping requests. +type SetDeviceModifierMappingCookie struct { *xgb.Cookie } -// 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 { +// SetDeviceModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceModifierMappingCookie.Reply() +func SetDeviceModifierMapping(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { 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 'SetDeviceModifierMapping' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) + return SetDeviceModifierMappingCookie{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 { +// SetDeviceModifierMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SendExtensionEvent' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - 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(Destination)) - 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 + panic("Cannot issue request 'SetDeviceModifierMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - b = xgb.Pad(b) - - return buf -} - -// DeviceBellCookie is a cookie used only for DeviceBell requests. -type DeviceBellCookie struct { - *xgb.Cookie + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) + return SetDeviceModifierMappingCookie{cookie} } -// 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 '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} +// SetDeviceModifierMappingReply represents the data returned from a SetDeviceModifierMapping request. +type SetDeviceModifierMappingReply 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 } -// 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.") +// Reply blocks and returns the reply data for a SetDeviceModifierMapping request. +func (cook SetDeviceModifierMappingCookie) Reply() (*SetDeviceModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } - cookie := c.NewCookie(true, false) - c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return DeviceBellCookie{cookie} + if buf == nil { + return nil, nil + } + return setDeviceModifierMappingReply(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 DeviceBellCookie) Check() error { - return cook.Cookie.Check() +// setDeviceModifierMappingReply reads a byte slice into a SetDeviceModifierMappingReply value. +func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { + v := new(SetDeviceModifierMappingReply) + 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 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 SetDeviceModifierMapping +// setDeviceModifierMappingRequest writes a SetDeviceModifierMapping request to a byte slice. +func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) []byte { + size := xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 32 // request opcode + buf[b] = 27 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -7272,14 +7177,13 @@ func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClas buf[b] = DeviceId b += 1 - buf[b] = FeedbackId + buf[b] = KeycodesPerModifier b += 1 - buf[b] = FeedbackClass - b += 1 + b += 1 // padding - buf[b] = byte(Percent) - b += 1 + copy(buf[b:], Keymaps[:(int(KeycodesPerModifier)*8)]) + b += xgb.Pad(int((int(KeycodesPerModifier) * 8))) return buf } @@ -7389,98 +7293,194 @@ func setDeviceValuatorsRequest(c *xgb.Conn, DeviceId byte, FirstValuator byte, N return buf } -// GetDeviceControlCookie is a cookie used only for GetDeviceControl requests. -type GetDeviceControlCookie struct { +// UngrabDeviceCookie is a cookie used only for UngrabDevice requests. +type UngrabDeviceCookie 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 { +// UngrabDevice 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 { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceControl' 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, true) - c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) - return GetDeviceControlCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{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 { +// 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 'GetDeviceControl' 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, true) - c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) - return GetDeviceControlCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{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 +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// 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 +// 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] = 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(Time)) + b += 4 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// UngrabDeviceButtonCookie is a cookie used only for UngrabDeviceButton requests. +type UngrabDeviceButtonCookie 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'UngrabDeviceButton' 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(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - return getDeviceControlReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{cookie} } -// getDeviceControlReply reads a byte slice into a GetDeviceControlReply value. -func getDeviceControlReply(buf []byte) *GetDeviceControlReply { - v := new(GetDeviceControlReply) - 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 UngrabDeviceButtonCookie) Check() error { + return cook.Cookie.Check() +} - b += 1 // padding +// 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) - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 18 // 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(GrabWindow)) b += 4 - v.Status = buf[b] + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice b += 1 - b += 23 // padding + buf[b] = Button + b += 1 - return v + buf[b] = GrabbedDevice + b += 1 + + return buf } -// 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 +// UngrabDeviceKeyCookie is a cookie used only for UngrabDeviceKey requests. +type UngrabDeviceKeyCookie 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'UngrabDeviceKey' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) + return UngrabDeviceKeyCookie{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() +} + +// 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] = 34 // 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.Put16(buf[b:], ControlId) + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) b += 2 - buf[b] = DeviceId + buf[b] = ModifierDevice b += 1 - b += 1 // padding + buf[b] = Key + b += 1 + + buf[b] = GrabbedDevice + b += 1 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,184 +208,287 @@ 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.") +func init() { + xgb.NewExtEventFuncs["XpExtension"][0] = NotifyEventNew +} + +type Pcontext uint32 + +func NewPcontextId(c *xgb.Conn) (Pcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - cookie := c.NewCookie(false, true) - c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return PrintGetPrinterListCookie{cookie} + return Pcontext(id), nil } -// 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 Printer struct { + NameLen uint32 + Name []String8 // size: xgb.Pad((int(NameLen) * 1)) + DescLen uint32 + Description []String8 // size: xgb.Pad((int(DescLen) * 1)) } -// 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 +// 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 } - if buf == nil { - return nil, nil + 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 } - return printGetPrinterListReply(buf), nil -} + b = xgb.Pad(b) -// printGetPrinterListReply reads a byte slice into a PrintGetPrinterListReply value. -func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { - v := new(PrintGetPrinterListReply) - b := 1 // skip reply determinant + return b +} - b += 1 // padding +// 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) +} - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// 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 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], v.NameLen) b += 4 - v.ListCount = xgb.Get32(buf[b:]) + 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 - b += 20 // padding + for i := 0; i < int(v.DescLen); i++ { + buf[b] = byte(v.Description[i]) + b += 1 + } + b = xgb.Pad(b) - v.Printers = make([]Printer, v.ListCount) - b += PrinterReadList(buf[b:], v.Printers) + return buf +} - return v +// 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 } -// 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)))) +// 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 +} + +type String8 byte + +// 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 +} + +// 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, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return CreateContextCookie{cookie} +} + +// CreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateContextCookie.Check() +func CreateContextChecked(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), 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 CreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. +func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { + size := xgb.Pad(((16 + 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] = 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:], ContextId) + b += 4 + xgb.Put32(buf[b:], PrinterNameLen) b += 4 @@ -636,167 +510,215 @@ func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen ui return buf } -// PrintRehashPrinterListCookie is a cookie used only for PrintRehashPrinterList requests. -type PrintRehashPrinterListCookie struct { +// PrintDestroyContextCookie is a cookie used only for PrintDestroyContext requests. +type PrintDestroyContextCookie struct { + *xgb.Cookie +} + +// PrintDestroyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintDestroyContext(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintDestroyContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printDestroyContextRequest(c, Context), cookie) + return PrintDestroyContextCookie{cookie} +} + +// PrintDestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintDestroyContextCookie.Check() +func PrintDestroyContextChecked(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintDestroyContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printDestroyContextRequest(c, Context), cookie) + return PrintDestroyContextCookie{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 PrintDestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintDestroyContext +// printDestroyContextRequest writes a PrintDestroyContext request to a byte slice. +func printDestroyContextRequest(c *xgb.Conn, Context uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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:], Context) + b += 4 + + return buf +} + +// PrintEndDocCookie is a cookie used only for PrintEndDoc requests. +type PrintEndDocCookie struct { *xgb.Cookie } -// PrintRehashPrinterList 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 PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { +func PrintEndDoc(c *xgb.Conn, Cancel bool) PrintEndDocCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintRehashPrinterList' 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(printRehashPrinterListRequest(c), cookie) - return PrintRehashPrinterListCookie{cookie} + c.NewRequest(printEndDocRequest(c, Cancel), cookie) + return PrintEndDocCookie{cookie} } -// PrintRehashPrinterListChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintRehashPrinterListCookie.Check() -func PrintRehashPrinterListChecked(c *xgb.Conn) PrintRehashPrinterListCookie { +// 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 'PrintRehashPrinterList' 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(printRehashPrinterListRequest(c), cookie) - return PrintRehashPrinterListCookie{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 PrintRehashPrinterListCookie) Check() error { +func (cook PrintEndDocCookie) 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 +// 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) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 20 // 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 + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + return buf } -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { +// PrintEndJobCookie is a cookie used only for PrintEndJob requests. +type PrintEndJobCookie struct { *xgb.Cookie } -// CreateContext sends an unchecked request. +// PrintEndJob sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateContext(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { +func PrintEndJob(c *xgb.Conn, Cancel bool) PrintEndJobCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintEndJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return CreateContextCookie{cookie} + c.NewRequest(printEndJobRequest(c, Cancel), cookie) + return PrintEndJobCookie{cookie} } -// CreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateContextCookie.Check() -func CreateContextChecked(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { +// PrintEndJobChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintEndJobCookie.Check() +func PrintEndJobChecked(c *xgb.Conn, Cancel bool) PrintEndJobCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintEndJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return CreateContextCookie{cookie} + c.NewRequest(printEndJobRequest(c, Cancel), cookie) + return PrintEndJobCookie{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 CreateContextCookie) Check() error { +func (cook PrintEndJobCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateContext -// createContextRequest writes a CreateContext request to a byte slice. -func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { - size := xgb.Pad(((16 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +// Write request to wire for PrintEndJob +// printEndJobRequest writes a PrintEndJob request to a byte slice. +func printEndJobRequest(c *xgb.Conn, Cancel bool) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] 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 - xgb.Put32(buf[b:], ContextId) - b += 4 - - 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 + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 } - b = xgb.Pad(b) + b += 1 return buf } -// PrintSetContextCookie is a cookie used only for PrintSetContext requests. -type PrintSetContextCookie struct { +// PrintEndPageCookie is a cookie used only for PrintEndPage requests. +type PrintEndPageCookie struct { *xgb.Cookie } -// PrintSetContext 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 PrintSetContext(c *xgb.Conn, Context uint32) PrintSetContextCookie { +func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSetContext' 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(printSetContextRequest(c, Context), cookie) - return PrintSetContextCookie{cookie} + c.NewRequest(printEndPageRequest(c, Cancel), cookie) + return PrintEndPageCookie{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 { +// 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 'PrintSetContext' 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(printSetContextRequest(c, Context), cookie) - return PrintSetContextCookie{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 PrintSetContextCookie) Check() error { +func (cook PrintEndPageCookie) 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 { +// 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) @@ -804,55 +726,63 @@ func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 3 // 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:], Context) - b += 4 + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding return buf } -// PrintGetContextCookie is a cookie used only for PrintGetContext requests. -type PrintGetContextCookie struct { +// PrintGetAttributesCookie is a cookie used only for PrintGetAttributes requests. +type PrintGetAttributesCookie 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 { +// 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 'PrintGetContext' 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, true) - c.NewRequest(printGetContextRequest(c), cookie) - return PrintGetContextCookie{cookie} + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{cookie} } -// PrintGetContextUnchecked sends an unchecked request. +// PrintGetAttributesUnchecked 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 { +func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetContext' 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, true) - c.NewRequest(printGetContextRequest(c), cookie) - return PrintGetContextCookie{cookie} + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{cookie} } -// PrintGetContextReply represents the data returned from a PrintGetContext request. -type PrintGetContextReply struct { +// 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 - Context uint32 + StringLen uint32 + // padding: 20 bytes + Attributes String8 } -// Reply blocks and returns the reply data for a PrintGetContext request. -func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { +// 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 @@ -860,12 +790,12 @@ func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { if buf == nil { return nil, nil } - return printGetContextReply(buf), nil + return printGetAttributesReply(buf), nil } -// printGetContextReply reads a byte slice into a PrintGetContextReply value. -func printGetContextReply(buf []byte) *PrintGetContextReply { - v := new(PrintGetContextReply) +// 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 @@ -876,123 +806,81 @@ func printGetContextReply(buf []byte) *PrintGetContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Context = xgb.Get32(buf[b:]) + v.StringLen = 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 + b += 20 // padding - buf[b] = 4 // request opcode + v.Attributes = String8(buf[b]) 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 -} - -// PrintDestroyContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintDestroyContext(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintDestroyContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(printDestroyContextRequest(c, Context), cookie) - return PrintDestroyContextCookie{cookie} -} - -// PrintDestroyContextChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintDestroyContextCookie.Check() -func PrintDestroyContextChecked(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintDestroyContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(printDestroyContextRequest(c, Context), cookie) - return PrintDestroyContextCookie{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 PrintDestroyContextCookie) Check() error { - return cook.Cookie.Check() + return v } - -// Write request to wire for PrintDestroyContext -// printDestroyContextRequest writes a PrintDestroyContext request to a byte slice. -func printDestroyContextRequest(c *xgb.Conn, Context uint32) []byte { - size := 8 + +// 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] = 5 // 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:], Context) + xgb.Put32(buf[b:], uint32(Context)) b += 4 + buf[b] = Pool + b += 1 + + b += 3 // padding + return buf } -// PrintGetScreenOfContextCookie is a cookie used only for PrintGetScreenOfContext requests. -type PrintGetScreenOfContextCookie struct { +// PrintGetContextCookie is a cookie used only for PrintGetContext requests. +type PrintGetContextCookie 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 { +// 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 'PrintGetScreenOfContext' 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, true) - c.NewRequest(printGetScreenOfContextRequest(c), cookie) - return PrintGetScreenOfContextCookie{cookie} + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{cookie} } -// PrintGetScreenOfContextUnchecked sends an unchecked request. +// PrintGetContextUnchecked 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 { +func PrintGetContextUnchecked(c *xgb.Conn) PrintGetContextCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetScreenOfContext' 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, true) - c.NewRequest(printGetScreenOfContextRequest(c), cookie) - return PrintGetScreenOfContextCookie{cookie} + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{cookie} } -// PrintGetScreenOfContextReply represents the data returned from a PrintGetScreenOfContext request. -type PrintGetScreenOfContextReply struct { +// 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 - Root xproto.Window + Context uint32 } -// Reply blocks and returns the reply data for a PrintGetScreenOfContext request. -func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { +// 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 @@ -1000,12 +888,12 @@ func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply if buf == nil { return nil, nil } - return printGetScreenOfContextReply(buf), nil + return printGetContextReply(buf), nil } -// printGetScreenOfContextReply reads a byte slice into a PrintGetScreenOfContextReply value. -func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { - v := new(PrintGetScreenOfContextReply) +// 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 @@ -1016,15 +904,15 @@ func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Root = xproto.Window(xgb.Get32(buf[b:])) + v.Context = 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 { +// 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) @@ -1032,7 +920,7 @@ func printGetScreenOfContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["XPEXTENSION"] 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 @@ -1041,156 +929,182 @@ func printGetScreenOfContextRequest(c *xgb.Conn) []byte { return buf } -// PrintStartJobCookie is a cookie used only for PrintStartJob requests. -type PrintStartJobCookie struct { +// PrintGetDocumentDataCookie is a cookie used only for PrintGetDocumentData requests. +type PrintGetDocumentDataCookie 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 { +// PrintGetDocumentData sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetDocumentDataCookie.Reply() +func PrintGetDocumentData(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { 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 'PrintGetDocumentData' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) + return PrintGetDocumentDataCookie{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 { +// PrintGetDocumentDataUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetDocumentDataUnchecked(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { 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 'PrintGetDocumentData' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) + return PrintGetDocumentDataCookie{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 { - return cook.Cookie.Check() +// PrintGetDocumentDataReply represents the data returned from a PrintGetDocumentData request. +type PrintGetDocumentDataReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + StatusCode uint32 + FinishedFlag uint32 + DataLen uint32 + // padding: 12 bytes + Data []byte // size: xgb.Pad((int(DataLen) * 1)) } -// 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) +// Reply blocks and returns the reply data for a PrintGetDocumentData request. +func (cook PrintGetDocumentDataCookie) Reply() (*PrintGetDocumentDataReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetDocumentDataReply(buf), nil +} - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 +// printGetDocumentDataReply reads a byte slice into a PrintGetDocumentDataReply value. +func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { + v := new(PrintGetDocumentDataReply) + b := 1 // skip reply determinant - buf[b] = 7 // 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 - buf[b] = OutputMode - b += 1 + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - return buf -} + v.StatusCode = xgb.Get32(buf[b:]) + b += 4 -// PrintEndJobCookie is a cookie used only for PrintEndJob requests. -type PrintEndJobCookie struct { - *xgb.Cookie -} + v.FinishedFlag = xgb.Get32(buf[b:]) + b += 4 -// PrintEndJob sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintEndJob(c *xgb.Conn, Cancel bool) PrintEndJobCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(printEndJobRequest(c, Cancel), cookie) - return PrintEndJobCookie{cookie} -} + v.DataLen = xgb.Get32(buf[b:]) + b += 4 -// PrintEndJobChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintEndJobCookie.Check() -func PrintEndJobChecked(c *xgb.Conn, Cancel bool) PrintEndJobCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndJob' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(printEndJobRequest(c, Cancel), cookie) - return PrintEndJobCookie{cookie} -} + b += 12 // 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 PrintEndJobCookie) Check() error { - return cook.Cookie.Check() + v.Data = make([]byte, v.DataLen) + copy(v.Data[:v.DataLen], buf[b:]) + b += xgb.Pad(int(v.DataLen)) + + return v } -// Write request to wire for PrintEndJob -// printEndJobRequest writes a PrintEndJob request to a byte slice. -func printEndJobRequest(c *xgb.Conn, Cancel bool) []byte { - size := 8 +// Write request to wire for PrintGetDocumentData +// printGetDocumentDataRequest writes a PrintGetDocumentData request to a byte slice. +func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 8 // 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 - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], MaxBytes) + b += 4 return buf } -// PrintStartDocCookie is a cookie used only for PrintStartDoc requests. -type PrintStartDocCookie struct { +// PrintGetImageResolutionCookie is a cookie used only for PrintGetImageResolution requests. +type PrintGetImageResolutionCookie struct { *xgb.Cookie } -// 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 { +// 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 'PrintStartDoc' 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(printStartDocRequest(c, DriverMode), cookie) - return PrintStartDocCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{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 { +// 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 'PrintStartDoc' 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, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{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 +} + +// 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(printStartDocRequest(c, DriverMode), cookie) - return PrintStartDocCookie{cookie} + return printGetImageResolutionReply(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 PrintStartDocCookie) Check() error { - return cook.Cookie.Check() +// 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 PrintStartDoc -// printStartDocRequest writes a PrintStartDoc request to a byte slice. -func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { +// 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) @@ -1198,149 +1112,124 @@ func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 9 // 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 - buf[b] = DriverMode - b += 1 + xgb.Put32(buf[b:], uint32(Context)) + b += 4 return buf } -// PrintEndDocCookie is a cookie used only for PrintEndDoc requests. -type PrintEndDocCookie struct { +// PrintGetOneAttributesCookie is a cookie used only for PrintGetOneAttributes requests. +type PrintGetOneAttributesCookie 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 { +// 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 'PrintEndDoc' 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(printEndDocRequest(c, Cancel), cookie) - return PrintEndDocCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) + return PrintGetOneAttributesCookie{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 { +// 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 'PrintEndDoc' 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(printEndDocRequest(c, Cancel), cookie) - return PrintEndDocCookie{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 PrintEndDocCookie) 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 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) +// 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 +} - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 +// printGetOneAttributesReply reads a byte slice into a PrintGetOneAttributesReply value. +func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { + v := new(PrintGetOneAttributesReply) + 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 - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// PrintPutDocumentDataCookie is a cookie used only for PrintPutDocumentData requests. -type PrintPutDocumentDataCookie struct { - *xgb.Cookie -} + v.ValueLen = xgb.Get32(buf[b:]) + b += 4 -// 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 { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintPutDocumentData' 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} -} + b += 20 // padding -// 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 'PrintPutDocumentData' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + v.Value = make([]String8, v.ValueLen) + for i := 0; i < int(v.ValueLen); i++ { + v.Value[i] = String8(buf[b]) + b += 1 } - cookie := c.NewCookie(true, false) - c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return PrintPutDocumentDataCookie{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 PrintPutDocumentDataCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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)))) +// 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] = 11 // 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(Drawable)) + xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], LenData) + xgb.Put32(buf[b:], NameLen) b += 4 - xgb.Put16(buf[b:], LenFmt) - b += 2 - - xgb.Put16(buf[b:], LenOptions) - b += 2 - - copy(buf[b:], Data[:LenData]) - b += xgb.Pad(int(LenData)) + buf[b] = Pool + b += 1 - for i := 0; i < int(len(DocFormat)); i++ { - buf[b] = byte(DocFormat[i]) - b += 1 - } - b = xgb.Pad(b) + b += 3 // padding - for i := 0; i < int(len(Options)); i++ { - buf[b] = byte(Options[i]) + for i := 0; i < int(NameLen); i++ { + buf[b] = byte(Name[i]) b += 1 } b = xgb.Pad(b) @@ -1348,47 +1237,48 @@ func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData return buf } -// PrintGetDocumentDataCookie is a cookie used only for PrintGetDocumentData requests. -type PrintGetDocumentDataCookie struct { +// PrintGetPageDimensionsCookie is a cookie used only for PrintGetPageDimensions requests. +type PrintGetPageDimensionsCookie struct { *xgb.Cookie } -// PrintGetDocumentData sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetDocumentDataCookie.Reply() -func PrintGetDocumentData(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { +// 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 'PrintGetDocumentData' 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, true) - c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) - return PrintGetDocumentDataCookie{cookie} + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{cookie} } -// PrintGetDocumentDataUnchecked sends an unchecked request. +// PrintGetPageDimensionsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetDocumentDataUnchecked(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { +func PrintGetPageDimensionsUnchecked(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetDocumentData' 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, true) - c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) - return PrintGetDocumentDataCookie{cookie} + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{cookie} } -// PrintGetDocumentDataReply represents the data returned from a PrintGetDocumentData request. -type PrintGetDocumentDataReply struct { +// 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 - StatusCode uint32 - FinishedFlag uint32 - DataLen uint32 - // padding: 12 bytes - Data []byte // size: xgb.Pad((int(DataLen) * 1)) + Width uint16 + Height uint16 + OffsetX uint16 + OffsetY uint16 + ReproducibleWidth uint16 + ReproducibleHeight uint16 } -// Reply blocks and returns the reply data for a PrintGetDocumentData request. -func (cook PrintGetDocumentDataCookie) Reply() (*PrintGetDocumentDataReply, error) { +// 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 @@ -1396,12 +1286,12 @@ func (cook PrintGetDocumentDataCookie) Reply() (*PrintGetDocumentDataReply, erro if buf == nil { return nil, nil } - return printGetDocumentDataReply(buf), nil + return printGetPageDimensionsReply(buf), nil } -// printGetDocumentDataReply reads a byte slice into a PrintGetDocumentDataReply value. -func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { - v := new(PrintGetDocumentDataReply) +// 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 @@ -1412,35 +1302,38 @@ func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.StatusCode = xgb.Get32(buf[b:]) - b += 4 + v.Width = xgb.Get16(buf[b:]) + b += 2 - v.FinishedFlag = xgb.Get32(buf[b:]) - b += 4 + v.Height = xgb.Get16(buf[b:]) + b += 2 - v.DataLen = xgb.Get32(buf[b:]) - b += 4 + v.OffsetX = xgb.Get16(buf[b:]) + b += 2 - b += 12 // padding + v.OffsetY = xgb.Get16(buf[b:]) + b += 2 - v.Data = make([]byte, v.DataLen) - copy(v.Data[:v.DataLen], buf[b:]) - b += xgb.Pad(int(v.DataLen)) + v.ReproducibleWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ReproducibleHeight = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for PrintGetDocumentData -// printGetDocumentDataRequest writes a PrintGetDocumentData request to a byte slice. -func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) []byte { - size := 12 +// 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] = 12 // request opcode + buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1449,187 +1342,200 @@ func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) xgb.Put32(buf[b:], uint32(Context)) b += 4 - xgb.Put32(buf[b:], MaxBytes) - b += 4 - return buf } -// PrintStartPageCookie is a cookie used only for PrintStartPage requests. -type PrintStartPageCookie struct { +// PrintGetPrinterListCookie is a cookie used only for PrintGetPrinterList requests. +type PrintGetPrinterListCookie 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 { +// 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 'PrintStartPage' 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, false) - c.NewRequest(printStartPageRequest(c, Window), cookie) - return PrintStartPageCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{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 { +// 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 'PrintStartPage' 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, false) - c.NewRequest(printStartPageRequest(c, Window), cookie) - return PrintStartPageCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{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() +// 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) } -// 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) +// 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 + } + if buf == nil { + return nil, nil + } + return printGetPrinterListReply(buf), nil +} - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 +// printGetPrinterListReply reads a byte slice into a PrintGetPrinterListReply value. +func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { + v := new(PrintGetPrinterListReply) + b := 1 // skip reply determinant - buf[b] = 13 // 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(Window)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} - -// PrintEndPageCookie is a cookie used only for PrintEndPage requests. -type PrintEndPageCookie struct { - *xgb.Cookie -} + v.ListCount = xgb.Get32(buf[b:]) + b += 4 -// 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 { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndPage' 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} -} + b += 20 // padding -// 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 'PrintEndPage' 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} -} + v.Printers = make([]Printer, v.ListCount) + b += PrinterReadList(buf[b:], v.Printers) -// Check returns an error if one occurred 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() + return v } -// 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 +// 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] = 14 // 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 - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 + 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 += 1 + b = xgb.Pad(b) - b += 3 // padding + for i := 0; i < int(LocaleLen); i++ { + buf[b] = byte(Locale[i]) + b += 1 + } + b = xgb.Pad(b) return buf } -// PrintSelectInputCookie is a cookie used only for PrintSelectInput requests. -type PrintSelectInputCookie struct { +// PrintGetScreenOfContextCookie is a cookie used only for PrintGetScreenOfContext requests. +type PrintGetScreenOfContextCookie 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 { +// 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 'PrintSelectInput' 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, false) - c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) - return PrintSelectInputCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{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 { +// 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 'PrintSelectInput' 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, false) - c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) - return PrintSelectInputCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{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() +// 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 } -// 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) +// 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 +} - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 +// printGetScreenOfContextReply reads a byte slice into a PrintGetScreenOfContextReply value. +func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { + v := new(PrintGetScreenOfContextReply) + b := 1 // skip reply determinant - buf[b] = 15 // 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(Context)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], EventMask) + v.Root = xproto.Window(xgb.Get32(buf[b:])) 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 +} + +// 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 } @@ -1742,145 +1648,124 @@ func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { return buf } -// PrintGetAttributesCookie is a cookie used only for PrintGetAttributes requests. -type PrintGetAttributesCookie struct { +// PrintPutDocumentDataCookie is a cookie used only for PrintPutDocumentData requests. +type PrintPutDocumentDataCookie 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 { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetAttributes' 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} -} - -// PrintGetAttributesUnchecked 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 PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { +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 'PrintGetAttributes' 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, true) - c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) - return PrintGetAttributesCookie{cookie} -} - -// 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 + cookie := c.NewCookie(false, false) + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} } -// 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 +// 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 'PrintPutDocumentData' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - return printGetAttributesReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} } -// 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 +// Check returns an error if one occurred 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() } -// 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 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] = 17 // 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 - buf[b] = Pool - b += 1 + xgb.Put32(buf[b:], LenData) + b += 4 - b += 3 // padding + xgb.Put16(buf[b:], LenFmt) + b += 2 + + xgb.Put16(buf[b:], LenOptions) + b += 2 + + copy(buf[b:], Data[:LenData]) + b += xgb.Pad(int(LenData)) + + 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) return buf } -// PrintGetOneAttributesCookie is a cookie used only for PrintGetOneAttributes requests. -type PrintGetOneAttributesCookie struct { +// PrintQueryScreensCookie is a cookie used only for PrintQueryScreens requests. +type PrintQueryScreensCookie 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 { +// 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 'PrintGetOneAttributes' 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(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) - return PrintGetOneAttributesCookie{cookie} + c.NewRequest(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} } -// PrintGetOneAttributesUnchecked 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 PrintGetOneAttributesUnchecked(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { +func PrintQueryScreensUnchecked(c *xgb.Conn) PrintQueryScreensCookie { 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 'PrintQueryScreens' 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(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} } -// PrintGetOneAttributesReply represents the data returned from a PrintGetOneAttributes request. -type PrintGetOneAttributesReply 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 - ValueLen uint32 + ListCount uint32 // padding: 20 bytes - Value []String8 // size: xgb.Pad((int(ValueLen) * 1)) + Roots []xproto.Window // size: xgb.Pad((int(ListCount) * 4)) } -// 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 PrintQueryScreens request. +func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1888,12 +1773,12 @@ func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, er if buf == nil { return nil, nil } - return printGetOneAttributesReply(buf), nil + return printQueryScreensReply(buf), nil } -// printGetOneAttributesReply reads a byte slice into a PrintGetOneAttributesReply value. -func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { - v := new(PrintGetOneAttributesReply) +// 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 @@ -1904,171 +1789,78 @@ func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ValueLen = xgb.Get32(buf[b:]) + v.ListCount = 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 + 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 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] = 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(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 { - *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)))) +// 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] = 18 // 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 - - 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 } -// PrintGetPageDimensionsCookie is a cookie used only for PrintGetPageDimensions requests. -type PrintGetPageDimensionsCookie struct { +// PrintQueryVersionCookie is a cookie used only for PrintQueryVersion requests. +type PrintQueryVersionCookie 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 { +// 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 'PrintGetPageDimensions' 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(printGetPageDimensionsRequest(c, Context), cookie) - return PrintGetPageDimensionsCookie{cookie} + c.NewRequest(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} } -// PrintGetPageDimensionsUnchecked 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 PrintGetPageDimensionsUnchecked(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { +func PrintQueryVersionUnchecked(c *xgb.Conn) PrintQueryVersionCookie { 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 'PrintQueryVersion' 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(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} } -// PrintGetPageDimensionsReply represents the data returned from a PrintGetPageDimensions request. -type PrintGetPageDimensionsReply 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 - Width uint16 - Height uint16 - OffsetX uint16 - OffsetY uint16 - ReproducibleWidth uint16 - ReproducibleHeight uint16 + MajorVersion uint16 + MinorVersion uint16 } -// 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 PrintQueryVersion request. +func (cook PrintQueryVersionCookie) Reply() (*PrintQueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2076,12 +1868,12 @@ func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, if buf == nil { return nil, nil } - return printGetPageDimensionsReply(buf), nil + return printQueryVersionReply(buf), nil } -// printGetPageDimensionsReply reads a byte slice into a PrintGetPageDimensionsReply value. -func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { - v := new(PrintGetPageDimensionsReply) +// 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 @@ -2092,142 +1884,273 @@ func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Width = xgb.Get16(buf[b:]) + v.MajorVersion = xgb.Get16(buf[b:]) b += 2 - v.Height = xgb.Get16(buf[b:]) + v.MinorVersion = xgb.Get16(buf[b:]) b += 2 - v.OffsetX = xgb.Get16(buf[b:]) - b += 2 + return v +} - v.OffsetY = xgb.Get16(buf[b:]) - b += 2 +// 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) - v.ReproducibleWidth = xgb.Get16(buf[b:]) - b += 2 + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 - v.ReproducibleHeight = xgb.Get16(buf[b:]) + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return v + return buf } -// 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 +// 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] = 21 // 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(Context)) - b += 4 - return buf } -// PrintQueryScreensCookie is a cookie used only for PrintQueryScreens requests. -type PrintQueryScreensCookie struct { +// PrintSelectInputCookie is a cookie used only for PrintSelectInput requests. +type PrintSelectInputCookie 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 { +// 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 'PrintQueryScreens' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintSelectInput' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} } -// PrintQueryScreensUnchecked 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 { +// 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 'PrintQueryScreens' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintSelectInput' 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} + cookie := c.NewCookie(true, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} } -// 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 - ListCount uint32 - // padding: 20 bytes - Roots []xproto.Window // size: xgb.Pad((int(ListCount) * 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 PrintSelectInputCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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 } - if buf == nil { - return nil, nil + b = xgb.Pad(b) + + return buf +} + +// 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.") } - return printQueryScreensReply(buf), nil + 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() } -// printQueryScreensReply reads a byte slice into a PrintQueryScreensReply value. -func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { - v := new(PrintQueryScreensReply) - b := 1 // skip reply determinant +// 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) - b += 1 // padding + buf[b] = c.Extensions["XPEXTENSION"] + 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 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Context)) b += 4 - v.ListCount = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], StringLen) b += 4 - b += 20 // padding + buf[b] = Pool + b += 1 - 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 + 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 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 +// 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] = 22 // 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:], 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,179 +23,211 @@ 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) +} -const ( - TimeCurrentTime = 0 -) +// Bytes writes a Arc value to a byte slice. +func (v Arc) Bytes() []byte { + buf := make([]byte, 12) + b := 0 -const ( - AtomNone = 0 - AtomAny = 0 - AtomPrimary = 1 - AtomSecondary = 2 - AtomArc = 3 - AtomAtom = 4 - AtomBitmap = 5 - AtomCardinal = 6 - AtomColormap = 7 - AtomCursor = 8 - AtomCutBuffer0 = 9 - AtomCutBuffer1 = 10 - AtomCutBuffer2 = 11 - AtomCutBuffer3 = 12 - AtomCutBuffer4 = 13 + 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 ( + 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 + AtomPrimary = 1 + AtomSecondary = 2 + AtomArc = 3 + AtomAtom = 4 + AtomBitmap = 5 + AtomCardinal = 6 + AtomColormap = 7 + AtomCursor = 8 + AtomCutBuffer0 = 9 + AtomCutBuffer1 = 10 + AtomCutBuffer2 = 11 + AtomCutBuffer3 = 12 + AtomCutBuffer4 = 13 AtomCutBuffer5 = 14 AtomCutBuffer6 = 15 AtomCutBuffer7 = 16 @@ -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,665 +358,845 @@ const ( ) const ( - GrabAny = 0 + ButtonMask1 = 256 + ButtonMask2 = 512 + ButtonMask3 = 1024 + ButtonMask4 = 2048 + ButtonMask5 = 4096 + ButtonMaskAny = 32768 ) -const ( - AllowAsyncPointer = 0 - AllowSyncPointer = 1 - AllowReplayPointer = 2 - AllowAsyncKeyboard = 3 - AllowSyncKeyboard = 4 - AllowReplayKeyboard = 5 - AllowAsyncBoth = 6 - AllowSyncBoth = 7 -) +// ButtonPress is the event number for a ButtonPressEvent. +const ButtonPress = 4 -const ( - InputFocusNone = 0 - InputFocusPointerRoot = 1 - InputFocusParent = 2 - InputFocusFollowKeyboard = 3 -) +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 +} -const ( - FontDrawLeftToRight = 0 - FontDrawRightToLeft = 1 -) +// 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 -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 -) + v.Detail = Button(buf[b]) + b += 1 -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 -) + 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:])) + b += 4 + + v.Child = 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 + } + b += 1 + + b += 1 // padding + + return v +} + +// Bytes writes a ButtonPressEvent value to a byte slice. +func (v ButtonPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 4 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + 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)) + 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.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + 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 + + b += 1 // padding + + return buf +} + +// 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[4] = ButtonPressEventNew +} + +// ButtonRelease is the event number for a ButtonReleaseEvent. +const ButtonRelease = 5 + +type ButtonReleaseEvent ButtonPressEvent + +// ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. +func ButtonReleaseEventNew(buf []byte) xgb.Event { + return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) +} + +// Bytes writes a ButtonReleaseEvent value to a byte slice. +func (v ButtonReleaseEvent) Bytes() []byte { + return ButtonPressEvent(v).Bytes() +} + +// 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 +} + +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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[5] = ButtonReleaseEventNew +} const ( - LineStyleSolid = 0 - LineStyleOnOffDash = 1 - LineStyleDoubleDash = 2 + CapStyleNotLast = 0 + CapStyleButt = 1 + CapStyleRound = 2 + CapStyleProjecting = 3 ) -const ( - CapStyleNotLast = 0 - CapStyleButt = 1 - CapStyleRound = 2 - CapStyleProjecting = 3 -) +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 Charinfo struct { + LeftSideBearing int16 + RightSideBearing int16 + CharacterWidth int16 + Ascent int16 + Descent int16 + Attributes uint16 +} + +// CharinfoRead reads a byte slice into a Charinfo value. +func CharinfoRead(buf []byte, v *Charinfo) int { + b := 0 + + v.LeftSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RightSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.CharacterWidth = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Ascent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Descent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Attributes = xgb.Get16(buf[b:]) + b += 2 -const ( - JoinStyleMiter = 0 - JoinStyleRound = 1 - JoinStyleBevel = 2 -) + return b +} -const ( - FillStyleSolid = 0 - FillStyleTiled = 1 - FillStyleStippled = 2 - FillStyleOpaqueStippled = 3 -) +// CharinfoReadList reads a byte slice into a list of Charinfo values. +func CharinfoReadList(buf []byte, dest []Charinfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Charinfo{} + b += CharinfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} -const ( - FillRuleEvenOdd = 0 - FillRuleWinding = 1 -) +// Bytes writes a Charinfo value to a byte slice. +func (v Charinfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 -const ( - SubwindowModeClipByChildren = 0 - SubwindowModeIncludeInferiors = 1 -) + xgb.Put16(buf[b:], uint16(v.LeftSideBearing)) + b += 2 -const ( - ArcModeChord = 0 - ArcModePieSlice = 1 -) + xgb.Put16(buf[b:], uint16(v.RightSideBearing)) + b += 2 -const ( - ClipOrderingUnsorted = 0 - ClipOrderingYSorted = 1 - ClipOrderingYXSorted = 2 - ClipOrderingYXBanded = 3 -) + xgb.Put16(buf[b:], uint16(v.CharacterWidth)) + b += 2 -const ( - CoordModeOrigin = 0 - CoordModePrevious = 1 -) + xgb.Put16(buf[b:], uint16(v.Ascent)) + b += 2 -const ( - PolyShapeComplex = 0 - PolyShapeNonconvex = 1 - PolyShapeConvex = 2 -) + xgb.Put16(buf[b:], uint16(v.Descent)) + b += 2 -const ( - ImageFormatXYBitmap = 0 - ImageFormatXYPixmap = 1 - ImageFormatZPixmap = 2 -) + xgb.Put16(buf[b:], v.Attributes) + b += 2 -const ( - ColormapAllocNone = 0 - ColormapAllocAll = 1 -) + return buf +} -const ( - ColorFlagRed = 1 - ColorFlagGreen = 2 - ColorFlagBlue = 4 -) +// CharinfoListBytes writes a list of Charinfo values to a byte slice. +func CharinfoListBytes(buf []byte, list []Charinfo) 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 ( - PixmapNone = 0 + CirculateRaiseLowest = 0 + CirculateLowerHighest = 1 ) -const ( - FontNone = 0 -) +// CirculateNotify is the event number for a CirculateNotifyEvent. +const CirculateNotify = 26 -const ( - QueryShapeOfLargestCursor = 0 - QueryShapeOfFastestTile = 1 - QueryShapeOfFastestStipple = 2 -) +type CirculateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + // padding: 4 bytes + Place byte + // padding: 3 bytes +} -const ( - KbKeyClickPercent = 1 - KbBellPercent = 2 - KbBellPitch = 4 - KbBellDuration = 8 - KbLed = 16 - KbLedMode = 32 - KbKey = 64 - KbAutoRepeatMode = 128 -) +// 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 -const ( - LedModeOff = 0 - LedModeOn = 1 -) + b += 1 // padding -const ( - AutoRepeatModeOff = 0 - AutoRepeatModeOn = 1 - AutoRepeatModeDefault = 2 -) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -const ( - BlankingNotPreferred = 0 - BlankingPreferred = 1 - BlankingDefault = 2 -) + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 -const ( - ExposuresNotAllowed = 0 - ExposuresAllowed = 1 - ExposuresDefault = 2 -) + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 -const ( - HostModeInsert = 0 - HostModeDelete = 1 -) + b += 4 // padding -const ( - FamilyInternet = 0 - FamilyDECnet = 1 - FamilyChaos = 2 - FamilyServerInterpreted = 5 - FamilyInternet6 = 6 -) + v.Place = buf[b] + b += 1 -const ( - AccessControlDisable = 0 - AccessControlEnable = 1 -) + b += 3 // padding -const ( - CloseDownDestroyAll = 0 - CloseDownRetainPermanent = 1 - CloseDownRetainTemporary = 2 -) + return v +} -const ( - KillAllTemporary = 0 -) +// Bytes writes a CirculateNotifyEvent value to a byte slice. +func (v CirculateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 -const ( - ScreenSaverReset = 0 - ScreenSaverActive = 1 -) + // write event number + buf[b] = 26 + b += 1 -const ( - MappingStatusSuccess = 0 - MappingStatusBusy = 1 - MappingStatusFailure = 2 -) + b += 1 // padding -const ( - MapIndexShift = 0 - MapIndexLock = 1 - MapIndexControl = 2 - MapIndex1 = 3 - MapIndex2 = 4 - MapIndex3 = 5 - MapIndex4 = 6 - MapIndex5 = 7 -) + b += 2 // skip sequence number -type Window uint32 + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 -func NewWindowId(c *xgb.Conn) (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 -type Pixmap uint32 + b += 4 // padding -func NewPixmapId(c *xgb.Conn) (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} + buf[b] = v.Place + b += 1 -type Cursor uint32 + b += 3 // padding -func NewCursorId(c *xgb.Conn) (Cursor, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Cursor(id), nil + return buf +} + +// 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 Font uint32 - -func NewFontId(c *xgb.Conn) (Font, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Font(id), nil +// 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, ", ") + "}" } -type Gcontext uint32 - -func NewGcontextId(c *xgb.Conn) (Gcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Gcontext(id), nil +func init() { + xgb.NewEventFuncs[26] = CirculateNotifyEventNew } -type Colormap uint32 +// CirculateRequest is the event number for a CirculateRequestEvent. +const CirculateRequest = 27 -func NewColormapId(c *xgb.Conn) (Colormap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Colormap(id), nil +type CirculateRequestEvent CirculateNotifyEvent + +// 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 Atom uint32 +// Bytes writes a CirculateRequestEvent value to a byte slice. +func (v CirculateRequestEvent) Bytes() []byte { + return CirculateNotifyEvent(v).Bytes() +} -func NewAtomId(c *xgb.Conn) (Atom, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Atom(id), nil +// 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 } -type Drawable uint32 +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, ", ") + "}" +} -func NewDrawableId(c *xgb.Conn) (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil +func init() { + xgb.NewEventFuncs[27] = CirculateRequestEventNew } -type Fontable uint32 +// ClientMessage is the event number for a ClientMessageEvent. +const ClientMessage = 33 -func NewFontableId(c *xgb.Conn) (Fontable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fontable(id), nil +type ClientMessageEvent struct { + Sequence uint16 + Format byte + Window Window + Type Atom + Data ClientMessageDataUnion } -type Visualid uint32 +// 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 -type Timestamp uint32 + v.Format = buf[b] + b += 1 -type Keysym uint32 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -type Keycode byte + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 -type Button byte + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 -type Char2b struct { - Byte1 byte - Byte2 byte + v.Data = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &v.Data) + + return v } -// Char2bRead reads a byte slice into a Char2b value. -func Char2bRead(buf []byte, v *Char2b) int { +// Bytes writes a ClientMessageEvent value to a byte slice. +func (v ClientMessageEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.Byte1 = buf[b] + // write event number + buf[b] = 33 b += 1 - v.Byte2 = buf[b] + buf[b] = v.Format 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) -} + b += 2 // skip sequence number -// Bytes writes a Char2b value to a byte slice. -func (v Char2b) Bytes() []byte { - buf := make([]byte, 2) - b := 0 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - buf[b] = v.Byte1 - b += 1 + xgb.Put32(buf[b:], uint32(v.Type)) + b += 4 - buf[b] = v.Byte2 - b += 1 + { + unionBytes := v.Data.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } 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 +// 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 } -type Point struct { - X int16 - Y int16 +// 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, ", ") + "}" } -// 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 +func init() { + xgb.NewEventFuncs[33] = ClientMessageEventNew } -// 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) +// ClientMessageDataUnion is a represention of the ClientMessageDataUnion 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 'ClientMessageDataUnion': +// ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion +// ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion +// ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion +type ClientMessageDataUnion struct { + Data8 []byte // size: 20 + Data16 []uint16 // size: 20 + Data32 []uint32 // size: 20 } -// Bytes writes a Point value to a byte slice. -func (v Point) Bytes() []byte { - buf := make([]byte, 4) - b := 0 +// ClientMessageDataUnionData8New constructs a new ClientMessageDataUnion union type with the Data8 field. +func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + copy(buf[b:], Data8[:20]) + b += xgb.Pad(int(20)) - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + // Create the Union type + v := ClientMessageDataUnion{} - return buf -} + // Now copy buf into all fields -// 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)) + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 } - return b -} + b = xgb.Pad(b) -type Rectangle struct { - X int16 - Y int16 - Width uint16 - Height uint16 + return v } -// RectangleRead reads a byte slice into a Rectangle value. -func RectangleRead(buf []byte, v *Rectangle) int { - b := 0 +// ClientMessageDataUnionData16New constructs a new ClientMessageDataUnion union type with the Data16 field. +func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + for i := 0; i < int(10); i++ { + xgb.Put16(buf[b:], Data16[i]) + b += 2 + } + b = xgb.Pad(b) - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + // Create the Union type + v := ClientMessageDataUnion{} - v.Width = xgb.Get16(buf[b:]) - b += 2 + // Now copy buf into all fields - v.Height = xgb.Get16(buf[b:]) - b += 2 + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) - return b -} + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(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]) + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 } - return xgb.Pad(b) + b = xgb.Pad(b) + + return v } -// Bytes writes a Rectangle value to a byte slice. -func (v Rectangle) Bytes() []byte { - buf := make([]byte, 8) - b := 0 +// ClientMessageDataUnionData32New constructs a new ClientMessageDataUnion union type with the Data32 field. +func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + for i := 0; i < int(5); i++ { + xgb.Put32(buf[b:], Data32[i]) + b += 4 + } + b = xgb.Pad(b) - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + // Create the Union type + v := ClientMessageDataUnion{} - xgb.Put16(buf[b:], v.Width) - b += 2 + // Now copy buf into all fields - xgb.Put16(buf[b:], v.Height) - b += 2 + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) - return buf -} + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) -// 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)) + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 } - return b -} + b = xgb.Pad(b) -type Arc struct { - X int16 - Y int16 - Width uint16 - Height uint16 - Angle1 int16 - Angle2 int16 + return v } -// 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 +// ClientMessageDataUnionRead reads a byte slice into a ClientMessageDataUnion value. +func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { + var b int - v.Height = xgb.Get16(buf[b:]) - b += 2 + b = 0 // re-read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) - v.Angle1 = int16(xgb.Get16(buf[b:])) - b += 2 + b = 0 // re-read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) - v.Angle2 = int16(xgb.Get16(buf[b:])) - b += 2 + b = 0 // re-read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) - return b + return 20 } -// ArcReadList reads a byte slice into a list of Arc values. -func ArcReadList(buf []byte, dest []Arc) int { +// ClientMessageDataUnionReadList reads a byte slice into a list of ClientMessageDataUnion values. +func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Arc{} - b += ArcRead(buf[b:], &dest[i]) + dest[i] = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(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) +// Bytes writes a ClientMessageDataUnion 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 ClientMessageDataUnion) Bytes() []byte { + buf := make([]byte, 20) 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 - + copy(buf[b:], v.Data8[:20]) + b += xgb.Pad(int(20)) return buf } -// ArcListBytes writes a list of Arc values to a byte slice. -func ArcListBytes(buf []byte, list []Arc) int { +// ClientMessageDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. +func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { b := 0 - var structBytes []byte + var unionBytes []byte for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) } return b } -type Format struct { - Depth byte - BitsPerPixel byte - ScanlinePad byte - // padding: 5 bytes +const ( + ClipOrderingUnsorted = 0 + ClipOrderingYSorted = 1 + ClipOrderingYXSorted = 2 + ClipOrderingYXBanded = 3 +) + +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 } -// FormatRead reads a byte slice into a Format value. -func FormatRead(buf []byte, v *Format) int { +// ColoritemRead reads a byte slice into a Coloritem value. +func ColoritemRead(buf []byte, v *Coloritem) int { b := 0 - v.Depth = buf[b] - b += 1 + 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.BitsPerPixel = buf[b] - b += 1 + v.Blue = xgb.Get16(buf[b:]) + b += 2 - v.ScanlinePad = buf[b] + v.Flags = buf[b] b += 1 - b += 5 // padding + b += 1 // padding return b } -// FormatReadList reads a byte slice into a list of Format values. -func FormatReadList(buf []byte, dest []Format) int { +// 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] = Format{} - b += FormatRead(buf[b:], &dest[i]) + dest[i] = Coloritem{} + b += ColoritemRead(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) +// Bytes writes a Coloritem value to a byte slice. +func (v Coloritem) Bytes() []byte { + buf := make([]byte, 12) b := 0 - buf[b] = v.Depth - b += 1 + xgb.Put32(buf[b:], v.Pixel) + b += 4 - buf[b] = v.BitsPerPixel - b += 1 + xgb.Put16(buf[b:], v.Red) + b += 2 - buf[b] = v.ScanlinePad + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + buf[b] = v.Flags b += 1 - b += 5 // padding + b += 1 // padding return buf } -// FormatListBytes writes a list of Format values to a byte slice. -func FormatListBytes(buf []byte, list []Format) int { +// 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 { @@ -1057,625 +1207,715 @@ func FormatListBytes(buf []byte, list []Format) int { return b } -type VisualInfo struct { - VisualId Visualid - Class byte - BitsPerRgbValue byte - ColormapEntries uint16 - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 4 bytes +type Colormap uint32 + +func NewColormapId(c *xgb.Conn) (Colormap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Colormap(id), nil } -// VisualInfoRead reads a byte slice into a VisualInfo value. -func VisualInfoRead(buf []byte, v *VisualInfo) int { - b := 0 +// BadColormap is the error number for a BadColormap. +const BadColormap = 12 - v.VisualId = Visualid(xgb.Get32(buf[b:])) - b += 4 +type ColormapError ValueError - v.Class = buf[b] - b += 1 +// 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 +} - v.BitsPerRgbValue = buf[b] - b += 1 +// SequenceId returns the sequence id attached to the BadColormap error. +// This is mostly used internally. +func (err ColormapError) SequenceId() uint16 { + return err.Sequence +} - v.ColormapEntries = xgb.Get16(buf[b:]) +// 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.RedMask = xgb.Get32(buf[b:]) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.GreenMask = xgb.Get32(buf[b:]) + v.Colormap = Colormap(xgb.Get32(buf[b:])) b += 4 - v.BlueMask = xgb.Get32(buf[b:]) - b += 4 + if buf[b] == 1 { + v.New = true + } else { + v.New = false + } + b += 1 - b += 4 // padding + v.State = buf[b] + b += 1 - return b -} + b += 2 // padding -// 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) + return v } -// Bytes writes a VisualInfo value to a byte slice. -func (v VisualInfo) Bytes() []byte { - buf := make([]byte, 24) +// Bytes writes a ColormapNotifyEvent value to a byte slice. +func (v ColormapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - xgb.Put32(buf[b:], uint32(v.VisualId)) + // 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 - buf[b] = v.Class + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + if v.New { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - buf[b] = v.BitsPerRgbValue + buf[b] = v.State b += 1 - xgb.Put16(buf[b:], v.ColormapEntries) + 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 - xgb.Put32(buf[b:], v.RedMask) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.GreenMask) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.BlueMask) + v.AboveSibling = Window(xgb.Get32(buf[b:])) b += 4 - b += 4 // padding + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - return buf -} + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 -// 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)) + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false } - return b -} + b += 1 -type DepthInfo struct { - Depth byte - // padding: 1 bytes - VisualsLen uint16 - // padding: 4 bytes - Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) + b += 1 // padding + + return v } -// DepthInfoRead reads a byte slice into a DepthInfo value. -func DepthInfoRead(buf []byte, v *DepthInfo) int { +// Bytes writes a ConfigureNotifyEvent value to a byte slice. +func (v ConfigureNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.Depth = buf[b] + // write event number + buf[b] = 22 b += 1 b += 1 // padding - v.VisualsLen = xgb.Get16(buf[b:]) - b += 2 + b += 2 // skip sequence number - b += 4 // padding + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 - v.Visuals = make([]VisualInfo, v.VisualsLen) - b += VisualInfoReadList(buf[b:], v.Visuals) + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - return b -} + xgb.Put32(buf[b:], uint32(v.AboveSibling)) + b += 4 -// 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) -} + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 -// 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 + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 - buf[b] = v.Depth - b += 1 + xgb.Put16(buf[b:], v.Width) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], v.Height) + b += 2 - xgb.Put16(buf[b:], v.VisualsLen) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - b += 4 // padding + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - b += VisualInfoListBytes(buf[b:], v.Visuals) + b += 1 // padding 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 +// 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 ConfigureNotifyEvent) SequenceId() uint16 { + return v.Sequence } -// 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 +// 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("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, ", ") + "}" } -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) +func init() { + xgb.NewEventFuncs[22] = ConfigureNotifyEventNew } -// ScreenInfoRead reads a byte slice into a ScreenInfo value. -func ScreenInfoRead(buf []byte, v *ScreenInfo) int { - b := 0 +// ConfigureRequest is the event number for a ConfigureRequestEvent. +const ConfigureRequest = 23 - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 +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 +} - v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) - b += 4 +// 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.WhitePixel = xgb.Get32(buf[b:]) + v.StackMode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) b += 4 - v.BlackPixel = xgb.Get32(buf[b:]) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.CurrentInputMasks = xgb.Get32(buf[b:]) + v.Sibling = Window(xgb.Get32(buf[b:])) b += 4 - v.WidthInPixels = xgb.Get16(buf[b:]) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.HeightInPixels = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.WidthInMillimeters = xgb.Get16(buf[b:]) + v.Width = xgb.Get16(buf[b:]) b += 2 - v.HeightInMillimeters = xgb.Get16(buf[b:]) + v.Height = xgb.Get16(buf[b:]) b += 2 - v.MinInstalledMaps = xgb.Get16(buf[b:]) + v.BorderWidth = xgb.Get16(buf[b:]) b += 2 - v.MaxInstalledMaps = xgb.Get16(buf[b:]) + v.ValueMask = 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 - } else { - v.SaveUnders = 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) - - 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 ConfigureRequestEvent value to a byte slice. +func (v ConfigureRequestEvent) 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] = 23 + b += 1 - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 + buf[b] = v.StackMode + 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.Parent)) b += 4 - xgb.Put32(buf[b:], v.BlackPixel) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], v.CurrentInputMasks) + xgb.Put32(buf[b:], uint32(v.Sibling)) b += 4 - xgb.Put16(buf[b:], v.WidthInPixels) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - xgb.Put16(buf[b:], v.HeightInPixels) + xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - xgb.Put16(buf[b:], v.WidthInMillimeters) + xgb.Put16(buf[b:], v.Width) b += 2 - xgb.Put16(buf[b:], v.HeightInMillimeters) + xgb.Put16(buf[b:], v.Height) b += 2 - xgb.Put16(buf[b:], v.MinInstalledMaps) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - xgb.Put16(buf[b:], v.MaxInstalledMaps) + xgb.Put16(buf[b:], v.ValueMask) b += 2 - xgb.Put32(buf[b:], uint32(v.RootVisual)) - b += 4 - - buf[b] = v.BackingStores - b += 1 - - if v.SaveUnders { - 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 +// 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 } -// 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 +// 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, ", ") + "}" } -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)) +func init() { + xgb.NewEventFuncs[23] = ConfigureRequestEventNew } -// SetupRequestRead reads a byte slice into a SetupRequest value. -func SetupRequestRead(buf []byte, v *SetupRequest) int { - b := 0 +const ( + CoordModeOrigin = 0 + CoordModePrevious = 1 +) - v.ByteOrder = buf[b] - b += 1 +// 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 +} + +// 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 b += 1 // padding - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + v.Width = xgb.Get16(buf[b:]) b += 2 - b += 2 // padding + v.Height = xgb.Get16(buf[b:]) + b += 2 - { - byteString := make([]byte, v.AuthorizationProtocolNameLen) - copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) - v.AuthorizationProtocolName = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - } + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 - { - byteString := make([]byte, v.AuthorizationProtocolDataLen) - copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) - v.AuthorizationProtocolData = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false } + b += 1 - return b -} + b += 1 // padding -// 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) + return v } -// 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)))) +// Bytes writes a CreateNotifyEvent value to a byte slice. +func (v CreateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ByteOrder + // write event number + buf[b] = 16 b += 1 b += 1 // padding - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 + b += 2 // skip sequence number - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 - xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) - b += 2 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + xgb.Put16(buf[b:], uint16(v.X)) 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 + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Width) b += 2 - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Height) b += 2 - v.Length = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - { - byteString := make([]byte, v.ReasonLen) - copy(byteString[:v.ReasonLen], buf[b:]) - v.Reason = string(byteString) - b += xgb.Pad(int(v.ReasonLen)) + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 } + b += 1 - return b + b += 1 // padding + + return buf } -// 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) +// 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 CreateNotifyEvent) SequenceId() uint16 { + return v.Sequence } -// 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 +// 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, ", ") + "}" +} - buf[b] = v.Status - b += 1 +func init() { + xgb.NewEventFuncs[16] = CreateNotifyEventNew +} - buf[b] = v.ReasonLen - b += 1 +type Cursor uint32 - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 +func NewCursorId(c *xgb.Conn) (Cursor, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Cursor(id), nil +} - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 +// BadCursor is the error number for a BadCursor. +const BadCursor = 6 - xgb.Put16(buf[b:], v.Length) - b += 2 +type CursorError ValueError - copy(buf[b:], v.Reason[:v.ReasonLen]) - b += xgb.Pad(int(v.ReasonLen)) +// 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 +} - return buf +// SequenceId returns the sequence id attached to the BadCursor error. +// This is mostly used internally. +func (err CursorError) SequenceId() uint16 { + return err.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 +// 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 } -// 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 +// 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, ", ") + "}" } -type SetupAuthenticate struct { - Status byte - // padding: 5 bytes - Length uint16 - Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) +func init() { + xgb.NewErrorFuncs[6] = CursorErrorNew } -// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. -func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { +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.Status = buf[b] + v.Depth = buf[b] b += 1 - b += 5 // padding + b += 1 // padding - v.Length = xgb.Get16(buf[b:]) + v.VisualsLen = 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))) - } + b += 4 // padding + + v.Visuals = make([]VisualInfo, v.VisualsLen) + b += VisualInfoReadList(buf[b:], v.Visuals) return b } -// SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values. -func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { +// 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] = SetupAuthenticate{} - b += SetupAuthenticateRead(buf[b:], &dest[i]) + dest[i] = DepthInfo{} + b += DepthInfoRead(buf[b:], &dest[i]) } return xgb.Pad(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)))) +// 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.Status + buf[b] = v.Depth b += 1 - b += 5 // padding + b += 1 // padding - xgb.Put16(buf[b:], v.Length) + xgb.Put16(buf[b:], v.VisualsLen) b += 2 - copy(buf[b:], v.Reason[:(int(v.Length)*4)]) - b += xgb.Pad(int((int(v.Length) * 4))) + b += 4 // padding + + b += VisualInfoListBytes(buf[b:], v.Visuals) return buf } -// SetupAuthenticateListBytes writes a list of SetupAuthenticate values to a byte slice. -func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { +// 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 { @@ -1686,625 +1926,668 @@ func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { return b } -// SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. -func SetupAuthenticateListSize(list []SetupAuthenticate) int { +// 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.Length) * 4) * 1))) + size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) } return size } -type SetupInfo struct { - Status byte +// DestroyNotify is the event number for a DestroyNotifyEvent. +const DestroyNotify = 17 + +type DestroyNotifyEvent struct { + Sequence uint16 // 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) + Event Window + Window Window } -// SetupInfoRead reads a byte slice into a SetupInfo value. -func SetupInfoRead(buf []byte, v *SetupInfo) int { - b := 0 - - v.Status = buf[b] - b += 1 +// 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.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get16(buf[b:]) + v.Sequence = 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:]) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.MotionBufferSize = xgb.Get32(buf[b:]) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.VendorLen = xgb.Get16(buf[b:]) - b += 2 + return v +} - v.MaximumRequestLength = xgb.Get16(buf[b:]) - b += 2 +// Bytes writes a DestroyNotifyEvent value to a byte slice. +func (v DestroyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 - v.RootsLen = buf[b] + // write event number + buf[b] = 17 b += 1 - v.PixmapFormatsLen = buf[b] - b += 1 + b += 1 // padding - v.ImageByteOrder = buf[b] - b += 1 + b += 2 // skip sequence number - v.BitmapFormatBitOrder = buf[b] - b += 1 + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 - v.BitmapFormatScanlineUnit = buf[b] - b += 1 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - v.BitmapFormatScanlinePad = buf[b] - b += 1 + return buf +} - v.MinKeycode = Keycode(buf[b]) - b += 1 +// 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 +} - v.MaxKeycode = Keycode(buf[b]) - b += 1 +// 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("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - b += 4 // padding +func init() { + xgb.NewEventFuncs[17] = DestroyNotifyEventNew +} - { - byteString := make([]byte, v.VendorLen) - copy(byteString[:v.VendorLen], buf[b:]) - v.Vendor = string(byteString) - b += xgb.Pad(int(v.VendorLen)) +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err } + return Drawable(id), nil +} - v.PixmapFormats = make([]Format, v.PixmapFormatsLen) - b += FormatReadList(buf[b:], v.PixmapFormats) +// BadDrawable is the error number for a BadDrawable. +const BadDrawable = 9 - v.Roots = make([]ScreenInfo, v.RootsLen) - b += ScreenInfoReadList(buf[b:], v.Roots) +type DrawableError ValueError - return b +// 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 } -// 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) +// SequenceId returns the sequence id attached to the BadDrawable error. +// This is mostly used internally. +func (err DrawableError) SequenceId() uint16 { + return err.Sequence } -// 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 +// 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 +} - buf[b] = v.Status - b += 1 +// 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, ", ") + "}" +} - b += 1 // padding +func init() { + xgb.NewErrorFuncs[9] = DrawableErrorNew +} - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 +// EnterNotify is the event number for a EnterNotifyEvent. +const EnterNotify = 7 - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 +type EnterNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + Mode byte + SameScreenFocus byte +} - xgb.Put16(buf[b:], v.Length) +// EnterNotifyEventNew constructs a EnterNotifyEvent value that implements xgb.Event from a byte slice. +func EnterNotifyEventNew(buf []byte) xgb.Event { + v := EnterNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], v.ReleaseNumber) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.ResourceIdBase) + v.Root = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.ResourceIdMask) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.MotionBufferSize) + v.Child = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], v.VendorLen) + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], v.MaximumRequestLength) + v.RootY = int16(xgb.Get16(buf[b:])) 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 + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 - buf[b] = v.BitmapFormatScanlineUnit - b += 1 + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 - buf[b] = v.BitmapFormatScanlinePad - b += 1 + v.State = xgb.Get16(buf[b:]) + b += 2 - buf[b] = byte(v.MinKeycode) + v.Mode = buf[b] b += 1 - buf[b] = byte(v.MaxKeycode) + v.SameScreenFocus = buf[b] 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 + return v } -// SetupInfoListBytes writes a list of SetupInfo values to a byte slice. -func SetupInfoListBytes(buf []byte, list []SetupInfo) int { +// Bytes writes a EnterNotifyEvent value to a byte slice. +func (v EnterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) 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 -} + // write event number + buf[b] = 7 + b += 1 -type Timecoord struct { - Time Timestamp - X int16 - Y int16 -} + buf[b] = v.Detail + b += 1 -// TimecoordRead reads a byte slice into a Timecoord value. -func TimecoordRead(buf []byte, v *Timecoord) int { - b := 0 + b += 2 // skip sequence number - v.Time = Timestamp(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 - return b -} + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 -// 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) -} + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 -// Bytes writes a Timecoord value to a byte slice. -func (v Timecoord) Bytes() []byte { - buf := make([]byte, 8) - b := 0 + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 - xgb.Put16(buf[b:], uint16(v.X)) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], uint16(v.Y)) + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) b += 2 + buf[b] = v.Mode + b += 1 + + buf[b] = v.SameScreenFocus + b += 1 + 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 +// SequenceId returns the sequence id attached to the EnterNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v EnterNotifyEvent) SequenceId() uint16 { + return v.Sequence } -type Fontprop struct { - Name Atom - Value uint32 +// String is a rudimentary string representation of EnterNotifyEvent. +func (v EnterNotifyEvent) 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 "EnterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// FontpropRead reads a byte slice into a Fontprop value. -func FontpropRead(buf []byte, v *Fontprop) int { - b := 0 +func init() { + xgb.NewEventFuncs[7] = EnterNotifyEventNew +} - v.Name = Atom(xgb.Get32(buf[b:])) - b += 4 +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 +) - v.Value = xgb.Get32(buf[b:]) - b += 4 +// Expose is the event number for a ExposeEvent. +const Expose = 12 - return b +type ExposeEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 2 bytes } -// 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) -} +// 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 -// Bytes writes a Fontprop value to a byte slice. -func (v Fontprop) Bytes() []byte { - buf := make([]byte, 8) - b := 0 + b += 1 // padding - xgb.Put32(buf[b:], uint32(v.Name)) - b += 4 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], v.Value) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - return buf -} + v.X = xgb.Get16(buf[b:]) + b += 2 -// 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 -} + v.Y = xgb.Get16(buf[b:]) + b += 2 -type Charinfo struct { - LeftSideBearing int16 - RightSideBearing int16 - CharacterWidth int16 - Ascent int16 - Descent int16 - Attributes uint16 + 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 } -// CharinfoRead reads a byte slice into a Charinfo value. -func CharinfoRead(buf []byte, v *Charinfo) int { +// Bytes writes a ExposeEvent value to a byte slice. +func (v ExposeEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.LeftSideBearing = int16(xgb.Get16(buf[b:])) - b += 2 + // write event number + buf[b] = 12 + b += 1 - v.RightSideBearing = int16(xgb.Get16(buf[b:])) + 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 - v.CharacterWidth = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], v.Y) b += 2 - v.Ascent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], v.Width) b += 2 - v.Descent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], v.Height) b += 2 - v.Attributes = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Count) b += 2 - return b + b += 2 // padding + + return buf } -// CharinfoReadList reads a byte slice into a list of Charinfo values. -func CharinfoReadList(buf []byte, dest []Charinfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Charinfo{} - b += CharinfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// 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 } -// Bytes writes a Charinfo value to a byte slice. -func (v Charinfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 +// 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, ", ") + "}" +} - xgb.Put16(buf[b:], uint16(v.LeftSideBearing)) - b += 2 +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 - xgb.Put16(buf[b:], uint16(v.RightSideBearing)) - b += 2 +type FocusInEvent struct { + Sequence uint16 + Detail byte + Event Window + Mode byte + // padding: 3 bytes +} - xgb.Put16(buf[b:], uint16(v.CharacterWidth)) - b += 2 +// 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 - xgb.Put16(buf[b:], uint16(v.Ascent)) - b += 2 + v.Detail = buf[b] + b += 1 - xgb.Put16(buf[b:], uint16(v.Descent)) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], v.Attributes) - b += 2 + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 - return buf -} + v.Mode = buf[b] + b += 1 -// CharinfoListBytes writes a list of Charinfo values to a byte slice. -func CharinfoListBytes(buf []byte, list []Charinfo) 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 Str struct { - NameLen byte - Name string // size: xgb.Pad((int(NameLen) * 1)) + return v } -// StrRead reads a byte slice into a Str value. -func StrRead(buf []byte, v *Str) int { +// Bytes writes a FocusInEvent value to a byte slice. +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.NameLen = buf[b] + // write event number + buf[b] = 9 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 -} + buf[b] = v.Detail + b += 1 -// 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) -} + b += 2 // skip sequence number -// 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 + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 - buf[b] = v.NameLen + buf[b] = v.Mode b += 1 - copy(buf[b:], v.Name[:v.NameLen]) - b += xgb.Pad(int(v.NameLen)) + b += 3 // padding 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 +// 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 } -// 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 +// String is a rudimentary string representation of FocusInEvent. +func (v FocusInEvent) 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 "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type Segment struct { - X1 int16 - Y1 int16 - X2 int16 - Y2 int16 +func init() { + xgb.NewEventFuncs[9] = FocusInEventNew } -// SegmentRead reads a byte slice into a Segment value. -func SegmentRead(buf []byte, v *Segment) int { - b := 0 +// FocusOut is the event number for a FocusOutEvent. +const FocusOut = 10 - v.X1 = int16(xgb.Get16(buf[b:])) - b += 2 +type FocusOutEvent FocusInEvent - v.Y1 = int16(xgb.Get16(buf[b:])) - b += 2 +// 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.X2 = int16(xgb.Get16(buf[b:])) - b += 2 +// Bytes writes a FocusOutEvent value to a byte slice. +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} - v.Y2 = int16(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 +} - return b +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, ", ") + "}" } -// 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]) +func init() { + xgb.NewEventFuncs[10] = FocusOutEventNew +} + +type Font uint32 + +func NewFontId(c *xgb.Conn) (Font, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return xgb.Pad(b) + return Font(id), nil } -// Bytes writes a Segment value to a byte slice. -func (v Segment) Bytes() []byte { - buf := make([]byte, 8) - b := 0 +const ( + FontNone = 0 +) - xgb.Put16(buf[b:], uint16(v.X1)) - b += 2 +// BadFont is the error number for a BadFont. +const BadFont = 7 - xgb.Put16(buf[b:], uint16(v.Y1)) - b += 2 +type FontError ValueError - xgb.Put16(buf[b:], uint16(v.X2)) - b += 2 +// 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 +} - xgb.Put16(buf[b:], uint16(v.Y2)) - b += 2 +// SequenceId returns the sequence id attached to the BadFont error. +// This is mostly used internally. +func (err FontError) SequenceId() uint16 { + return err.Sequence +} - return buf +// 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 } -// 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)) +// 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.NewErrorFuncs[7] = FontErrorNew +} + +const ( + FontDrawLeftToRight = 0 + FontDrawRightToLeft = 1 +) + +type Fontable uint32 + +func NewFontableId(c *xgb.Conn) (Fontable, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return b + return Fontable(id), nil } -type Coloritem struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Flags byte - // padding: 1 bytes +type Fontprop struct { + Name Atom + Value uint32 } -// ColoritemRead reads a byte slice into a Coloritem value. -func ColoritemRead(buf []byte, v *Coloritem) int { +// FontpropRead reads a byte slice into a Fontprop value. +func FontpropRead(buf []byte, v *Fontprop) int { b := 0 - v.Pixel = xgb.Get32(buf[b:]) + v.Name = Atom(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 + v.Value = xgb.Get32(buf[b:]) + b += 4 return b } -// ColoritemReadList reads a byte slice into a list of Coloritem values. -func ColoritemReadList(buf []byte, dest []Coloritem) int { +// 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] = Coloritem{} - b += ColoritemRead(buf[b:], &dest[i]) + dest[i] = Fontprop{} + b += FontpropRead(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) +// Bytes writes a Fontprop value to a byte slice. +func (v Fontprop) Bytes() []byte { + buf := make([]byte, 8) b := 0 - xgb.Put32(buf[b:], v.Pixel) + xgb.Put32(buf[b:], uint32(v.Name)) 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 + xgb.Put32(buf[b:], v.Value) + b += 4 return buf } -// ColoritemListBytes writes a list of Coloritem values to a byte slice. -func ColoritemListBytes(buf []byte, list []Coloritem) int { +// 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 { @@ -2315,62 +2598,62 @@ func ColoritemListBytes(buf []byte, list []Coloritem) int { return b } -type Rgb struct { - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes +type Format struct { + Depth byte + BitsPerPixel byte + ScanlinePad byte + // padding: 5 bytes } -// RgbRead reads a byte slice into a Rgb value. -func RgbRead(buf []byte, v *Rgb) int { +// FormatRead reads a byte slice into a Format value. +func FormatRead(buf []byte, v *Format) int { b := 0 - v.Red = xgb.Get16(buf[b:]) - b += 2 + v.Depth = buf[b] + b += 1 - v.Green = xgb.Get16(buf[b:]) - b += 2 + v.BitsPerPixel = buf[b] + b += 1 - v.Blue = xgb.Get16(buf[b:]) - b += 2 + v.ScanlinePad = buf[b] + b += 1 - b += 2 // padding + b += 5 // padding return b } -// RgbReadList reads a byte slice into a list of Rgb values. -func RgbReadList(buf []byte, dest []Rgb) int { +// 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] = Rgb{} - b += RgbRead(buf[b:], &dest[i]) + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Rgb value to a byte slice. -func (v Rgb) Bytes() []byte { +// 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.Red) - b += 2 + buf[b] = v.Depth + b += 1 - xgb.Put16(buf[b:], v.Green) - b += 2 + buf[b] = v.BitsPerPixel + b += 1 - xgb.Put16(buf[b:], v.Blue) - b += 2 + buf[b] = v.ScanlinePad + b += 1 - b += 2 // padding + b += 5 // padding return buf } -// RgbListBytes writes a list of Rgb values to a byte slice. -func RgbListBytes(buf []byte, list []Rgb) int { +// 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 { @@ -2381,431 +2664,560 @@ func RgbListBytes(buf []byte, list []Rgb) int { return b } -type Host struct { - Family byte - // padding: 1 bytes - AddressLen uint16 - Address []byte // size: xgb.Pad((int(AddressLen) * 1)) -} - -// 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.AddressLen = xgb.Get16(buf[b:]) - b += 2 +// BadGContext is the error number for a BadGContext. +const BadGContext = 13 - v.Address = make([]byte, v.AddressLen) - copy(v.Address[:v.AddressLen], buf[b:]) - b += xgb.Pad(int(v.AddressLen)) +type GContextError ValueError - return 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 } -// 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) +// SequenceId returns the sequence id attached to the BadGContext error. +// This is mostly used internally. +func (err GContextError) SequenceId() uint16 { + return err.Sequence } -// 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 - - buf[b] = v.Family - b += 1 +// 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 +} - b += 1 // padding +// 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, ", ") + "}" +} - xgb.Put16(buf[b:], v.AddressLen) - b += 2 +func init() { + xgb.NewErrorFuncs[13] = GContextErrorNew +} - copy(buf[b:], v.Address[:v.AddressLen]) - b += xgb.Pad(int(v.AddressLen)) +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 +) - return buf -} +type Gcontext uint32 -// 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)) +func NewGcontextId(c *xgb.Conn) (Gcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return b + return Gcontext(id), nil } -// 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 -} +const ( + GetPropertyTypeAny = 0 +) -// ClientMessageDataUnion is a represention of the ClientMessageDataUnion 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 'ClientMessageDataUnion': -// ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion -// ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion -// ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion -type ClientMessageDataUnion struct { - Data8 []byte // size: 20 - Data16 []uint16 // size: 20 - Data32 []uint32 // size: 20 -} +const ( + GrabAny = 0 +) + +const ( + GrabModeSync = 0 + GrabModeAsync = 1 +) -// ClientMessageDataUnionData8New constructs a new ClientMessageDataUnion union type with the Data8 field. -func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) +const ( + GrabStatusSuccess = 0 + GrabStatusAlreadyGrabbed = 1 + GrabStatusInvalidTime = 2 + GrabStatusNotViewable = 3 + GrabStatusFrozen = 4 +) - copy(buf[b:], Data8[:20]) - b += xgb.Pad(int(20)) +// GraphicsExposure is the event number for a GraphicsExposureEvent. +const GraphicsExposure = 13 - // Create the Union type - v := ClientMessageDataUnion{} +type GraphicsExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + X uint16 + Y uint16 + Width uint16 + Height uint16 + MinorOpcode uint16 + Count uint16 + MajorOpcode byte + // padding: 3 bytes +} - // Now copy buf into all fields +// GraphicsExposureEventNew constructs a GraphicsExposureEvent value that implements xgb.Event from a byte slice. +func GraphicsExposureEventNew(buf []byte) xgb.Event { + v := GraphicsExposureEvent{} + b := 1 // don't read event number - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + b += 1 // padding - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 - return v -} + v.X = xgb.Get16(buf[b:]) + b += 2 -// ClientMessageDataUnionData16New constructs a new ClientMessageDataUnion union type with the Data16 field. -func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) + v.Y = xgb.Get16(buf[b:]) + b += 2 - for i := 0; i < int(10); i++ { - xgb.Put16(buf[b:], Data16[i]) - b += 2 - } - b = xgb.Pad(b) + v.Width = xgb.Get16(buf[b:]) + b += 2 - // Create the Union type - v := ClientMessageDataUnion{} + v.Height = xgb.Get16(buf[b:]) + b += 2 - // Now copy buf into all fields + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + v.Count = xgb.Get16(buf[b:]) + b += 2 - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + v.MajorOpcode = buf[b] + b += 1 - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + b += 3 // padding return v } -// ClientMessageDataUnionData32New constructs a new ClientMessageDataUnion union type with the Data32 field. -func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) +// Bytes writes a GraphicsExposureEvent value to a byte slice. +func (v GraphicsExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 - for i := 0; i < int(5); i++ { - xgb.Put32(buf[b:], Data32[i]) - b += 4 - } - b = xgb.Pad(b) + // write event number + buf[b] = 13 + b += 1 - // Create the Union type - v := ClientMessageDataUnion{} + b += 1 // padding - // Now copy buf into all fields + b += 2 // skip sequence number - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.X) + b += 2 - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.Y) + b += 2 - return v -} + xgb.Put16(buf[b:], v.Width) + b += 2 -// ClientMessageDataUnionRead reads a byte slice into a ClientMessageDataUnion value. -func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { - var b int + xgb.Put16(buf[b:], v.Height) + b += 2 - b = 0 // re-read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 - b = 0 // re-read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.Count) + b += 2 - b = 0 // re-read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + buf[b] = v.MajorOpcode + b += 1 - return 20 -} + b += 3 // padding -// ClientMessageDataUnionReadList reads a byte slice into a list of ClientMessageDataUnion values. -func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ClientMessageDataUnion{} - b += ClientMessageDataUnionRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return buf } -// Bytes writes a ClientMessageDataUnion 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 ClientMessageDataUnion) Bytes() []byte { - buf := make([]byte, 20) - b := 0 +// SequenceId returns the sequence id attached to the GraphicsExposure event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v GraphicsExposureEvent) SequenceId() uint16 { + return v.Sequence +} - copy(buf[b:], v.Data8[:20]) - b += xgb.Pad(int(20)) - return buf +// String is a rudimentary string representation of GraphicsExposureEvent. +func (v GraphicsExposureEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + 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("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "GraphicsExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// ClientMessageDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. -func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { - b := 0 - var unionBytes []byte - for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) - } - return b +func init() { + xgb.NewEventFuncs[13] = GraphicsExposureEventNew } -// KeyPress is the event number for a KeyPressEvent. -const KeyPress = 2 +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 +) + +// GravityNotify is the event number for a GravityNotifyEvent. +const GravityNotify = 24 -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 +type GravityNotifyEvent struct { + Sequence uint16 // padding: 1 bytes + Event Window + Window Window + X int16 + Y int16 } -// KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. -func KeyPressEventNew(buf []byte) xgb.Event { - v := KeyPressEvent{} +// 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 - v.Detail = Keycode(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:])) 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:])) - 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:])) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.State = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - return v } -// Bytes writes a KeyPressEvent value to a byte slice. -func (v KeyPressEvent) 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] = 2 + buf[b] = 24 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)) - b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) 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)) - b += 2 + return buf +} - xgb.Put16(buf[b:], uint16(v.EventY)) - b += 2 +// 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 GravityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} - xgb.Put16(buf[b:], v.State) +// 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("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[24] = GravityNotifyEventNew +} + +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 Host struct { + Family byte + // padding: 1 bytes + AddressLen uint16 + Address []byte // size: xgb.Pad((int(AddressLen) * 1)) +} + +// 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.AddressLen = xgb.Get16(buf[b:]) b += 2 - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 + v.Address = make([]byte, v.AddressLen) + copy(v.Address[:v.AddressLen], buf[b:]) + b += xgb.Pad(int(v.AddressLen)) + + return b +} + +// 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 Host value to a byte slice. +func (v Host) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) + b := 0 + + buf[b] = v.Family b += 1 - b += 1 // padding + b += 1 // padding + + xgb.Put16(buf[b:], v.AddressLen) + b += 2 + + copy(buf[b:], v.Address[:v.AddressLen]) + b += xgb.Pad(int(v.AddressLen)) + + 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 +} + +// 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 +} + +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 (err IDChoiceError) SequenceId() uint16 { + return err.Sequence +} + +// 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, "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.NewErrorFuncs[14] = IDChoiceErrorNew +} + +const ( + ImageFormatXYBitmap = 0 + ImageFormatXYPixmap = 1 + ImageFormatZPixmap = 2 +) + +const ( + ImageOrderLSBFirst = 0 + ImageOrderMSBFirst = 1 +) + +// BadImplementation is the error number for a BadImplementation. +const BadImplementation = 17 - return buf +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 KeyPress event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadImplementation error. // This is mostly used internally. -func (v KeyPressEvent) SequenceId() uint16 { - return v.Sequence +func (err ImplementationError) SequenceId() uint16 { + return err.Sequence } -// 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("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, ", ") + "}" +// 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.NewEventFuncs[2] = KeyPressEventNew + xgb.NewErrorFuncs[17] = ImplementationErrorNew } -// ButtonPress is the event number for a ButtonPressEvent. -const ButtonPress = 4 +const ( + InputFocusNone = 0 + InputFocusPointerRoot = 1 + InputFocusParent = 2 + InputFocusFollowKeyboard = 3 +) -type ButtonPressEvent struct { +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 Button + Detail Keycode Time Timestamp Root Window Event Window @@ -2819,12 +3231,12 @@ type ButtonPressEvent struct { // padding: 1 bytes } -// ButtonPressEventNew constructs a ButtonPressEvent value that implements xgb.Event from a byte slice. -func ButtonPressEventNew(buf []byte) xgb.Event { - v := ButtonPressEvent{} +// 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 - v.Detail = Button(buf[b]) + v.Detail = Keycode(buf[b]) b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -2869,13 +3281,13 @@ func ButtonPressEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a ButtonPressEvent value to a byte slice. -func (v ButtonPressEvent) 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] = 4 + buf[b] = 2 b += 1 buf[b] = byte(v.Detail) @@ -2922,15 +3334,15 @@ func (v ButtonPressEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the ButtonPress 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 ButtonPressEvent) SequenceId() uint16 { +func (v KeyPressEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ButtonPressEvent. -func (v ButtonPressEvent) String() string { +// 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("Detail: %d", v.Detail)) @@ -2944,144 +3356,36 @@ func (v ButtonPressEvent) String() string { 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, ", ") + "}" + return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[4] = ButtonPressEventNew -} - -// 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 + xgb.NewEventFuncs[2] = KeyPressEventNew } -// 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 - - v.Detail = 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:])) - b += 4 - - 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.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 - } - b += 1 +// KeyRelease is the event number for a KeyReleaseEvent. +const KeyRelease = 3 - b += 1 // padding +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 MotionNotifyEvent value to a byte slice. -func (v MotionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 6 - b += 1 - - buf[b] = v.Detail - b += 1 - - 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)) - 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.RootY)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.EventX)) - b += 2 - - 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 - - b += 1 // padding - - 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 MotionNotify 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 MotionNotifyEvent) SequenceId() uint16 { +func (v KeyReleaseEvent) SequenceId() uint16 { return v.Sequence } - -// String is a rudimentary string representation of MotionNotifyEvent. -func (v MotionNotifyEvent) String() string { + +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)) @@ -3095,138 +3399,95 @@ func (v MotionNotifyEvent) String() string { 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, ", ") + "}" + return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[6] = MotionNotifyEventNew + xgb.NewEventFuncs[3] = KeyReleaseEventNew } -// EnterNotify is the event number for a EnterNotifyEvent. -const EnterNotify = 7 +type Keycode byte -type EnterNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - Mode byte - SameScreenFocus byte +// KeymapNotify is the event number for a KeymapNotifyEvent. +const KeymapNotify = 11 + +type KeymapNotifyEvent struct { + Keys []byte // size: 32 } -// EnterNotifyEventNew constructs a EnterNotifyEvent value that implements xgb.Event from a byte slice. -func EnterNotifyEventNew(buf []byte) xgb.Event { - v := EnterNotifyEvent{} +// 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 - v.Detail = 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:])) - b += 4 - - 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.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 - - v.Mode = buf[b] - b += 1 - - v.SameScreenFocus = buf[b] - b += 1 + v.Keys = make([]byte, 31) + copy(v.Keys[:31], buf[b:]) + b += xgb.Pad(int(31)) return v } -// Bytes writes a EnterNotifyEvent value to a byte slice. -func (v EnterNotifyEvent) 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] = 7 - b += 1 - - buf[b] = v.Detail + buf[b] = 11 b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 + copy(buf[b:], v.Keys[:31]) + b += xgb.Pad(int(31)) - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 + return buf +} - xgb.Put32(buf[b:], uint32(v.Child)) - 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.Put16(buf[b:], uint16(v.RootX)) - b += 2 +// String is a rudimentary string representation of KeymapNotifyEvent. +func (v KeymapNotifyEvent) String() string { + fieldVals := make([]string, 0, 1) + return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - xgb.Put16(buf[b:], uint16(v.RootY)) - b += 2 +func init() { + xgb.NewEventFuncs[11] = KeymapNotifyEventNew +} - xgb.Put16(buf[b:], uint16(v.EventX)) - b += 2 +type Keysym uint32 - xgb.Put16(buf[b:], uint16(v.EventY)) - b += 2 +const ( + KillAllTemporary = 0 +) - xgb.Put16(buf[b:], v.State) - b += 2 +// LeaveNotify is the event number for a LeaveNotifyEvent. +const LeaveNotify = 8 - buf[b] = v.Mode - b += 1 +type LeaveNotifyEvent EnterNotifyEvent - buf[b] = v.SameScreenFocus - b += 1 +// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. +func LeaveNotifyEventNew(buf []byte) xgb.Event { + return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) +} - return buf +// 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 EnterNotify event. +// 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 EnterNotifyEvent) SequenceId() uint16 { +func (v LeaveNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of EnterNotifyEvent. -func (v EnterNotifyEvent) String() string { +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)) @@ -3241,31 +3502,91 @@ func (v EnterNotifyEvent) String() string { 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 "EnterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[7] = EnterNotifyEventNew + xgb.NewEventFuncs[8] = LeaveNotifyEventNew } -// FocusIn is the event number for a FocusInEvent. -const FocusIn = 9 +const ( + LedModeOff = 0 + LedModeOn = 1 +) -type FocusInEvent struct { +// 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 + +type MapNotifyEvent struct { Sequence uint16 - Detail byte - Event Window - Mode byte + // padding: 1 bytes + Event Window + Window Window + OverrideRedirect bool // padding: 3 bytes } -// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. -func FocusInEventNew(buf []byte) xgb.Event { - v := FocusInEvent{} +// MapNotifyEventNew constructs a MapNotifyEvent value that implements xgb.Event from a byte slice. +func MapNotifyEventNew(buf []byte) xgb.Event { + v := MapNotifyEvent{} b := 1 // don't read event number - v.Detail = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3273,7 +3594,14 @@ func FocusInEventNew(buf []byte) xgb.Event { v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.Mode = buf[b] + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } b += 1 b += 3 // padding @@ -3281,24 +3609,30 @@ func FocusInEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a FocusInEvent value to a byte slice. -func (v FocusInEvent) Bytes() []byte { +// Bytes writes a MapNotifyEvent value to a byte slice. +func (v MapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 9 + buf[b] = 19 b += 1 - buf[b] = v.Detail - b += 1 + b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - buf[b] = v.Mode + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 b += 3 // padding @@ -3306,96 +3640,125 @@ func (v FocusInEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the FocusIn event. +// SequenceId returns the sequence id attached to the MapNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v FocusInEvent) SequenceId() uint16 { +func (v MapNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of FocusInEvent. -func (v FocusInEvent) String() string { - fieldVals := make([]string, 0, 4) +// String is a rudimentary string representation of MapNotifyEvent. +func (v MapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) 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 "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[9] = FocusInEventNew + xgb.NewEventFuncs[19] = MapNotifyEventNew } -// KeymapNotify is the event number for a KeymapNotifyEvent. -const KeymapNotify = 11 +// MapRequest is the event number for a MapRequestEvent. +const MapRequest = 20 -type KeymapNotifyEvent struct { - Keys []byte // size: 32 +type MapRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window } -// KeymapNotifyEventNew constructs a KeymapNotifyEvent value that implements xgb.Event from a byte slice. -func KeymapNotifyEventNew(buf []byte) xgb.Event { - v := KeymapNotifyEvent{} +// MapRequestEventNew constructs a MapRequestEvent value that implements xgb.Event from a byte slice. +func MapRequestEventNew(buf []byte) xgb.Event { + v := MapRequestEvent{} b := 1 // don't read event number - v.Keys = make([]byte, 31) - copy(v.Keys[:31], buf[b:]) - b += xgb.Pad(int(31)) + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 return v } -// Bytes writes a KeymapNotifyEvent value to a byte slice. -func (v KeymapNotifyEvent) Bytes() []byte { +// Bytes writes a MapRequestEvent value to a byte slice. +func (v MapRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 11 + buf[b] = 20 b += 1 - copy(buf[b:], v.Keys[:31]) - b += xgb.Pad(int(31)) + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the KeymapNotify event. +// SequenceId returns the sequence id attached to the MapRequest event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v KeymapNotifyEvent) SequenceId() uint16 { - return uint16(0) +func (v MapRequestEvent) SequenceId() uint16 { + return v.Sequence } -// String is a rudimentary string representation of KeymapNotifyEvent. -func (v KeymapNotifyEvent) String() string { - fieldVals := make([]string, 0, 1) - return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// String is a rudimentary string representation of MapRequestEvent. +func (v MapRequestEvent) String() string { + fieldVals := make([]string, 0, 3) + 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)) + return "MapRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[11] = KeymapNotifyEventNew + xgb.NewEventFuncs[20] = MapRequestEventNew } -// Expose is the event number for a ExposeEvent. -const Expose = 12 +const ( + MapStateUnmapped = 0 + MapStateUnviewable = 1 + MapStateViewable = 2 +) -type ExposeEvent 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 - Window Window - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 2 bytes + Request byte + FirstKeycode Keycode + Count byte + // padding: 1 bytes } -// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. -func ExposeEventNew(buf []byte) xgb.Event { - v := ExposeEvent{} +// 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 @@ -3403,311 +3766,333 @@ func ExposeEventNew(buf []byte) xgb.Event { 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.Request = buf[b] + b += 1 - v.Height = xgb.Get16(buf[b:]) - b += 2 + v.FirstKeycode = Keycode(buf[b]) + b += 1 - v.Count = xgb.Get16(buf[b:]) - b += 2 + v.Count = buf[b] + b += 1 - b += 2 // padding + b += 1 // padding return v } -// Bytes writes a ExposeEvent value to a byte slice. -func (v ExposeEvent) 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] = 12 + buf[b] = 34 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 + buf[b] = v.Request + b += 1 - xgb.Put16(buf[b:], v.Height) - b += 2 + buf[b] = byte(v.FirstKeycode) + b += 1 - xgb.Put16(buf[b:], v.Count) - b += 2 + buf[b] = v.Count + b += 1 - b += 2 // padding + b += 1 // padding return buf } -// SequenceId returns the sequence id attached to the Expose 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 ExposeEvent) SequenceId() uint16 { +func (v MappingNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ExposeEvent. -func (v ExposeEvent) 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("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("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[12] = ExposeEventNew + xgb.NewEventFuncs[34] = MappingNotifyEventNew +} + +const ( + MappingStatusSuccess = 0 + MappingStatusBusy = 1 + MappingStatusFailure = 2 +) + +// 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 } -// GraphicsExposure is the event number for a GraphicsExposureEvent. -const GraphicsExposure = 13 +// 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 +) -type GraphicsExposureEvent struct { - Sequence uint16 +// 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 - Drawable Drawable - X uint16 - Y uint16 - Width uint16 - Height uint16 - MinorOpcode uint16 - Count uint16 - MajorOpcode byte - // padding: 3 bytes } -// GraphicsExposureEventNew constructs a GraphicsExposureEvent value that implements xgb.Event from a byte slice. -func GraphicsExposureEventNew(buf []byte) xgb.Event { - v := GraphicsExposureEvent{} +// 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.Drawable = Drawable(xgb.Get32(buf[b:])) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.X = xgb.Get16(buf[b:]) - b += 2 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - v.Y = 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.Width = xgb.Get16(buf[b:]) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.Height = xgb.Get16(buf[b:]) + v.EventX = int16(xgb.Get16(buf[b:])) b += 2 - v.MinorOpcode = xgb.Get16(buf[b:]) + v.EventY = int16(xgb.Get16(buf[b:])) b += 2 - v.Count = xgb.Get16(buf[b:]) + v.State = xgb.Get16(buf[b:]) b += 2 - v.MajorOpcode = buf[b] + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } b += 1 - b += 3 // padding + b += 1 // padding return v } -// Bytes writes a GraphicsExposureEvent value to a byte slice. -func (v GraphicsExposureEvent) 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] = 13 + 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.Drawable)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put16(buf[b:], v.X) - b += 2 + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 - xgb.Put16(buf[b:], v.Y) + 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:], v.Width) + xgb.Put16(buf[b:], uint16(v.RootY)) b += 2 - xgb.Put16(buf[b:], v.Height) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], v.MinorOpcode) + xgb.Put16(buf[b:], uint16(v.EventY)) b += 2 - xgb.Put16(buf[b:], v.Count) + xgb.Put16(buf[b:], v.State) b += 2 - buf[b] = v.MajorOpcode + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - b += 3 // padding + b += 1 // padding return buf } -// SequenceId returns the sequence id attached to the GraphicsExposure 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 GraphicsExposureEvent) SequenceId() uint16 { +func (v MotionNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of GraphicsExposureEvent. -func (v GraphicsExposureEvent) String() string { - fieldVals := make([]string, 0, 10) +// 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("Drawable: %d", v.Drawable)) - 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("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "GraphicsExposure {" + 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 "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[13] = GraphicsExposureEventNew -} - -// 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 + xgb.NewEventFuncs[6] = MotionNotifyEventNew } -// 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 - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(xgb.Get32(buf[b:])) - b += 4 - - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 +// BadName is the error number for a BadName. +const BadName = 15 - b += 1 // padding +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 } -// 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 BadName error. +// This is mostly used internally. +func (err NameError) SequenceId() uint16 { + return err.Sequence } -// 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 +// 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 } -// 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, ", ") + "}" +// 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.NewEventFuncs[14] = NoExposureEventNew + xgb.NewErrorFuncs[15] = NameErrorNew } -// VisibilityNotify is the event number for a VisibilityNotifyEvent. -const VisibilityNotify = 15 +// NoExposure is the event number for a NoExposureEvent. +const NoExposure = 14 -type VisibilityNotifyEvent struct { +type NoExposureEvent 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{} + 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 b += 1 // padding @@ -3715,139 +4100,175 @@ func VisibilityNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) + v.Drawable = Drawable(xgb.Get32(buf[b:])) b += 4 - v.State = buf[b] + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] b += 1 - b += 3 // padding + b += 1 // padding return v } -// Bytes writes a VisibilityNotifyEvent value to a byte slice. -func (v VisibilityNotifyEvent) Bytes() []byte { +// 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] = 15 + buf[b] = 14 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Drawable)) b += 4 - buf[b] = v.State + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + buf[b] = v.MajorOpcode b += 1 - b += 3 // padding + b += 1 // padding return buf } -// SequenceId returns the sequence id attached to the VisibilityNotify event. +// 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 VisibilityNotifyEvent) SequenceId() uint16 { +func (v NoExposureEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of VisibilityNotifyEvent. -func (v VisibilityNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) +// 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("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + 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[15] = VisibilityNotifyEventNew + xgb.NewEventFuncs[14] = NoExposureEventNew } -// 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 -} +const ( + NotifyDetailAncestor = 0 + NotifyDetailVirtual = 1 + NotifyDetailInferior = 2 + NotifyDetailNonlinear = 3 + NotifyDetailNonlinearVirtual = 4 + NotifyDetailPointer = 5 + NotifyDetailPointerRoot = 6 + NotifyDetailNone = 7 +) -// 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 +const ( + NotifyModeNormal = 0 + NotifyModeGrab = 1 + NotifyModeUngrab = 2 + NotifyModeWhileGrabbed = 3 +) - b += 1 // padding +type Pixmap uint32 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 +// BadPixmap is the error number for a BadPixmap. +const BadPixmap = 4 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 +type PixmapError ValueError - v.X = int16(xgb.Get16(buf[b:])) - b += 2 +// 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 +} - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 +// SequenceId returns the sequence id attached to the BadPixmap error. +// This is mostly used internally. +func (err PixmapError) SequenceId() uint16 { + return err.Sequence +} - v.Width = xgb.Get16(buf[b:]) - b += 2 +// 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 +} - v.Height = xgb.Get16(buf[b:]) - b += 2 +// 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, ", ") + "}" +} - v.BorderWidth = xgb.Get16(buf[b:]) - b += 2 +func init() { + xgb.NewErrorFuncs[4] = PixmapErrorNew +} - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 +const ( + PixmapNone = 0 +) - b += 1 // padding +const ( + PlaceOnTop = 0 + PlaceOnBottom = 1 +) - return v +type Point struct { + X int16 + Y int16 } -// Bytes writes a CreateNotifyEvent value to a byte slice. -func (v CreateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// PointRead reads a byte slice into a Point value. +func PointRead(buf []byte, v *Point) int { b := 0 - // write event number - buf[b] = 16 - b += 1 + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - b += 1 // padding + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - b += 2 // skip sequence number + return b +} - xgb.Put32(buf[b:], uint32(v.Parent)) - b += 4 +// 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) +} - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 +// 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 @@ -3855,66 +4276,54 @@ func (v CreateNotifyEvent) Bytes() []byte { 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:], v.BorderWidth) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - return buf } -// 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 CreateNotifyEvent) SequenceId() uint16 { - return v.Sequence +// 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 } -// 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, ", ") + "}" -} +const ( + PolyShapeComplex = 0 + PolyShapeNonconvex = 1 + PolyShapeConvex = 2 +) -func init() { - xgb.NewEventFuncs[16] = CreateNotifyEventNew -} +const ( + PropModeReplace = 0 + PropModePrepend = 1 + PropModeAppend = 2 +) + +const ( + PropertyNewValue = 0 + PropertyDelete = 1 +) -// DestroyNotify is the event number for a DestroyNotifyEvent. -const DestroyNotify = 17 +// PropertyNotify is the event number for a PropertyNotifyEvent. +const PropertyNotify = 28 -type DestroyNotifyEvent struct { +type PropertyNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Event Window Window Window + Atom Atom + Time Timestamp + State byte + // padding: 3 bytes } -// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. -func DestroyNotifyEventNew(buf []byte) xgb.Event { - v := DestroyNotifyEvent{} +// 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 @@ -3922,72 +4331,167 @@ func DestroyNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + 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 DestroyNotifyEvent value to a byte slice. -func (v DestroyNotifyEvent) 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] = 17 + buf[b] = 28 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) + 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.Time)) b += 4 + buf[b] = v.State + b += 1 + + b += 3 // padding + return buf } -// SequenceId returns the sequence id attached to the DestroyNotify event. +// 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 DestroyNotifyEvent) SequenceId() uint16 { +func (v PropertyNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of DestroyNotifyEvent. -func (v DestroyNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) +// 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("Event: %d", v.Event)) fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + 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[17] = DestroyNotifyEventNew + xgb.NewEventFuncs[28] = PropertyNotifyEventNew } -// UnmapNotify is the event number for a UnmapNotifyEvent. -const UnmapNotify = 18 +const ( + QueryShapeOfLargestCursor = 0 + QueryShapeOfFastestTile = 1 + QueryShapeOfFastestStipple = 2 +) -type UnmapNotifyEvent struct { +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 +} + +// ReparentNotify is the event number for a ReparentNotifyEvent. +const ReparentNotify = 21 + +type ReparentNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - FromConfigure bool + Event Window + Window Window + Parent Window + X int16 + Y int16 + OverrideRedirect bool // padding: 3 bytes } -// UnmapNotifyEventNew constructs a UnmapNotifyEvent value that implements xgb.Event from a byte slice. -func UnmapNotifyEventNew(buf []byte) xgb.Event { - v := UnmapNotifyEvent{} +// 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 @@ -4001,10 +4505,19 @@ func UnmapNotifyEventNew(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.FromConfigure = true + v.OverrideRedirect = true } else { - v.FromConfigure = false + v.OverrideRedirect = false } b += 1 @@ -4013,13 +4526,13 @@ func UnmapNotifyEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a UnmapNotifyEvent value to a byte slice. -func (v UnmapNotifyEvent) 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] = 18 + buf[b] = 21 b += 1 b += 1 // padding @@ -4032,7 +4545,16 @@ func (v UnmapNotifyEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - if v.FromConfigure { + 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 @@ -4044,42 +4566,108 @@ func (v UnmapNotifyEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the UnmapNotify 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 UnmapNotifyEvent) SequenceId() uint16 { +func (v ReparentNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of UnmapNotifyEvent. -func (v UnmapNotifyEvent) 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("FromConfigure: %t", v.FromConfigure)) - return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + 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, ", ") + "}" +} + +func init() { + 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.NewEventFuncs[18] = UnmapNotifyEventNew + xgb.NewErrorFuncs[1] = RequestErrorNew } -// MapNotify is the event number for a MapNotifyEvent. -const MapNotify = 19 +// ResizeRequest is the event number for a ResizeRequestEvent. +const ResizeRequest = 25 -type MapNotifyEvent struct { +type ResizeRequestEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - OverrideRedirect bool - // padding: 3 bytes + Window Window + Width uint16 + Height uint16 } -// MapNotifyEventNew constructs a MapNotifyEvent value that implements xgb.Event from a byte slice. -func MapNotifyEventNew(buf []byte) xgb.Event { - v := MapNotifyEvent{} +// ResizeRequestEventNew constructs a ResizeRequestEvent value that implements xgb.Event from a byte slice. +func ResizeRequestEventNew(buf []byte) xgb.Event { + v := ResizeRequestEvent{} b := 1 // don't read event number b += 1 // padding @@ -4087,548 +4675,569 @@ func MapNotifyEventNew(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 - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - b += 3 // padding + v.Height = xgb.Get16(buf[b:]) + b += 2 return v } -// Bytes writes a MapNotifyEvent value to a byte slice. -func (v MapNotifyEvent) Bytes() []byte { +// Bytes writes a ResizeRequestEvent value to a byte slice. +func (v ResizeRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 19 + buf[b] = 25 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.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + xgb.Put16(buf[b:], v.Width) + b += 2 - b += 3 // padding + xgb.Put16(buf[b:], v.Height) + b += 2 return buf } -// SequenceId returns the sequence id attached to the MapNotify event. +// SequenceId returns the sequence id attached to the ResizeRequest event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v MapNotifyEvent) SequenceId() uint16 { +func (v ResizeRequestEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of MapNotifyEvent. -func (v MapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +// String is a rudimentary string representation of ResizeRequestEvent. +func (v ResizeRequestEvent) String() string { + fieldVals := make([]string, 0, 4) 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("OverrideRedirect: %t", v.OverrideRedirect)) - return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + return "ResizeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[19] = MapNotifyEventNew + xgb.NewEventFuncs[25] = ResizeRequestEventNew } -// MapRequest is the event number for a MapRequestEvent. -const MapRequest = 20 - -type MapRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window +type Rgb struct { + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes } -// MapRequestEventNew constructs a MapRequestEvent value that implements xgb.Event from a byte slice. -func MapRequestEventNew(buf []byte) xgb.Event { - v := MapRequestEvent{} - b := 1 // don't read event number +// RgbRead reads a byte slice into a Rgb value. +func RgbRead(buf []byte, v *Rgb) int { + b := 0 - b += 1 // padding + v.Red = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Green = xgb.Get16(buf[b:]) b += 2 - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 + v.Blue = xgb.Get16(buf[b:]) + b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + b += 2 // padding - return v + return b } -// Bytes writes a MapRequestEvent value to a byte slice. -func (v MapRequestEvent) Bytes() []byte { - buf := make([]byte, 32) +// 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) +} - // write event number - buf[b] = 20 - b += 1 +// Bytes writes a Rgb value to a byte slice. +func (v Rgb) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - b += 1 // padding + xgb.Put16(buf[b:], v.Red) + b += 2 - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.Green) + b += 2 - xgb.Put32(buf[b:], uint32(v.Parent)) - b += 4 + xgb.Put16(buf[b:], v.Blue) + b += 2 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + b += 2 // padding return buf } -// SequenceId returns the sequence id attached to the MapRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v MapRequestEvent) SequenceId() uint16 { - return v.Sequence +// 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 } -// String is a rudimentary string representation of MapRequestEvent. -func (v MapRequestEvent) String() string { - fieldVals := make([]string, 0, 3) - 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)) - return "MapRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +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) } -func init() { - xgb.NewEventFuncs[20] = MapRequestEventNew -} +// ScreenInfoRead reads a byte slice into a ScreenInfo value. +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { + b := 0 -// ReparentNotify is the event number for a ReparentNotifyEvent. -const ReparentNotify = 21 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 -type ReparentNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - Parent Window - X int16 - Y int16 - OverrideRedirect bool - // padding: 3 bytes -} + v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + b += 4 -// 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 + v.WhitePixel = xgb.Get32(buf[b:]) + b += 4 - b += 1 // padding + v.BlackPixel = xgb.Get32(buf[b:]) + b += 4 - v.Sequence = xgb.Get16(buf[b:]) + v.CurrentInputMasks = xgb.Get32(buf[b:]) + b += 4 + + v.WidthInPixels = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 + v.HeightInPixels = xgb.Get16(buf[b:]) + b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + v.WidthInMillimeters = xgb.Get16(buf[b:]) + b += 2 - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 + v.HeightInMillimeters = xgb.Get16(buf[b:]) + b += 2 - v.X = int16(xgb.Get16(buf[b:])) + v.MinInstalledMaps = xgb.Get16(buf[b:]) b += 2 - v.Y = int16(xgb.Get16(buf[b:])) + v.MaxInstalledMaps = 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.OverrideRedirect = true + v.SaveUnders = true } else { - v.OverrideRedirect = false + v.SaveUnders = false } b += 1 - b += 3 // padding + v.RootDepth = buf[b] + b += 1 - return v + v.AllowedDepthsLen = buf[b] + b += 1 + + v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) + b += DepthInfoReadList(buf[b:], v.AllowedDepths) + + return b } -// Bytes writes a ReparentNotifyEvent value to a byte slice. -func (v ReparentNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// 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) +} - // write event number - buf[b] = 21 - b += 1 +// 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 - b += 2 // skip sequence number + xgb.Put32(buf[b:], uint32(v.DefaultColormap)) + b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], v.WhitePixel) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], v.BlackPixel) b += 4 - xgb.Put32(buf[b:], uint32(v.Parent)) + xgb.Put32(buf[b:], v.CurrentInputMasks) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) + xgb.Put16(buf[b:], v.WidthInPixels) b += 2 - xgb.Put16(buf[b:], uint16(v.Y)) + xgb.Put16(buf[b:], v.HeightInPixels) b += 2 - if v.OverrideRedirect { + 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 + + if v.SaveUnders { buf[b] = 1 } else { buf[b] = 0 } b += 1 - b += 3 // padding + buf[b] = v.RootDepth + b += 1 + + buf[b] = v.AllowedDepthsLen + b += 1 + + b += DepthInfoListBytes(buf[b:], v.AllowedDepths) return buf } -// 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 ReparentNotifyEvent) SequenceId() uint16 { - return v.Sequence +// 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 } -// 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)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// 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 } -func init() { - xgb.NewEventFuncs[21] = ReparentNotifyEventNew +const ( + ScreenSaverReset = 0 + ScreenSaverActive = 1 +) + +type Segment struct { + X1 int16 + Y1 int16 + X2 int16 + Y2 int16 } -// ConfigureNotify is the event number for a ConfigureNotifyEvent. -const ConfigureNotify = 22 +// SegmentRead reads a byte slice into a Segment value. +func SegmentRead(buf []byte, v *Segment) int { + b := 0 -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 -} + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 -// 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 + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 - b += 1 // padding + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Y2 = int16(xgb.Get16(buf[b:])) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 + return b +} - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 +// 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) +} - v.AboveSibling = Window(xgb.Get32(buf[b:])) - b += 4 +// Bytes writes a Segment value to a byte slice. +func (v Segment) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - v.X = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(v.X1)) b += 2 - v.Y = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(v.Y1)) b += 2 - v.Width = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(v.X2)) b += 2 - v.Height = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(v.Y2)) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) - b += 2 + return buf +} - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false +// 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)) } - b += 1 + return b +} - b += 1 // padding +// SelectionClear is the event number for a SelectionClearEvent. +const SelectionClear = 29 - return v +type SelectionClearEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Window + Selection Atom } -// 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] = 22 - b += 1 +// SelectionClearEventNew constructs a SelectionClearEvent value that implements xgb.Event from a byte slice. +func SelectionClearEventNew(buf []byte) xgb.Event { + v := SelectionClearEvent{} + b := 1 // don't read event number b += 1 // padding - b += 2 // skip sequence number + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(v.Event)) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + v.Owner = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], uint32(v.AboveSibling)) + v.Selection = Atom(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + return v +} - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 +// Bytes writes a SelectionClearEvent value to a byte slice. +func (v SelectionClearEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 - xgb.Put16(buf[b:], v.Width) - b += 2 + // write event number + buf[b] = 29 + b += 1 - xgb.Put16(buf[b:], v.Height) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], v.BorderWidth) - b += 2 + b += 2 // skip sequence number - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 - b += 1 // padding + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the ConfigureNotify event. +// SequenceId returns the sequence id attached to the SelectionClear event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ConfigureNotifyEvent) SequenceId() uint16 { +func (v SelectionClearEvent) 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 SelectionClearEvent. +func (v SelectionClearEvent) String() string { + fieldVals := make([]string, 0, 4) 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("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("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + return "SelectionClear {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[22] = ConfigureNotifyEventNew + xgb.NewEventFuncs[29] = SelectionClearEventNew } -// ConfigureRequest is the event number for a ConfigureRequestEvent. -const ConfigureRequest = 23 +// SelectionNotify is the event number for a SelectionNotifyEvent. +const SelectionNotify = 31 -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 SelectionNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Requestor Window + Selection Atom + Target Atom + Property Atom } -// ConfigureRequestEventNew constructs a ConfigureRequestEvent value that implements xgb.Event from a byte slice. -func ConfigureRequestEventNew(buf []byte) xgb.Event { - v := ConfigureRequestEvent{} +// 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 - 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.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + v.Requestor = Window(xgb.Get32(buf[b:])) b += 4 - v.Sibling = Window(xgb.Get32(buf[b:])) + v.Selection = Atom(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.BorderWidth = xgb.Get16(buf[b:]) - b += 2 + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 - v.ValueMask = xgb.Get16(buf[b:]) - b += 2 + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 return v } -// Bytes writes a ConfigureRequestEvent value to a byte slice. -func (v ConfigureRequestEvent) 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] = 23 + buf[b] = 31 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.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Requestor)) b += 4 - xgb.Put32(buf[b:], uint32(v.Sibling)) + xgb.Put32(buf[b:], uint32(v.Selection)) b += 4 - 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:], v.BorderWidth) - b += 2 + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 - xgb.Put16(buf[b:], v.ValueMask) - b += 2 + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the ConfigureRequest 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 ConfigureRequestEvent) SequenceId() uint16 { +func (v SelectionNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ConfigureRequestEvent. -func (v ConfigureRequestEvent) String() string { - fieldVals := make([]string, 0, 10) +// 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("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, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + 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, ", ") + "}" } func init() { - xgb.NewEventFuncs[23] = ConfigureRequestEventNew + xgb.NewEventFuncs[31] = SelectionNotifyEventNew } -// GravityNotify is the event number for a GravityNotifyEvent. -const GravityNotify = 24 +// SelectionRequest is the event number for a SelectionRequestEvent. +const SelectionRequest = 30 -type GravityNotifyEvent struct { +type SelectionRequestEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - X int16 - Y int16 + Time Timestamp + Owner Window + Requestor Window + Selection Atom + Target Atom + Property Atom } -// GravityNotifyEventNew constructs a GravityNotifyEvent value that implements xgb.Event from a byte slice. -func GravityNotifyEventNew(buf []byte) xgb.Event { - v := GravityNotifyEvent{} +// 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 @@ -4636,624 +5245,755 @@ func GravityNotifyEventNew(buf []byte) xgb.Event { 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.Owner = Window(xgb.Get32(buf[b:])) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + v.Requestor = Window(xgb.Get32(buf[b:])) + b += 4 - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 return v } -// Bytes writes a GravityNotifyEvent value to a byte slice. -func (v GravityNotifyEvent) 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] = 24 + buf[b] = 30 b += 1 b += 1 // padding 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.Owner)) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + xgb.Put32(buf[b:], uint32(v.Requestor)) + b += 4 - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the GravityNotify 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 GravityNotifyEvent) SequenceId() uint16 { +func (v SelectionRequestEvent) 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 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("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, ", ") + "}" + 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, ", ") + "}" } func init() { - xgb.NewEventFuncs[24] = GravityNotifyEventNew -} - -// ResizeRequest is the event number for a ResizeRequestEvent. -const ResizeRequest = 25 - -type ResizeRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Width uint16 - Height uint16 + xgb.NewEventFuncs[30] = SelectionRequestEventNew } -// ResizeRequestEventNew constructs a ResizeRequestEvent value that implements xgb.Event from a byte slice. -func ResizeRequestEventNew(buf []byte) xgb.Event { - v := ResizeRequestEvent{} - b := 1 // don't read event number +const ( + SendEventDestPointerWindow = 0 + SendEventDestItemFocus = 1 +) - b += 1 // padding +const ( + SetModeInsert = 0 + SetModeDelete = 1 +) - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +type SetupAuthenticate struct { + Status byte + // padding: 5 bytes + Length uint16 + Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) +} - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 +// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. +func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { + b := 0 - v.Width = xgb.Get16(buf[b:]) - b += 2 + v.Status = buf[b] + b += 1 - v.Height = xgb.Get16(buf[b:]) + b += 5 // padding + + v.Length = xgb.Get16(buf[b:]) b += 2 - return v + { + 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 ResizeRequestEvent value to a byte slice. -func (v ResizeRequestEvent) Bytes() []byte { - buf := make([]byte, 32) +// 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) +} - // write event number - buf[b] = 25 - b += 1 - - b += 1 // padding +// 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 - b += 2 // skip sequence number + buf[b] = v.Status + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + b += 5 // padding - xgb.Put16(buf[b:], v.Width) + xgb.Put16(buf[b:], v.Length) b += 2 - xgb.Put16(buf[b:], v.Height) - b += 2 + copy(buf[b:], v.Reason[:(int(v.Length)*4)]) + b += xgb.Pad(int((int(v.Length) * 4))) return buf } -// SequenceId returns the sequence id attached to the ResizeRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ResizeRequestEvent) SequenceId() uint16 { - return v.Sequence +// 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 } -// String is a rudimentary string representation of ResizeRequestEvent. -func (v ResizeRequestEvent) 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("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - return "ResizeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// 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 } -func init() { - xgb.NewEventFuncs[25] = ResizeRequestEventNew +type SetupFailed struct { + Status byte + ReasonLen byte + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + Reason string // size: xgb.Pad((int(ReasonLen) * 1)) } -// CirculateNotify is the event number for a CirculateNotifyEvent. -const CirculateNotify = 26 - -type CirculateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - // padding: 4 bytes - Place byte - // padding: 3 bytes -} +// SetupFailedRead reads a byte slice into a SetupFailed value. +func SetupFailedRead(buf []byte, v *SetupFailed) int { + b := 0 -// 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 + v.Status = buf[b] + b += 1 - b += 1 // padding + v.ReasonLen = buf[b] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + v.ProtocolMajorVersion = 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.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 - b += 4 // padding + v.Length = xgb.Get16(buf[b:]) + b += 2 - v.Place = buf[b] - b += 1 + { + byteString := make([]byte, v.ReasonLen) + copy(byteString[:v.ReasonLen], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int(v.ReasonLen)) + } - b += 3 // padding + return b +} - return v +// 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 CirculateNotifyEvent value to a byte slice. -func (v CirculateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// 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 - // write event number - buf[b] = 26 + buf[b] = v.Status b += 1 - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 + buf[b] = v.ReasonLen + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 - b += 4 // padding + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 - buf[b] = v.Place - b += 1 + xgb.Put16(buf[b:], v.Length) + b += 2 - b += 3 // padding + copy(buf[b:], v.Reason[:v.ReasonLen]) + b += xgb.Pad(int(v.ReasonLen)) return buf } -// 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 +// 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 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, ", ") + "}" +// 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 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) } -func init() { - xgb.NewEventFuncs[26] = CirculateNotifyEventNew -} +// SetupInfoRead reads a byte slice into a SetupInfo value. +func SetupInfoRead(buf []byte, v *SetupInfo) int { + b := 0 -// PropertyNotify is the event number for a PropertyNotifyEvent. -const PropertyNotify = 28 + v.Status = buf[b] + b += 1 -type PropertyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Atom Atom - Time Timestamp - State byte - // padding: 3 bytes -} + b += 1 // padding -// 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 + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 - b += 1 // padding + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Length = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) + v.ReleaseNumber = xgb.Get32(buf[b:]) b += 4 - v.Atom = Atom(xgb.Get32(buf[b:])) + v.ResourceIdBase = xgb.Get32(buf[b:]) b += 4 - v.Time = Timestamp(xgb.Get32(buf[b:])) + v.ResourceIdMask = xgb.Get32(buf[b:]) b += 4 - v.State = buf[b] - b += 1 + v.MotionBufferSize = xgb.Get32(buf[b:]) + b += 4 - b += 3 // padding + v.VendorLen = xgb.Get16(buf[b:]) + b += 2 - return v -} + v.MaximumRequestLength = xgb.Get16(buf[b:]) + b += 2 -// Bytes writes a PropertyNotifyEvent value to a byte slice. -func (v PropertyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 + v.RootsLen = buf[b] + b += 1 - // write event number - buf[b] = 28 + v.PixmapFormatsLen = buf[b] b += 1 - b += 1 // padding + v.ImageByteOrder = buf[b] + b += 1 - b += 2 // skip sequence number + v.BitmapFormatBitOrder = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + v.BitmapFormatScanlineUnit = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Atom)) - b += 4 + v.BitmapFormatScanlinePad = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + v.MinKeycode = Keycode(buf[b]) + b += 1 - buf[b] = v.State + v.MaxKeycode = Keycode(buf[b]) b += 1 - b += 3 // padding + b += 4 // padding - return buf -} + { + byteString := make([]byte, v.VendorLen) + copy(byteString[:v.VendorLen], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLen)) + } -// 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 -} + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) + b += FormatReadList(buf[b:], v.PixmapFormats) -// 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, ", ") + "}" -} + v.Roots = make([]ScreenInfo, v.RootsLen) + b += ScreenInfoReadList(buf[b:], v.Roots) -func init() { - xgb.NewEventFuncs[28] = PropertyNotifyEventNew + return b } -// SelectionClear is the event number for a SelectionClearEvent. -const SelectionClear = 29 - -type SelectionClearEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Owner Window - Selection Atom +// 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) } -// SelectionClearEventNew constructs a SelectionClearEvent value that implements xgb.Event from a byte slice. -func SelectionClearEventNew(buf []byte) xgb.Event { - v := SelectionClearEvent{} - b := 1 // don't read event number +// 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 + + buf[b] = v.Status + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.ProtocolMajorVersion) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + xgb.Put32(buf[b:], v.ReleaseNumber) b += 4 - v.Owner = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], v.ResourceIdBase) b += 4 - v.Selection = Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], v.ResourceIdMask) b += 4 - return v -} + xgb.Put32(buf[b:], v.MotionBufferSize) + b += 4 -// Bytes writes a SelectionClearEvent value to a byte slice. -func (v SelectionClearEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 + xgb.Put16(buf[b:], v.VendorLen) + b += 2 - // write event number - buf[b] = 29 + 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 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + buf[b] = v.BitmapFormatBitOrder + b += 1 - xgb.Put32(buf[b:], uint32(v.Owner)) - b += 4 + buf[b] = v.BitmapFormatScanlineUnit + b += 1 - xgb.Put32(buf[b:], uint32(v.Selection)) - b += 4 + buf[b] = v.BitmapFormatScanlinePad + b += 1 - return buf -} + buf[b] = byte(v.MinKeycode) + b += 1 -// SequenceId returns the sequence id attached to the SelectionClear event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v SelectionClearEvent) SequenceId() uint16 { - return v.Sequence -} + buf[b] = byte(v.MaxKeycode) + b += 1 -// String is a rudimentary string representation of SelectionClearEvent. -func (v SelectionClearEvent) String() string { - fieldVals := make([]string, 0, 4) - 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("Selection: %d", v.Selection)) - return "SelectionClear {" + xgb.StringsJoin(fieldVals, ", ") + "}" + 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 } -func init() { - xgb.NewEventFuncs[29] = SelectionClearEventNew +// 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 } -// SelectionRequest is the event number for a SelectionRequestEvent. -const SelectionRequest = 30 +// 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 SelectionRequestEvent struct { - Sequence uint16 +type SetupRequest struct { + ByteOrder byte // padding: 1 bytes - Time Timestamp - Owner Window - Requestor Window - Selection Atom - Target Atom - Property Atom + 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)) } -// 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 +// 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.Sequence = xgb.Get16(buf[b:]) + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Owner = Window(xgb.Get32(buf[b:])) - b += 4 + v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + b += 2 - v.Requestor = Window(xgb.Get32(buf[b:])) - b += 4 + v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + b += 2 - v.Selection = Atom(xgb.Get32(buf[b:])) - b += 4 + b += 2 // padding - v.Target = Atom(xgb.Get32(buf[b:])) - b += 4 + { + byteString := make([]byte, v.AuthorizationProtocolNameLen) + copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) + v.AuthorizationProtocolName = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + } - v.Property = Atom(xgb.Get32(buf[b:])) - b += 4 + { + byteString := make([]byte, v.AuthorizationProtocolDataLen) + copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) + v.AuthorizationProtocolData = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + } - return v + return b } -// Bytes writes a SelectionRequestEvent value to a byte slice. -func (v SelectionRequestEvent) Bytes() []byte { - buf := make([]byte, 32) +// 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 - // write event number - buf[b] = 30 + buf[b] = v.ByteOrder b += 1 b += 1 // padding - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 - xgb.Put32(buf[b:], uint32(v.Owner)) - b += 4 + xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) + b += 2 - xgb.Put32(buf[b:], uint32(v.Requestor)) - b += 4 + xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + b += 2 - xgb.Put32(buf[b:], uint32(v.Selection)) - b += 4 + b += 2 // padding - xgb.Put32(buf[b:], uint32(v.Target)) - b += 4 + copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - xgb.Put32(buf[b:], uint32(v.Property)) - b += 4 + copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) return buf } -// 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 SelectionRequestEvent) 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 } -// 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 "SelectionRequest {" + 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[30] = SelectionRequestEventNew +const ( + StackModeAbove = 0 + StackModeBelow = 1 + StackModeTopIf = 2 + StackModeBottomIf = 3 + StackModeOpposite = 4 +) + +type Str struct { + NameLen byte + Name string // size: xgb.Pad((int(NameLen) * 1)) } -// SelectionNotify is the event number for a SelectionNotifyEvent. -const SelectionNotify = 31 +// StrRead reads a byte slice into a Str value. +func StrRead(buf []byte, v *Str) int { + b := 0 -type SelectionNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Requestor Window - Selection Atom - Target Atom - Property Atom + 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 } -// 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 +// 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) +} - b += 1 // padding +// 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 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + buf[b] = v.NameLen + b += 1 - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) - v.Requestor = Window(xgb.Get32(buf[b:])) - b += 4 + return buf +} - v.Selection = Atom(xgb.Get32(buf[b:])) - b += 4 +// 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 +} - v.Target = Atom(xgb.Get32(buf[b:])) - b += 4 +// 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 +} - v.Property = Atom(xgb.Get32(buf[b:])) - b += 4 +const ( + SubwindowModeClipByChildren = 0 + SubwindowModeIncludeInferiors = 1 +) - return v +const ( + TimeCurrentTime = 0 +) + +type Timecoord struct { + Time Timestamp + X int16 + Y int16 } -// Bytes writes a SelectionNotifyEvent value to a byte slice. -func (v SelectionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// TimecoordRead reads a byte slice into a Timecoord value. +func TimecoordRead(buf []byte, v *Timecoord) int { b := 0 - // write event number - buf[b] = 31 - b += 1 + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 - b += 1 // padding + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - b += 2 // skip sequence number + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + 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) +} - xgb.Put32(buf[b:], uint32(v.Requestor)) - b += 4 +// 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.Selection)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Target)) - b += 4 + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 - xgb.Put32(buf[b:], uint32(v.Property)) - b += 4 + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 return buf } -// 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 SelectionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// 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("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, ", ") + "}" +// 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 } -func init() { - xgb.NewEventFuncs[31] = SelectionNotifyEventNew -} +type Timestamp uint32 -// ColormapNotify is the event number for a ColormapNotifyEvent. -const ColormapNotify = 32 +// UnmapNotify is the event number for a UnmapNotifyEvent. +const UnmapNotify = 18 -type ColormapNotifyEvent struct { +type UnmapNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Window Window - Colormap Colormap - New bool - State byte - // padding: 2 bytes + Event Window + Window Window + FromConfigure bool + // padding: 3 bytes } -// ColormapNotifyEventNew constructs a ColormapNotifyEvent value that implements xgb.Event from a byte slice. -func ColormapNotifyEventNew(buf []byte) xgb.Event { - v := ColormapNotifyEvent{} +// 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 // padding @@ -5261,182 +6001,160 @@ func ColormapNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.Colormap = Colormap(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 if buf[b] == 1 { - v.New = true + v.FromConfigure = true } else { - v.New = false + v.FromConfigure = false } b += 1 - v.State = buf[b] - b += 1 - - b += 2 // padding + b += 3 // padding return v } -// Bytes writes a ColormapNotifyEvent value to a byte slice. -func (v ColormapNotifyEvent) Bytes() []byte { +// Bytes writes a UnmapNotifyEvent value to a byte slice. +func (v UnmapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 32 + buf[b] = 18 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put32(buf[b:], uint32(v.Colormap)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - if v.New { + if v.FromConfigure { buf[b] = 1 } else { buf[b] = 0 } b += 1 - buf[b] = v.State - b += 1 - - b += 2 // padding + b += 3 // padding return buf } -// SequenceId returns the sequence id attached to the ColormapNotify event. +// 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 ColormapNotifyEvent) SequenceId() uint16 { +func (v UnmapNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ColormapNotifyEvent. -func (v ColormapNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) +// 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("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, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) + return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[32] = ColormapNotifyEventNew + xgb.NewEventFuncs[18] = UnmapNotifyEventNew } -// ClientMessage is the event number for a ClientMessageEvent. -const ClientMessage = 33 +// BadValue is the error number for a BadValue. +const BadValue = 2 -type ClientMessageEvent struct { - Sequence uint16 - Format byte - Window Window - Type Atom - Data ClientMessageDataUnion +type ValueError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes } -// 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 +// ValueErrorNew constructs a ValueError value that implements xgb.Error from a byte slice. +func ValueErrorNew(buf []byte) xgb.Error { + v := ValueError{} + v.NiceName = "Value" - v.Format = buf[b] - b += 1 + b := 1 // skip error determinant + b += 1 // don't read error number v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Type = Atom(xgb.Get32(buf[b:])) + v.BadValue = xgb.Get32(buf[b:]) b += 4 - v.Data = ClientMessageDataUnion{} - b += ClientMessageDataUnionRead(buf[b:], &v.Data) - - return v -} - -// Bytes writes a ClientMessageEvent value to a byte slice. -func (v ClientMessageEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 33 - b += 1 + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 - buf[b] = v.Format + v.MajorOpcode = buf[b] b += 1 - b += 2 // skip sequence number - - 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)) - } + b += 1 // padding - return buf + return v } -// SequenceId returns the sequence id attached to the ClientMessage event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadValue error. // This is mostly used internally. -func (v ClientMessageEvent) SequenceId() uint16 { - return v.Sequence +func (err ValueError) SequenceId() uint16 { + return err.Sequence } -// String is a rudimentary string representation of ClientMessageEvent. -func (v ClientMessageEvent) String() string { +// BadId returns the 'BadValue' number if one exists for the BadValue error. If no bad value exists, 0 is returned. +func (err ValueError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadValue error. + +func (err ValueError) Error() 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, ", ") + "}" + 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 "BadValue {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[33] = ClientMessageEventNew + xgb.NewErrorFuncs[2] = ValueErrorNew } -// MappingNotify is the event number for a MappingNotifyEvent. -const MappingNotify = 34 +const ( + VisibilityUnobscured = 0 + VisibilityPartiallyObscured = 1 + VisibilityFullyObscured = 2 +) -type MappingNotifyEvent struct { +// VisibilityNotify is the event number for a VisibilityNotifyEvent. +const VisibilityNotify = 15 + +type VisibilityNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Request byte - FirstKeycode Keycode - Count byte - // padding: 1 bytes + Window Window + State byte + // padding: 3 bytes } -// MappingNotifyEventNew constructs a MappingNotifyEvent value that implements xgb.Event from a byte slice. -func MappingNotifyEventNew(buf []byte) xgb.Event { - v := MappingNotifyEvent{} +// 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 @@ -5444,1035 +6162,1012 @@ func MappingNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Request = buf[b] - b += 1 - - v.FirstKeycode = Keycode(buf[b]) - b += 1 + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 - v.Count = buf[b] + v.State = buf[b] b += 1 - b += 1 // padding + b += 3 // padding return v } -// Bytes writes a MappingNotifyEvent value to a byte slice. -func (v MappingNotifyEvent) Bytes() []byte { +// 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] = 34 + buf[b] = 15 b += 1 b += 1 // padding b += 2 // skip sequence number - buf[b] = v.Request - b += 1 - - buf[b] = byte(v.FirstKeycode) - b += 1 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - buf[b] = v.Count + buf[b] = v.State b += 1 - b += 1 // padding + b += 3 // padding return buf } -// SequenceId returns the sequence id attached to the MappingNotify event. +// 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 MappingNotifyEvent) SequenceId() uint16 { +func (v VisibilityNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of MappingNotifyEvent. -func (v MappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +// 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("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, ", ") + "}" + 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[34] = MappingNotifyEventNew + xgb.NewEventFuncs[15] = VisibilityNotifyEventNew } -// KeyRelease is the event number for a KeyReleaseEvent. -const KeyRelease = 3 - -type KeyReleaseEvent KeyPressEvent +const ( + VisualClassStaticGray = 0 + VisualClassGrayScale = 1 + VisualClassStaticColor = 2 + VisualClassPseudoColor = 3 + VisualClassTrueColor = 4 + VisualClassDirectColor = 5 +) -// KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice. -func KeyReleaseEventNew(buf []byte) xgb.Event { - return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) +type VisualInfo struct { + VisualId Visualid + Class byte + BitsPerRgbValue byte + ColormapEntries uint16 + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 4 bytes } -// Bytes writes a KeyReleaseEvent value to a byte slice. -func (v KeyReleaseEvent) Bytes() []byte { - return KeyPressEvent(v).Bytes() -} +// VisualInfoRead reads a byte slice into a VisualInfo value. +func VisualInfoRead(buf []byte, v *VisualInfo) int { + b := 0 -// 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.VisualId = Visualid(xgb.Get32(buf[b:])) + b += 4 -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.Class = buf[b] + b += 1 -func init() { - xgb.NewEventFuncs[3] = KeyReleaseEventNew -} + v.BitsPerRgbValue = buf[b] + b += 1 -// ButtonRelease is the event number for a ButtonReleaseEvent. -const ButtonRelease = 5 + v.ColormapEntries = xgb.Get16(buf[b:]) + b += 2 -type ButtonReleaseEvent ButtonPressEvent + v.RedMask = xgb.Get32(buf[b:]) + b += 4 -// ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. -func ButtonReleaseEventNew(buf []byte) xgb.Event { - return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) -} + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 -// Bytes writes a ButtonReleaseEvent value to a byte slice. -func (v ButtonReleaseEvent) Bytes() []byte { - return ButtonPressEvent(v).Bytes() + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + 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 +// 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) } -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 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 } -func init() { - xgb.NewEventFuncs[5] = ButtonReleaseEventNew +// 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 } -// LeaveNotify is the event number for a LeaveNotifyEvent. -const LeaveNotify = 8 +type Visualid uint32 -type LeaveNotifyEvent EnterNotifyEvent +type Window uint32 -// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. -func LeaveNotifyEventNew(buf []byte) xgb.Event { - return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil } -// Bytes writes a LeaveNotifyEvent value to a byte slice. -func (v LeaveNotifyEvent) Bytes() []byte { - return EnterNotifyEvent(v).Bytes() +const ( + WindowNone = 0 +) + +// BadWindow is the error number for a BadWindow. +const BadWindow = 3 + +type WindowError ValueError + +// WindowErrorNew constructs a WindowError value that implements xgb.Error from a byte slice. +func WindowErrorNew(buf []byte) xgb.Error { + v := WindowError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Window" + return v } -// SequenceId returns the sequence id attached to the LeaveNotify event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadWindow error. // This is mostly used internally. -func (v LeaveNotifyEvent) SequenceId() uint16 { - return v.Sequence +func (err WindowError) SequenceId() uint16 { + return err.Sequence } -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, ", ") + "}" +// BadId returns the 'BadValue' number if one exists for the BadWindow error. If no bad value exists, 0 is returned. +func (err WindowError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadWindow error. +func (err WindowError) 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 "BadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[8] = LeaveNotifyEventNew + xgb.NewErrorFuncs[3] = WindowErrorNew } -// FocusOut is the event number for a FocusOutEvent. -const FocusOut = 10 +const ( + WindowClassCopyFromParent = 0 + WindowClassInputOutput = 1 + WindowClassInputOnly = 2 +) -type FocusOutEvent FocusInEvent +// Skipping definition for base type 'Bool' -// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. -func FocusOutEventNew(buf []byte) xgb.Event { - return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) -} +// Skipping definition for base type 'Byte' -// Bytes writes a FocusOutEvent value to a byte slice. -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() -} +// Skipping definition for base type 'Card8' -// 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 -} +// Skipping definition for base type 'Char' -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, ", ") + "}" -} +// Skipping definition for base type 'Void' -func init() { - xgb.NewEventFuncs[10] = FocusOutEventNew -} +// Skipping definition for base type 'Double' -// CirculateRequest is the event number for a CirculateRequestEvent. -const CirculateRequest = 27 +// Skipping definition for base type 'Float' -type CirculateRequestEvent CirculateNotifyEvent +// Skipping definition for base type 'Int16' -// CirculateRequestEventNew constructs a CirculateRequestEvent value that implements xgb.Event from a byte slice. -func CirculateRequestEventNew(buf []byte) xgb.Event { - return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) -} +// Skipping definition for base type 'Int32' -// Bytes writes a CirculateRequestEvent value to a byte slice. -func (v CirculateRequestEvent) Bytes() []byte { - return CirculateNotifyEvent(v).Bytes() -} +// Skipping definition for base type 'Int8' -// 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 -} +// Skipping definition for base type 'Card16' -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, ", ") + "}" +// Skipping definition for base type 'Card32' + +// AllocColorCookie is a cookie used only for AllocColor requests. +type AllocColorCookie struct { + *xgb.Cookie } -func init() { - xgb.NewEventFuncs[27] = CirculateRequestEventNew +// 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} } -// BadRequest is the error number for a BadRequest. -const BadRequest = 1 +// 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} +} -type RequestError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte +// 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 } -// RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. -func RequestErrorNew(buf []byte) xgb.Error { - v := RequestError{} - v.NiceName = "Request" +// 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 +} - b := 1 // skip error determinant - b += 1 // don't read error number +// allocColorReply reads a byte slice into a AllocColorReply value. +func allocColorReply(buf []byte) *AllocColorReply { + v := new(AllocColorReply) + b := 1 // skip reply determinant + + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.BadValue = xgb.Get32(buf[b:]) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MinorOpcode = xgb.Get16(buf[b:]) + v.Red = xgb.Get16(buf[b:]) b += 2 - v.MajorOpcode = buf[b] - b += 1 + v.Green = xgb.Get16(buf[b:]) + b += 2 - b += 1 // padding + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 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 -} +// 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 BadRequest error. If no bad value exists, 0 is returned. -func (err RequestError) BadId() uint32 { - return err.BadValue -} + buf[b] = 84 // request opcode + b += 1 -// Error returns a rudimentary string representation of the BadRequest error. + b += 1 // padding -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, ", ") + "}" + 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) + b += 2 + + b += 2 // padding + + return buf } -func init() { - xgb.NewErrorFuncs[1] = RequestErrorNew +// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. +type AllocColorCellsCookie struct { + *xgb.Cookie } -// BadValue is the error number for a BadValue. -const BadValue = 2 +// 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} +} -type ValueError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte +// 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} +} + +// 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)) } -// ValueErrorNew constructs a ValueError value that implements xgb.Error from a byte slice. -func ValueErrorNew(buf []byte) xgb.Error { - v := ValueError{} - v.NiceName = "Value" +// 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 +} - b := 1 // skip error determinant - b += 1 // don't read error number +// allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. +func allocColorCellsReply(buf []byte) *AllocColorCellsReply { + v := new(AllocColorCellsReply) + b := 1 // skip reply determinant + + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.BadValue = xgb.Get32(buf[b:]) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MinorOpcode = xgb.Get16(buf[b:]) + v.PixelsLen = xgb.Get16(buf[b:]) b += 2 - v.MajorOpcode = buf[b] - b += 1 + v.MasksLen = xgb.Get16(buf[b:]) + b += 2 - b += 1 // padding + b += 20 // padding - return v -} + 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) -// SequenceId returns the sequence id attached to the BadValue error. -// This is mostly used internally. -func (err ValueError) SequenceId() uint16 { - return err.Sequence -} + 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) -// BadId returns the 'BadValue' number if one exists for the BadValue error. If no bad value exists, 0 is returned. -func (err ValueError) BadId() uint32 { - return err.BadValue + return v } -// Error returns a rudimentary string representation of the BadValue error. +// 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) -func (err ValueError) 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 "BadValue {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + buf[b] = 86 // request opcode + b += 1 -func init() { - xgb.NewErrorFuncs[2] = ValueErrorNew -} + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -// BadWindow is the error number for a BadWindow. -const BadWindow = 3 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -type WindowError ValueError + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -// WindowErrorNew constructs a WindowError value that implements xgb.Error from a byte slice. -func WindowErrorNew(buf []byte) xgb.Error { - v := WindowError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Window" - return v -} + xgb.Put16(buf[b:], Colors) + b += 2 -// SequenceId returns the sequence id attached to the BadWindow error. -// This is mostly used internally. -func (err WindowError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], Planes) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadWindow error. If no bad value exists, 0 is returned. -func (err WindowError) BadId() uint32 { - return err.BadValue + return buf } -// Error returns a rudimentary string representation of the BadWindow error. -func (err WindowError) 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 "BadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. +type AllocColorPlanesCookie struct { + *xgb.Cookie } -func init() { - xgb.NewErrorFuncs[3] = WindowErrorNew +// 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} } -// 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 +// 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} } -// SequenceId returns the sequence id attached to the BadPixmap error. -// This is mostly used internally. -func (err PixmapError) SequenceId() uint16 { - return err.Sequence +// 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)) } -// 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 +// 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 } -// 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, ", ") + "}" -} +// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. +func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { + v := new(AllocColorPlanesReply) + b := 1 // skip reply determinant -func init() { - xgb.NewErrorFuncs[4] = PixmapErrorNew -} + b += 1 // padding -// BadAtom is the error number for a BadAtom. -const BadAtom = 5 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -type AtomError ValueError + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// 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 -} + v.PixelsLen = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the BadAtom error. -// This is mostly used internally. -func (err AtomError) SequenceId() uint16 { - return err.Sequence -} + b += 2 // padding -// 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 -} + v.RedMask = xgb.Get32(buf[b:]) + b += 4 -// 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, ", ") + "}" -} + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 -func init() { - xgb.NewErrorFuncs[5] = AtomErrorNew -} + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 -// BadCursor is the error number for a BadCursor. -const BadCursor = 6 + b += 8 // padding -type CursorError ValueError + 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) -// 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 -} +// 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) -// 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, ", ") + "}" -} + buf[b] = 87 // request opcode + b += 1 -func init() { - xgb.NewErrorFuncs[6] = CursorErrorNew -} + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -// BadFont is the error number for a BadFont. -const BadFont = 7 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -type FontError ValueError + xgb.Put32(buf[b:], uint32(Cmap)) + 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 -} + xgb.Put16(buf[b:], Colors) + b += 2 -// SequenceId returns the sequence id attached to the BadFont error. -// This is mostly used internally. -func (err FontError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], Reds) + b += 2 -// 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 -} + xgb.Put16(buf[b:], Greens) + b += 2 -// 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, ", ") + "}" -} + xgb.Put16(buf[b:], Blues) + b += 2 -func init() { - xgb.NewErrorFuncs[7] = FontErrorNew + return buf } -// 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 +// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. +type AllocNamedColorCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the BadMatch error. -// This is mostly used internally. -func (err MatchError) SequenceId() uint16 { - return err.Sequence +// 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} } -// 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 +// 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} } -// 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, ", ") + "}" +// 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 } -func init() { - xgb.NewErrorFuncs[8] = MatchErrorNew +// 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 } -// BadDrawable is the error number for a BadDrawable. -const BadDrawable = 9 +// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. +func allocNamedColorReply(buf []byte) *AllocNamedColorReply { + v := new(AllocNamedColorReply) + b := 1 // skip reply determinant -type DrawableError ValueError + b += 1 // padding -// 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 -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the BadDrawable error. -// This is mostly used internally. -func (err DrawableError) 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 BadDrawable error. If no bad value exists, 0 is returned. -func (err DrawableError) BadId() uint32 { - return err.BadValue -} + v.Pixel = xgb.Get32(buf[b:]) + 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.ExactRed = xgb.Get16(buf[b:]) + b += 2 -func init() { - xgb.NewErrorFuncs[9] = DrawableErrorNew -} + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 -// BadAccess is the error number for a BadAccess. -const BadAccess = 10 + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 -type AccessError RequestError + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 -// 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 -} + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the BadAccess error. -// This is mostly used internally. -func (err AccessError) SequenceId() uint16 { - return err.Sequence -} + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 -// 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 + return v } -// 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, ", ") + "}" -} +// 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) -func init() { - xgb.NewErrorFuncs[10] = AccessErrorNew -} + buf[b] = 85 // request opcode + b += 1 -// BadAlloc is the error number for a BadAlloc. -const BadAlloc = 11 + b += 1 // padding -type AllocError RequestError + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + 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.Put32(buf[b:], uint32(Cmap)) + b += 4 -// SequenceId returns the sequence id attached to the BadAlloc error. -// This is mostly used internally. -func (err AllocError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], NameLen) + b += 2 -// 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 -} + b += 2 // padding -// 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, ", ") + "}" -} + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) -func init() { - xgb.NewErrorFuncs[11] = AllocErrorNew + return buf } -// 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 +// AllowEventsCookie is a cookie used only for AllowEvents requests. +type AllowEventsCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the BadColormap error. -// This is mostly used internally. -func (err ColormapError) SequenceId() uint16 { - return err.Sequence +// 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} } -// 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 +// 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} } -// 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, ", ") + "}" +// Check returns an error if one occurred 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() } -func init() { - xgb.NewErrorFuncs[12] = ColormapErrorNew -} +// 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) -// BadGContext is the error number for a BadGContext. -const BadGContext = 13 + buf[b] = 35 // request opcode + b += 1 -type GContextError ValueError + buf[b] = Mode + b += 1 -// 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 + 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 } -// SequenceId returns the sequence id attached to the BadGContext error. -// This is mostly used internally. -func (err GContextError) SequenceId() uint16 { - return err.Sequence +// BellCookie is a cookie used only for Bell requests. +type BellCookie struct { + *xgb.Cookie } -// 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 +// 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} } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[13] = GContextErrorNew +// Check returns an error if one occurred 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() } -// BadIDChoice is the error number for a BadIDChoice. -const BadIDChoice = 14 +// 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) -type IDChoiceError ValueError + buf[b] = 104 // request opcode + b += 1 -// 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 -} + buf[b] = byte(Percent) + b += 1 -// SequenceId returns the sequence id attached to the BadIDChoice error. -// This is mostly used internally. -func (err IDChoiceError) SequenceId() uint16 { - return err.Sequence + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf } -// 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 +// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. +type ChangeActivePointerGrabCookie struct { + *xgb.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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[14] = IDChoiceErrorNew +// 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} } -// BadName is the error number for a BadName. -const BadName = 15 +// Check returns an error if one occurred 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() +} -type NameError RequestError +// 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) -// 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 -} + buf[b] = 30 // request opcode + b += 1 -// SequenceId returns the sequence id attached to the BadName error. -// This is mostly used internally. -func (err NameError) SequenceId() uint16 { - return err.Sequence -} + b += 1 // padding -// 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 -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// 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, ", ") + "}" -} + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 -func init() { - xgb.NewErrorFuncs[15] = NameErrorNew -} + xgb.Put32(buf[b:], uint32(Time)) + b += 4 -// BadLength is the error number for a BadLength. -const BadLength = 16 + xgb.Put16(buf[b:], EventMask) + b += 2 -type LengthError RequestError + b += 2 // padding -// 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 + return buf } -// SequenceId returns the sequence id attached to the BadLength error. -// This is mostly used internally. -func (err LengthError) SequenceId() uint16 { - return err.Sequence +// ChangeGCCookie is a cookie used only for ChangeGC requests. +type ChangeGCCookie struct { + *xgb.Cookie } -// 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 +// 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} } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[16] = LengthErrorNew +// Check returns an error if one occurred 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() } -// BadImplementation is the error number for a BadImplementation. -const BadImplementation = 17 +// 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) -type ImplementationError RequestError + buf[b] = 56 // request opcode + b += 1 -// 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 += 1 // padding -// SequenceId returns the sequence id attached to the BadImplementation error. -// This is mostly used internally. -func (err ImplementationError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// 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 -} + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 -// 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, ", ") + "}" -} + 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.NewErrorFuncs[17] = ImplementationErrorNew + return buf } -// CreateWindowCookie is a cookie used only for CreateWindow requests. -type CreateWindowCookie struct { +// ChangeHostsCookie is a cookie used only for ChangeHosts requests. +type ChangeHostsCookie struct { *xgb.Cookie } -// CreateWindow 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 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 ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { 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(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{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 { +// 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(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{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 ChangeHostsCookie) 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 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) - buf[b] = 1 // request opcode + buf[b] = 109 // request opcode b += 1 - buf[b] = Depth + 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(Wid)) - b += 4 + buf[b] = Family + b += 1 - xgb.Put32(buf[b:], uint32(Parent)) - b += 4 + b += 1 // padding - xgb.Put16(buf[b:], uint16(X)) + xgb.Put16(buf[b:], AddressLen) b += 2 - xgb.Put16(buf[b:], uint16(Y)) - b += 2 + copy(buf[b:], Address[:AddressLen]) + b += xgb.Pad(int(AddressLen)) - xgb.Put16(buf[b:], Width) - b += 2 + return buf +} - xgb.Put16(buf[b:], Height) - b += 2 +// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. +type ChangeKeyboardControlCookie struct { + *xgb.Cookie +} - xgb.Put16(buf[b:], BorderWidth) - b += 2 +// 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} +} - xgb.Put16(buf[b:], Class) - b += 2 +// 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} +} - xgb.Put32(buf[b:], uint32(Visual)) - b += 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 ChangeKeyboardControlCookie) 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))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 102 // 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:], ValueMask) b += 4 @@ -6485,55 +7180,59 @@ func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X i return buf } -// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. -type ChangeWindowAttributesCookie struct { +// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. +type ChangeKeyboardMappingCookie struct { *xgb.Cookie } -// ChangeWindowAttributes sends an unchecked request. +// ChangeKeyboardMapping 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 ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{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 { +// 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(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + 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 ChangeWindowAttributesCookie) Check() error { +func (cook ChangeKeyboardMappingCookie) 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 { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// 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] = 2 // 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 - xgb.Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) + 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) @@ -6541,145 +7240,113 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, return buf } -// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. -type GetWindowAttributesCookie struct { +// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. +type ChangePointerControlCookie 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. +// ChangePointerControl 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} -} - -// 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 +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} } -// 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 +// 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} } -// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. -func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { - v := new(GetWindowAttributesReply) - b := 1 // skip reply determinant - - v.BackingStore = buf[b] - 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 ChangePointerControlCookie) Check() error { + return cook.Cookie.Check() +} - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// 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) - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + buf[b] = 105 // request opcode + b += 1 - v.Visual = Visualid(xgb.Get32(buf[b:])) - b += 4 + b += 1 // padding - v.Class = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.BitGravity = buf[b] - b += 1 - - v.WinGravity = buf[b] - b += 1 - - v.BackingPlanes = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(AccelerationNumerator)) + b += 2 - v.BackingPixel = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(AccelerationDenominator)) + b += 2 - if buf[b] == 1 { - v.SaveUnder = true - } else { - v.SaveUnder = false - } - b += 1 + xgb.Put16(buf[b:], uint16(Threshold)) + b += 2 - if buf[b] == 1 { - v.MapIsInstalled = true + if DoAcceleration { + buf[b] = 1 } else { - v.MapIsInstalled = false + buf[b] = 0 } b += 1 - v.MapState = buf[b] - b += 1 - - if buf[b] == 1 { - v.OverrideRedirect = true + if DoThreshold { + buf[b] = 1 } else { - v.OverrideRedirect = false + buf[b] = 0 } b += 1 - v.Colormap = Colormap(xgb.Get32(buf[b:])) - b += 4 - - v.AllEventMasks = xgb.Get32(buf[b:]) - b += 4 + return buf +} - v.YourEventMask = xgb.Get32(buf[b:]) - b += 4 +// ChangePropertyCookie is a cookie used only for ChangeProperty requests. +type ChangePropertyCookie struct { + *xgb.Cookie +} - v.DoNotPropagateMask = xgb.Get16(buf[b:]) - b += 2 +// ChangeProperty 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} +} - b += 2 // padding +// 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(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{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 ChangePropertyCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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] = 3 // 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 @@ -6687,47 +7354,65 @@ func getWindowAttributesRequest(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 } -// DestroyWindowCookie is a cookie used only for DestroyWindow requests. -type DestroyWindowCookie struct { +// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. +type ChangeSaveSetCookie struct { *xgb.Cookie } -// DestroyWindow sends an unchecked request. +// ChangeSaveSet 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 ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { cookie := c.NewCookie(false, false) - c.NewRequest(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{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 { +// ChangeSaveSetChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check() +func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { cookie := c.NewCookie(true, false) - c.NewRequest(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{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 ChangeSaveSetCookie) 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 { +// Write request to wire for ChangeSaveSet +// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice. +func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 4 // request opcode + buf[b] = 6 // 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 @@ -6738,41 +7423,41 @@ func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { return buf } -// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. -type DestroySubwindowsCookie struct { +// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. +type ChangeWindowAttributesCookie struct { *xgb.Cookie } -// DestroySubwindows 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 DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { +func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(destroySubwindowsRequest(c, Window), cookie) - return DestroySubwindowsCookie{cookie} + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{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 { +// 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(destroySubwindowsRequest(c, Window), cookie) - return DestroySubwindowsCookie{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 DestroySubwindowsCookie) Check() error { +func (cook ChangeWindowAttributesCookie) 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 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] = 5 // request opcode + buf[b] = 2 // request opcode b += 1 b += 1 // padding @@ -6783,47 +7468,55 @@ func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) 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 } -// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. -type ChangeSaveSetCookie struct { +// CirculateWindowCookie is a cookie used only for CirculateWindow requests. +type CirculateWindowCookie struct { *xgb.Cookie } -// ChangeSaveSet 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 ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { +func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} } -// ChangeSaveSetChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check() -func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { +// 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(changeSaveSetRequest(c, Mode, Window), cookie) - return ChangeSaveSetCookie{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 ChangeSaveSetCookie) Check() error { +func (cook CirculateWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeSaveSet -// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice. -func changeSaveSetRequest(c *xgb.Conn, Mode byte, 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] = 6 // request opcode + buf[b] = 13 // request opcode b += 1 - buf[b] = Mode + buf[b] = Direction b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6835,44 +7528,49 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { return buf } -// ReparentWindowCookie is a cookie used only for ReparentWindow requests. -type ReparentWindowCookie struct { +// ClearAreaCookie is a cookie used only for ClearArea requests. +type ClearAreaCookie struct { *xgb.Cookie } -// ReparentWindow 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 ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} +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} } -// 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 { +// 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(reparentWindowRequest(c, Window, Parent, X, Y), cookie) - return ReparentWindowCookie{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 ReparentWindowCookie) Check() error { +func (cook ClearAreaCookie) 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 { +// 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] = 7 // 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 @@ -6880,53 +7578,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)) - 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 } -// MapWindowCookie is a cookie used only for MapWindow requests. -type MapWindowCookie struct { +// CloseFontCookie is a cookie used only for CloseFont requests. +type CloseFontCookie struct { *xgb.Cookie } -// MapWindow 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 MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { +func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { cookie := c.NewCookie(false, false) - c.NewRequest(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{cookie} + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{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 { +// 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(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{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 MapWindowCookie) Check() error { +func (cook CloseFontCookie) 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 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] = 8 // request opcode + buf[b] = 46 // request opcode b += 1 b += 1 // padding @@ -6934,47 +7635,47 @@ func mapWindowRequest(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 } -// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. -type MapSubwindowsCookie struct { +// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. +type ConfigureWindowCookie struct { *xgb.Cookie } -// MapSubwindows sends an unchecked request. +// ConfigureWindow 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 ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(mapSubwindowsRequest(c, Window), cookie) - return MapSubwindowsCookie{cookie} + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{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 { +// ConfigureWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ConfigureWindowCookie.Check() +func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { cookie := c.NewCookie(true, false) - c.NewRequest(mapSubwindowsRequest(c, Window), cookie) - return MapSubwindowsCookie{cookie} + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{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 ConfigureWindowCookie) 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 ConfigureWindow +// configureWindowRequest writes a ConfigureWindow request to a byte slice. +func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { + size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 9 // request opcode + buf[b] = 12 // request opcode b += 1 b += 1 // padding @@ -6985,44 +7686,55 @@ func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put16(buf[b:], ValueMask) + b += 2 + + b += 2 // padding + + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// UnmapWindowCookie is a cookie used only for UnmapWindow requests. -type UnmapWindowCookie struct { +// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. +type ConvertSelectionCookie struct { *xgb.Cookie } -// UnmapWindow 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 UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { +func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { cookie := c.NewCookie(false, false) - c.NewRequest(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{cookie} + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{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 { +// 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(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{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 UnmapWindowCookie) Check() error { +func (cook ConvertSelectionCookie) 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 +// 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] = 10 // request opcode + buf[b] = 24 // request opcode b += 1 b += 1 // padding @@ -7030,47 +7742,59 @@ func unmapWindowRequest(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(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 } -// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. -type UnmapSubwindowsCookie struct { +// CopyAreaCookie is a cookie used only for CopyArea requests. +type CopyAreaCookie struct { *xgb.Cookie } -// UnmapSubwindows 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 UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { +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(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{cookie} + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{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 { +// 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(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{cookie} + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{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 CopyAreaCookie) 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 { - size := 8 +// 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] = 11 // request opcode + buf[b] = 62 // request opcode b += 1 b += 1 // padding @@ -7078,47 +7802,71 @@ 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(SrcDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) 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) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + return buf } -// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. -type ConfigureWindowCookie struct { +// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. +type CopyColormapAndFreeCookie struct { *xgb.Cookie } -// ConfigureWindow sends an unchecked request. +// CopyColormapAndFree sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { +func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { cookie := c.NewCookie(false, false) - c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} } -// ConfigureWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using ConfigureWindowCookie.Check() -func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { +// 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(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} + 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 ConfigureWindowCookie) Check() error { +func (cook CopyColormapAndFreeCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ConfigureWindow -// configureWindowRequest writes a ConfigureWindow request to a byte slice. -func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { - size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// 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] = 12 // request opcode + buf[b] = 80 // request opcode b += 1 b += 1 // padding @@ -7126,522 +7874,549 @@ func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueL 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(Mid)) b += 4 - xgb.Put16(buf[b:], ValueMask) - b += 2 - - b += 2 // padding - - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(SrcCmap)) + b += 4 return buf } -// CirculateWindowCookie is a cookie used only for CirculateWindow requests. -type CirculateWindowCookie struct { +// CopyGCCookie is a cookie used only for CopyGC requests. +type CopyGCCookie struct { *xgb.Cookie } -// CirculateWindow sends an unchecked request. +// CopyGC 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 CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { cookie := c.NewCookie(false, false) - c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) - return CirculateWindowCookie{cookie} + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{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 { +// 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(circulateWindowRequest(c, Direction, Window), cookie) - return CirculateWindowCookie{cookie} + 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 CirculateWindowCookie) Check() error { +func (cook CopyGCCookie) 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 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] = 13 // request opcode + buf[b] = 57 // 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(SrcGc)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstGc)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) b += 4 return buf } -// GetGeometryCookie is a cookie used only for GetGeometry requests. -type GetGeometryCookie struct { +// CopyPlaneCookie is a cookie used only for CopyPlane requests. +type CopyPlaneCookie 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. +// CopyPlane 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 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} } -// 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 +// 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 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 CopyPlaneCookie) 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 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) - v.Depth = buf[b] + buf[b] = 63 // 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:])) - b += 2 + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - v.Y = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 - v.Width = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - v.Height = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DstX)) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DstY)) b += 2 - 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:], Width) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Height) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], BitPlane) b += 4 return buf } -// QueryTreeCookie is a cookie used only for QueryTree requests. -type QueryTreeCookie struct { +// CreateColormapCookie is a cookie used only for CreateColormap requests. +type CreateColormapCookie 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} -} - -// QueryTreeUnchecked sends an unchecked request. +// CreateColormap 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} -} - -// 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)) +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} } -// 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 +// 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} } -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 - - v.ChildrenLen = xgb.Get16(buf[b:]) - b += 2 - - b += 14 // padding - - 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 +// Check returns an error if one occurred 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 QueryTree -// queryTreeRequest writes a QueryTree request to a byte slice. -func queryTreeRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// 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 + + 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)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFont)) + b += 4 + + xgb.Put16(buf[b:], SourceChar) + b += 2 + + xgb.Put16(buf[b:], MaskChar) + b += 2 + + xgb.Put16(buf[b:], ForeRed) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], ForeGreen) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], ForeBlue) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + xgb.Put16(buf[b:], BackRed) + b += 2 - v.NameLen = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], BackGreen) b += 2 - b += 22 // padding + xgb.Put16(buf[b:], BackBlue) + b += 2 - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } + return buf +} - return v +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { + *xgb.Cookie } -// 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 +// 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,248 +8472,244 @@ 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} +// DestroySubwindows 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} } -// GetPropertyUnchecked sends an unchecked request. +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = 5 // 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 +} + +// DestroyWindowCookie is a cookie used only for DestroyWindow requests. +type DestroyWindowCookie struct { + *xgb.Cookie +} + +// DestroyWindow 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 DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{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)) +// 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} } -// 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 DestroyWindowCookie) 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 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) - v.Format = buf[b] + buf[b] = 4 // 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 +// FillPolyCookie is a cookie used only for FillPoly requests. +type FillPolyCookie struct { + *xgb.Cookie +} - b += 12 // padding +// FillPoly 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{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)))) +// 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} +} - 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 FillPolyCookie) 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 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] = 20 // request opcode + buf[b] = 69 // 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 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put32(buf[b:], uint32(Type)) - b += 4 + buf[b] = Shape + b += 1 - xgb.Put32(buf[b:], LongOffset) - b += 4 + buf[b] = CoordinateMode + b += 1 - xgb.Put32(buf[b:], LongLength) - b += 4 + b += 2 // padding + + b += PointListBytes(buf[b:], Points) return buf } -// ListPropertiesCookie is a cookie used only for ListProperties requests. -type ListPropertiesCookie struct { +// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. +type ForceScreenSaverCookie 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. +// ForceScreenSaver 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} -} - -// 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)) +func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{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 +// 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} } -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.AtomsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - 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) - - 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 ForceScreenSaverCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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} -} - -// 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 +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} } -// 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 +// 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} } -// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. -func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { - v := new(GetSelectionOwnerReply) - 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 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 - 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,105 +8964,45 @@ func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { if buf == nil { return nil, nil } - return grabPointerReply(buf), nil -} - -// grabPointerReply reads a byte slice into a GrabPointerReply value. -func grabPointerReply(buf []byte) *GrabPointerReply { - v := new(GrabPointerReply) - 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 + return getAtomNameReply(buf), nil } -// 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 +// getAtomNameReply reads a byte slice into a GetAtomNameReply value. +func getAtomNameReply(buf []byte) *GetAtomNameReply { + v := new(GetAtomNameReply) + b := 1 // skip reply determinant - xgb.Put32(buf[b:], uint32(ConfineTo)) - b += 4 + b += 1 // padding - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 + 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 -} - -// UngrabPointerCookie is a cookie used only for UngrabPointer requests. -type UngrabPointerCookie struct { - *xgb.Cookie -} + v.NameLen = xgb.Get16(buf[b:]) + b += 2 -// UngrabPointer 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} -} + b += 22 // padding -// 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} -} + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } -// Check returns an error if one occurred 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() + return v } -// Write request to wire for UngrabPointer -// ungrabPointerRequest writes a UngrabPointer request to a byte slice. -func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { +// 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] = 27 // request opcode + buf[b] = 17 // request opcode b += 1 b += 1 // padding @@ -8301,177 +9010,188 @@ func ungrabPointerRequest(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)) + xgb.Put32(buf[b:], uint32(Atom)) b += 4 return buf } -// GrabButtonCookie is a cookie used only for GrabButton requests. -type GrabButtonCookie struct { +// GetFontPathCookie is a cookie used only for GetFontPath requests. +type GetFontPathCookie 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} +// 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} } -// 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} +// GetFontPathUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{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() +// 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) } -// 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 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 +} - buf[b] = 28 // request opcode - b += 1 +// getFontPathReply reads a byte slice into a GetFontPathReply value. +func getFontPathReply(buf []byte) *GetFontPathReply { + v := new(GetFontPathReply) + b := 1 // skip reply determinant - 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 + 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.PathLen = xgb.Get16(buf[b:]) b += 2 - buf[b] = PointerMode - b += 1 + b += 22 // padding - buf[b] = KeyboardMode - b += 1 + v.Path = make([]Str, v.PathLen) + b += StrReadList(buf[b:], v.Path) - xgb.Put32(buf[b:], uint32(ConfineTo)) - b += 4 + return v +} - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 +// 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] = Button + buf[b] = 52 // request opcode b += 1 - b += 1 // padding - - xgb.Put16(buf[b:], Modifiers) + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 return buf } -// UngrabButtonCookie is a cookie used only for UngrabButton requests. -type UngrabButtonCookie struct { +// GetGeometryCookie is a cookie used only for GetGeometry requests. +type GetGeometryCookie 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} +// 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} } -// 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} +// 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 UngrabButtonCookie) 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 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 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] = 29 // 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 - 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 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - b += 2 // padding + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - return buf -} + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 -// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. -type ChangeActivePointerGrabCookie struct { - *xgb.Cookie -} + v.Width = xgb.Get16(buf[b:]) + 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} -} + v.Height = xgb.Get16(buf[b:]) + 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} -} + v.BorderWidth = 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 ChangeActivePointerGrabCookie) Check() error { - return cook.Cookie.Check() + b += 2 // padding + + 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 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] = 30 // request opcode + buf[b] = 14 // request opcode b += 1 b += 1 // padding @@ -8479,50 +9199,45 @@ func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], EventMask) - b += 2 - - b += 2 // padding - return buf } -// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. -type GrabKeyboardCookie struct { +// GetImageCookie is a cookie used only for GetImage requests. +type GetImageCookie 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 { +// 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(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} } -// GrabKeyboardUnchecked sends an unchecked request. +// GetImageUnchecked 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 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(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} } -// GrabKeyboardReply represents the data returned from a GrabKeyboard request. -type GrabKeyboardReply struct { +// 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 - Status byte + Depth byte + Visual Visualid + // padding: 20 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// 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 GetImage request. +func (cook GetImageCookie) Reply() (*GetImageReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8530,15 +9245,15 @@ func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { if buf == nil { return nil, nil } - return grabKeyboardReply(buf), nil + return getImageReply(buf), nil } -// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. -func grabKeyboardReply(buf []byte) *GrabKeyboardReply { - v := new(GrabKeyboardReply) +// getImageReply reads a byte slice into a GetImageReply value. +func getImageReply(buf []byte) *GetImageReply { + v := new(GetImageReply) b := 1 // skip reply determinant - v.Status = buf[b] + v.Depth = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -8547,299 +9262,226 @@ func grabKeyboardReply(buf []byte) *GrabKeyboardReply { 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 } -// 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 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] = 31 // request opcode + buf[b] = 73 // request opcode b += 1 - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } + 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(GrabWindow)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - b += 2 // padding - - return buf -} - -// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. -type UngrabKeyboardCookie struct { - *xgb.Cookie -} - -// UngrabKeyboard 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) + xgb.Put16(buf[b:], uint16(X)) + b += 2 - buf[b] = 32 // request opcode - b += 1 + xgb.Put16(buf[b:], uint16(Y)) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], Width) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Height) b += 2 - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], PlaneMask) b += 4 return buf } -// GrabKeyCookie is a cookie used only for GrabKey requests. -type GrabKeyCookie struct { +// GetInputFocusCookie is a cookie used only for GetInputFocus requests. +type GetInputFocusCookie 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} +// 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(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{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} +// GetInputFocusUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{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() +// 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 + RevertTo byte + Focus Window } -// 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] = 33 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 +// 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 } - 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 - - buf[b] = byte(Key) - b += 1 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 + if buf == nil { + return nil, nil + } + return getInputFocusReply(buf), nil +} - b += 3 // padding +// getInputFocusReply reads a byte slice into a GetInputFocusReply value. +func getInputFocusReply(buf []byte) *GetInputFocusReply { + v := new(GetInputFocusReply) + b := 1 // skip reply determinant - return buf -} + v.RevertTo = buf[b] + b += 1 -// UngrabKeyCookie is a cookie used only for UngrabKey requests. -type UngrabKeyCookie struct { - *xgb.Cookie -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// UngrabKey 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} -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// 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} -} + v.Focus = Window(xgb.Get32(buf[b:])) + b += 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 UngrabKeyCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 +// 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] = 34 // request opcode - b += 1 - - buf[b] = byte(Key) + buf[b] = 43 // 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(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - return buf } -// AllowEventsCookie is a cookie used only for AllowEvents requests. -type AllowEventsCookie struct { +// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. +type GetKeyboardControlCookie 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} +// 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} } -// 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} +// 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} } -// Check returns an error if one occurred 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() +// 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 } -// 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 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 +} - buf[b] = 35 // request opcode - b += 1 +// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. +func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { + v := new(GetKeyboardControlReply) + b := 1 // skip reply determinant - buf[b] = Mode + 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(Time)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} + v.LedMask = xgb.Get32(buf[b:]) + b += 4 -// GrabServerCookie is a cookie used only for GrabServer requests. -type GrabServerCookie struct { - *xgb.Cookie -} + v.KeyClickPercent = buf[b] + b += 1 -// 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.BellPercent = buf[b] + b += 1 -// 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} -} + v.BellPitch = 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 GrabServerCookie) Check() error { - return cook.Cookie.Check() + 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 GrabServer -// grabServerRequest writes a GrabServer request to a byte slice. -func grabServerRequest(c *xgb.Conn) []byte { +// 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] = 36 // request opcode + buf[b] = 103 // request opcode b += 1 b += 1 // padding @@ -8849,88 +9491,130 @@ func grabServerRequest(c *xgb.Conn) []byte { return buf } -// UngrabServerCookie is a cookie used only for UngrabServer requests. -type UngrabServerCookie struct { +// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. +type GetKeyboardMappingCookie struct { *xgb.Cookie } -// UngrabServer 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 UngrabServer(c *xgb.Conn) UngrabServerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabServerRequest(c), cookie) - return UngrabServerCookie{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} } -// 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} +// 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 UngrabServerCookie) 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 UngrabServer -// ungrabServerRequest writes a UngrabServer request to a byte slice. -func ungrabServerRequest(c *xgb.Conn) []byte { - size := 4 +// 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] = 37 // request opcode + buf[b] = 101 // 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 + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + return buf } -// QueryPointerCookie is a cookie used only for QueryPointer requests. -type QueryPointerCookie struct { +// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. +type GetModifierMappingCookie 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 { +// 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(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} } -// QueryPointerUnchecked sends an unchecked request. +// GetModifierMappingUnchecked 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 GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} } -// 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 +// 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)) } -// 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 GetModifierMapping request. +func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8938,19 +9622,15 @@ func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { if buf == nil { return nil, nil } - return queryPointerReply(buf), nil + return getModifierMappingReply(buf), nil } -// queryPointerReply reads a byte slice into a QueryPointerReply value. -func queryPointerReply(buf []byte) *QueryPointerReply { - v := new(QueryPointerReply) +// getModifierMappingReply reads a byte slice into a GetModifierMappingReply value. +func getModifierMappingReply(buf []byte) *GetModifierMappingReply { + v := new(GetModifierMappingReply) b := 1 // skip reply determinant - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } + v.KeycodesPerModifier = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -8959,50 +9639,32 @@ func queryPointerReply(buf []byte) *QueryPointerReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Root = 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.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.Mask = xgb.Get16(buf[b:]) - b += 2 + b += 24 // padding - b += 2 // 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 } -// 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 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] = 38 // request opcode + buf[b] = 119 // 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 } @@ -9100,261 +9762,211 @@ func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Ti return buf } -// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. -type TranslateCoordinatesCookie struct { +// GetPointerControlCookie is a cookie used only for GetPointerControl requests. +type GetPointerControlCookie 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 { +// 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(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} } -// TranslateCoordinatesUnchecked sends an unchecked request. +// GetPointerControlUnchecked 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 GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { cookie := c.NewCookie(false, true) - c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{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 +// 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 } -// 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 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 translateCoordinatesReply(buf), nil -} - -// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. -func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { - v := new(TranslateCoordinatesReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Child = Window(xgb.Get32(buf[b:])) - b += 4 - - v.DstX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.DstY = int16(xgb.Get16(buf[b:])) - b += 2 - - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = 40 // 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(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 -} - -// WarpPointerCookie is a cookie used only for WarpPointer requests. -type WarpPointerCookie struct { - *xgb.Cookie -} - -// WarpPointer 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{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 { - return cook.Cookie.Check() + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerControlReply(buf), nil } -// 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] = 41 // 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 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(SrcWindow)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) + v.AccelerationNumerator = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(SrcY)) + v.AccelerationDenominator = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], SrcWidth) + v.Threshold = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], SrcHeight) - b += 2 + b += 18 // padding - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 + return v +} - xgb.Put16(buf[b:], uint16(DstY)) +// 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] = 106 // 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 } -// SetInputFocusCookie is a cookie used only for SetInputFocus requests. -type SetInputFocusCookie struct { +// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. +type GetPointerMappingCookie struct { *xgb.Cookie } -// SetInputFocus 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{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} } -// 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(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} +// GetPointerMappingUnchecked 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} } -// Check returns an error if one occurred 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 { - return cook.Cookie.Check() +// 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)) } -// 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) +// 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 +} - buf[b] = 42 // request opcode - b += 1 +// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. +func getPointerMappingReply(buf []byte) *GetPointerMappingReply { + v := new(GetPointerMappingReply) + b := 1 // skip reply determinant - buf[b] = RevertTo + v.MapLen = 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(Focus)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Time)) - 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] = 117 // 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 } -// GetInputFocusCookie is a cookie used only for GetInputFocus requests. -type GetInputFocusCookie struct { +// GetPropertyCookie is a cookie used only for GetProperty requests. +type GetPropertyCookie 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 { +// 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(getInputFocusRequest(c), cookie) - return GetInputFocusCookie{cookie} + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} } -// GetInputFocusUnchecked 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 GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { +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(getInputFocusRequest(c), cookie) - return GetInputFocusCookie{cookie} + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} } -// 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 - RevertTo byte - Focus Window +// 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)) } -// 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 GetProperty request. +func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9362,15 +9974,15 @@ func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { if buf == nil { return nil, nil } - return getInputFocusReply(buf), nil + return getPropertyReply(buf), nil } -// getInputFocusReply reads a byte slice into a GetInputFocusReply value. -func getInputFocusReply(buf []byte) *GetInputFocusReply { - v := new(GetInputFocusReply) +// getPropertyReply reads a byte slice into a GetPropertyReply value. +func getPropertyReply(buf []byte) *GetPropertyReply { + v := new(GetPropertyReply) b := 1 // skip reply determinant - v.RevertTo = buf[b] + v.Format = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -9379,60 +9991,97 @@ func getInputFocusReply(buf []byte) *GetInputFocusReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Focus = Window(xgb.Get32(buf[b:])) + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 + + v.ValueLen = xgb.Get32(buf[b:]) b += 4 + b += 12 // 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 GetInputFocus -// getInputFocusRequest writes a GetInputFocus request to a byte slice. -func getInputFocusRequest(c *xgb.Conn) []byte { - size := 4 +// 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] = 43 // request opcode + buf[b] = 20 // 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 + 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 } -// QueryKeymapCookie is a cookie used only for QueryKeymap requests. -type QueryKeymapCookie struct { +// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. +type GetScreenSaverCookie 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 { +// 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(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} } -// QueryKeymapUnchecked 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 QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { +func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} } -// QueryKeymapReply represents the data returned from a QueryKeymap request. -type QueryKeymapReply 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 - Keys []byte // size: 32 + Timeout uint16 + Interval uint16 + PreferBlanking byte + AllowExposures byte + // padding: 18 bytes } -// 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 GetScreenSaver request. +func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9440,12 +10089,12 @@ func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { if buf == nil { return nil, nil } - return queryKeymapReply(buf), nil + return getScreenSaverReply(buf), nil } -// queryKeymapReply reads a byte slice into a QueryKeymapReply value. -func queryKeymapReply(buf []byte) *QueryKeymapReply { - v := new(QueryKeymapReply) +// 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 @@ -9456,21 +10105,31 @@ 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)) + v.Timeout = xgb.Get16(buf[b:]) + b += 2 + + v.Interval = xgb.Get16(buf[b:]) + b += 2 + + v.PreferBlanking = buf[b] + b += 1 + + v.AllowExposures = buf[b] + b += 1 + + b += 18 // padding 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 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] = 44 // request opcode + buf[b] = 108 // request opcode b += 1 b += 1 // padding @@ -9480,97 +10139,74 @@ func queryKeymapRequest(c *xgb.Conn) []byte { return buf } -// OpenFontCookie is a cookie used only for OpenFont requests. -type OpenFontCookie struct { +// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. +type GetSelectionOwnerCookie struct { *xgb.Cookie } -// OpenFont 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) - return OpenFontCookie{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} } -// 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(openFontRequest(c, Fid, NameLen, Name), cookie) - return OpenFontCookie{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} } -// Check returns an error if one occurred 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 { - return cook.Cookie.Check() +// 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 } -// 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) +// 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 +} - buf[b] = 45 // request opcode - b += 1 +// 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(Fid)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - - return buf -} - -// CloseFontCookie is a cookie used only for CloseFont requests. -type CloseFontCookie struct { - *xgb.Cookie -} - -// CloseFont 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(closeFontRequest(c, Font), cookie) - return CloseFontCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(closeFontRequest(c, Font), cookie) - return CloseFontCookie{cookie} -} + v.Owner = Window(xgb.Get32(buf[b:])) + b += 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 CloseFontCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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] = 46 // request opcode + buf[b] = 23 // request opcode b += 1 b += 1 // padding @@ -9578,59 +10214,57 @@ 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(Selection)) b += 4 return buf } -// QueryFontCookie is a cookie used only for QueryFont requests. -type QueryFontCookie struct { +// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. +type GetWindowAttributesCookie 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 { +// 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(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} } -// QueryFontUnchecked 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 QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { +func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} } -// 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 - 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)) +// 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 QueryFont request. -func (cook QueryFontCookie) Reply() (*QueryFontReply, 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 @@ -9638,86 +10272,90 @@ func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { if buf == nil { return nil, nil } - return queryFontReply(buf), nil + return getWindowAttributesReply(buf), nil } -// queryFontReply reads a byte slice into a QueryFontReply value. -func queryFontReply(buf []byte) *QueryFontReply { - v := new(QueryFontReply) +// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. +func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { + v := new(GetWindowAttributesReply) b := 1 // skip reply determinant - b += 1 // padding + v.BackingStore = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 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 - b += 4 // padding + v.Visual = Visualid(xgb.Get32(buf[b:])) + b += 4 - v.MinCharOrByte2 = xgb.Get16(buf[b:]) + v.Class = xgb.Get16(buf[b:]) b += 2 - v.MaxCharOrByte2 = xgb.Get16(buf[b:]) - b += 2 + v.BitGravity = buf[b] + b += 1 - v.DefaultChar = xgb.Get16(buf[b:]) - b += 2 + v.WinGravity = buf[b] + b += 1 - v.PropertiesLen = xgb.Get16(buf[b:]) - b += 2 + v.BackingPlanes = xgb.Get32(buf[b:]) + b += 4 - v.DrawDirection = buf[b] + v.BackingPixel = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.SaveUnder = true + } else { + v.SaveUnder = false + } b += 1 - v.MinByte1 = buf[b] + if buf[b] == 1 { + v.MapIsInstalled = true + } else { + v.MapIsInstalled = false + } b += 1 - v.MaxByte1 = buf[b] + v.MapState = buf[b] b += 1 if buf[b] == 1 { - v.AllCharsExist = true + v.OverrideRedirect = true } else { - v.AllCharsExist = false + v.OverrideRedirect = false } b += 1 - v.FontAscent = int16(xgb.Get16(buf[b:])) - b += 2 + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 - v.FontDescent = int16(xgb.Get16(buf[b:])) - b += 2 + v.AllEventMasks = xgb.Get32(buf[b:]) + b += 4 - v.CharInfosLen = xgb.Get32(buf[b:]) + v.YourEventMask = xgb.Get32(buf[b:]) b += 4 - v.Properties = make([]Fontprop, v.PropertiesLen) - b += FontpropReadList(buf[b:], v.Properties) + v.DoNotPropagateMask = xgb.Get16(buf[b:]) + b += 2 - v.CharInfos = make([]Charinfo, v.CharInfosLen) - b += CharinfoReadList(buf[b:], v.CharInfos) + b += 2 // padding return v } -// Write request to wire for QueryFont -// queryFontRequest writes a QueryFont request to a byte slice. -func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { +// 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] = 47 // request opcode + buf[b] = 3 // request opcode b += 1 b += 1 // padding @@ -9725,264 +10363,185 @@ 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:], uint32(Window)) b += 4 return buf } -// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. -type QueryTextExtentsCookie struct { +// GrabButtonCookie is a cookie used only for GrabButton requests. +type GrabButtonCookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} -} - -// QueryTextExtentsUnchecked 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 QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} +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} } -// 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 +// 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} } -// 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 - } - if buf == nil { - return nil, nil - } - return queryTextExtentsReply(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 GrabButtonCookie) Check() error { + return cook.Cookie.Check() } -// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. -func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { - v := new(QueryTextExtentsReply) - b := 1 // skip reply determinant +// 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) - v.DrawDirection = buf[b] + buf[b] = 28 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + if OwnerEvents { + buf[b] = 1 + } else { + 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:])) - b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 - v.OverallAscent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], EventMask) b += 2 - v.OverallDescent = int16(xgb.Get16(buf[b:])) - b += 2 + buf[b] = PointerMode + b += 1 - v.OverallWidth = int32(xgb.Get32(buf[b:])) - b += 4 + buf[b] = KeyboardMode + b += 1 - v.OverallLeft = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(ConfineTo)) b += 4 - v.OverallRight = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 48 // request opcode + buf[b] = Button b += 1 - buf[b] = byte((int(StringLen) & 1)) - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Modifiers) b += 2 - xgb.Put32(buf[b:], uint32(Font)) - b += 4 - - b += Char2bListBytes(buf[b:], String) - - // skip writing local field: StringLen (2) :: uint16 - return buf } -// ListFontsCookie is a cookie used only for ListFonts requests. -type ListFontsCookie struct { +// GrabKeyCookie is a cookie used only for GrabKey requests. +type GrabKeyCookie struct { *xgb.Cookie } -// ListFonts sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListFontsCookie.Reply() -func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -// ListFontsUnchecked 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 ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -// ListFontsReply represents the data returned from a ListFonts request. -type ListFontsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NamesLen uint16 - // padding: 22 bytes - Names []Str // size: StrListSize(Names) -} - -// Reply blocks and returns the reply data for a ListFonts request. -func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listFontsReply(buf), nil +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} } -// listFontsReply reads a byte slice into a ListFontsReply value. -func listFontsReply(buf []byte) *ListFontsReply { - v := new(ListFontsReply) - 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.NamesLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Names = make([]Str, v.NamesLen) - b += StrReadList(buf[b:], v.Names) +// 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} +} - 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 GrabKeyCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for ListFonts -// listFontsRequest writes a ListFonts request to a byte slice. -func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 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) - buf[b] = 49 // request opcode + buf[b] = 33 // 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.Put16(buf[b:], MaxNames) - b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 - xgb.Put16(buf[b:], PatternLen) + xgb.Put16(buf[b:], Modifiers) b += 2 - copy(buf[b:], Pattern[:PatternLen]) - b += xgb.Pad(int(PatternLen)) + buf[b] = byte(Key) + b += 1 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 3 // padding return buf } -// ListFontsWithInfoCookie is a cookie used only for ListFontsWithInfo requests. -type ListFontsWithInfoCookie struct { +// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. +type GrabKeyboardCookie struct { *xgb.Cookie } -// ListFontsWithInfo sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListFontsWithInfoCookie.Reply() -func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { +// 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(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} } -// ListFontsWithInfoUnchecked 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 ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { +func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(false, true) - c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} } -// ListFontsWithInfoReply represents the data returned from a ListFontsWithInfo request. -type ListFontsWithInfoReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - NameLen byte - 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 - RepliesHint uint32 - Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) - Name string // size: xgb.Pad((int(NameLen) * 1)) +// 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 + Status byte } -// Reply blocks and returns the reply data for a ListFontsWithInfo request. -func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, 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 @@ -9990,15 +10549,15 @@ func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { if buf == nil { return nil, nil } - return listFontsWithInfoReply(buf), nil + return grabKeyboardReply(buf), nil } -// listFontsWithInfoReply reads a byte slice into a ListFontsWithInfoReply value. -func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { - v := new(ListFontsWithInfoReply) +// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. +func grabKeyboardReply(buf []byte) *GrabKeyboardReply { + v := new(GrabKeyboardReply) b := 1 // skip reply determinant - v.NameLen = buf[b] + v.Status = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -10007,178 +10566,76 @@ func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { 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.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.FontDescent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RepliesHint = xgb.Get32(buf[b:]) - b += 4 - - v.Properties = make([]Fontprop, v.PropertiesLen) - b += FontpropReadList(buf[b:], v.Properties) - - { - 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 ListFontsWithInfo -// listFontsWithInfoRequest writes a ListFontsWithInfo request to a byte slice. -func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +// 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] = 50 // request opcode + buf[b] = 31 // 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.Put16(buf[b:], MaxNames) - b += 2 - - xgb.Put16(buf[b:], PatternLen) - b += 2 - - copy(buf[b:], Pattern[:PatternLen]) - b += xgb.Pad(int(PatternLen)) - - 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() -} + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 -// 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) + xgb.Put32(buf[b:], uint32(Time)) + b += 4 - buf[b] = 51 // request opcode + buf[b] = PointerMode 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 + buf[b] = KeyboardMode + b += 1 b += 2 // padding - b += StrListBytes(buf[b:], Font) - return buf } -// GetFontPathCookie is a cookie used only for GetFontPath requests. -type GetFontPathCookie struct { +// GrabPointerCookie is a cookie used only for GrabPointer requests. +type GrabPointerCookie 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 { +// 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(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} } -// GetFontPathUnchecked 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 GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { +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(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} } -// GetFontPathReply represents the data returned from a GetFontPath request. -type GetFontPathReply 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 - PathLen uint16 - // padding: 22 bytes - Path []Str // size: StrListSize(Path) + Status byte } -// 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 GrabPointer request. +func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -10186,15 +10643,16 @@ func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { if buf == nil { return nil, nil } - return getFontPathReply(buf), nil + return grabPointerReply(buf), nil } -// getFontPathReply reads a byte slice into a GetFontPathReply value. -func getFontPathReply(buf []byte) *GetFontPathReply { - v := new(GetFontPathReply) +// 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 @@ -10202,290 +10660,253 @@ func getFontPathReply(buf []byte) *GetFontPathReply { 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 +// 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] = 52 // request opcode + buf[b] = 26 // 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 - return buf -} - -// 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() -} + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 -// 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) + xgb.Put16(buf[b:], EventMask) + b += 2 - buf[b] = 53 // request opcode + buf[b] = PointerMode b += 1 - buf[b] = Depth + buf[b] = KeyboardMode 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(ConfineTo)) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 return buf } -// FreePixmapCookie is a cookie used only for FreePixmap requests. -type FreePixmapCookie struct { +// GrabServerCookie is a cookie used only for GrabServer requests. +type GrabServerCookie struct { *xgb.Cookie } -// FreePixmap sends an unchecked request. +// GrabServer 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 { +func GrabServer(c *xgb.Conn) GrabServerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{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 { +// 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(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} + 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 FreePixmapCookie) Check() error { +func (cook GrabServerCookie) Check() error { return cook.Cookie.Check() } -// 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 +// 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] = 54 // request opcode + buf[b] = 36 // 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(Pixmap)) - b += 4 - return buf } -// CreateGCCookie is a cookie used only for CreateGC requests. -type CreateGCCookie struct { +// ImageText16Cookie is a cookie used only for ImageText16 requests. +type ImageText16Cookie struct { *xgb.Cookie } -// CreateGC 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 CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { +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(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{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 { +// 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(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{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 CreateGCCookie) Check() error { +func (cook ImageText16Cookie) 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))))))) +// 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] = 55 // 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(Cid)) - b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Gc)) 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:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + b += Char2bListBytes(buf[b:], String) return buf } -// ChangeGCCookie is a cookie used only for ChangeGC requests. -type ChangeGCCookie struct { +// ImageText8Cookie is a cookie used only for ImageText8 requests. +type ImageText8Cookie struct { *xgb.Cookie } -// ChangeGC 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 ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { +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(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{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 { +// 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(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{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 ChangeGCCookie) Check() error { +func (cook ImageText8Cookie) Check() error { return cook.Cookie.Check() } -// 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 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] = 56 // request opcode + buf[b] = 76 // 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(Gc)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Gc)) 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:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], String[:StringLen]) + b += xgb.Pad(int(StringLen)) return buf } -// CopyGCCookie is a cookie used only for CopyGC requests. -type CopyGCCookie struct { +// InstallColormapCookie is a cookie used only for InstallColormap requests. +type InstallColormapCookie struct { *xgb.Cookie } -// CopyGC sends an unchecked request. +// InstallColormap 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 { +func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { cookie := c.NewCookie(false, false) - c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{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 { +// 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(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} + 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 CopyGCCookie) Check() error { +func (cook InstallColormapCookie) 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 +// 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] = 57 // request opcode + buf[b] = 81 // request opcode b += 1 b += 1 // padding @@ -10493,280 +10914,307 @@ func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32 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) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 return buf } -// SetDashesCookie is a cookie used only for SetDashes requests. -type SetDashesCookie struct { +// InternAtomCookie is a cookie used only for InternAtom requests. +type InternAtomCookie struct { *xgb.Cookie } -// SetDashes sends an unchecked request. +// 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. // 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 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} } -// 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} +// 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 } -// Check returns an error if one occurred 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 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 } -// 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)))) +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// 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) - buf[b] = 58 // request opcode + buf[b] = 16 // request opcode b += 1 - b += 1 // padding + if OnlyIfExists { + 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(Gc)) - b += 4 - - xgb.Put16(buf[b:], DashOffset) + xgb.Put16(buf[b:], NameLen) b += 2 - xgb.Put16(buf[b:], DashesLen) - b += 2 + b += 2 // padding - copy(buf[b:], Dashes[:DashesLen]) - b += xgb.Pad(int(DashesLen)) + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. -type SetClipRectanglesCookie struct { +// KillClientCookie is a cookie used only for KillClient requests. +type KillClientCookie struct { *xgb.Cookie } -// SetClipRectangles sends an unchecked request. +// KillClient 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 { +func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{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 { +// 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(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} + 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 SetClipRectanglesCookie) Check() error { +func (cook KillClientCookie) 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)))) +// 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] = 59 // request opcode + buf[b] = 113 // request opcode b += 1 - buf[b] = Ordering - 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(Gc)) + xgb.Put32(buf[b:], Resource) b += 4 - xgb.Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += RectangleListBytes(buf[b:], Rectangles) - return buf } -// FreeGCCookie is a cookie used only for FreeGC requests. -type FreeGCCookie struct { +// ListExtensionsCookie is a cookie used only for ListExtensions requests. +type ListExtensionsCookie struct { *xgb.Cookie } -// FreeGC sends an unchecked request. +// 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. // 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} +func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} } -// 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} +// 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 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 } -// Check returns an error if one occurred 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() +// 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 } -// 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 +// 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] = 60 // request opcode + buf[b] = 99 // 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(Gc)) - b += 4 - return buf } -// ClearAreaCookie is a cookie used only for ClearArea requests. -type ClearAreaCookie struct { +// ListFontsCookie is a cookie used only for ListFonts requests. +type ListFontsCookie 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} +// ListFonts sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListFontsCookie.Reply() +func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{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} +// ListFontsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{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() +// ListFontsReply represents the data returned from a ListFonts request. +type ListFontsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NamesLen uint16 + // padding: 22 bytes + Names []Str // size: StrListSize(Names) } -// 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 +// Reply blocks and returns the reply data for a ListFonts request. +func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + if buf == nil { + return nil, nil + } + return listFontsReply(buf), nil +} - xgb.Put32(buf[b:], uint32(Window)) - b += 4 +// listFontsReply reads a byte slice into a ListFontsReply value. +func listFontsReply(buf []byte) *ListFontsReply { + v := new(ListFontsReply) + b := 1 // skip reply determinant - xgb.Put16(buf[b:], uint16(X)) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], uint16(Y)) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Width) - b += 2 + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - xgb.Put16(buf[b:], Height) + v.NamesLen = xgb.Get16(buf[b:]) b += 2 - return buf -} - -// CopyAreaCookie is a cookie used only for CopyArea requests. -type CopyAreaCookie struct { - *xgb.Cookie -} - -// CopyArea 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} -} + b += 22 // padding -// 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} -} + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) -// Check returns an error if one occurred 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() + return v } -// 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 +// Write request to wire for ListFonts +// listFontsRequest writes a ListFonts request to a byte slice. +func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 62 // request opcode + buf[b] = 49 // request opcode b += 1 b += 1 // padding @@ -10774,307 +11222,340 @@ func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc 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)) - 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)) + xgb.Put16(buf[b:], MaxNames) b += 2 - xgb.Put16(buf[b:], Width) + xgb.Put16(buf[b:], PatternLen) b += 2 - xgb.Put16(buf[b:], Height) - b += 2 + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) return buf } -// CopyPlaneCookie is a cookie used only for CopyPlane requests. -type CopyPlaneCookie struct { +// ListFontsWithInfoCookie is a cookie used only for ListFontsWithInfo requests. +type ListFontsWithInfoCookie struct { *xgb.Cookie } -// CopyPlane sends an unchecked request. +// ListFontsWithInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListFontsWithInfoCookie.Reply() +func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{cookie} +} + +// ListFontsWithInfoUnchecked 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} +func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{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} +// ListFontsWithInfoReply represents the data returned from a ListFontsWithInfo request. +type ListFontsWithInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + NameLen byte + 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 + RepliesHint uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + Name string // size: xgb.Pad((int(NameLen) * 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 CopyPlaneCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a ListFontsWithInfo request. +func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listFontsWithInfoReply(buf), nil } -// 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) +// listFontsWithInfoReply reads a byte slice into a ListFontsWithInfoReply value. +func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { + v := new(ListFontsWithInfoReply) + b := 1 // skip reply determinant - buf[b] = 63 // request opcode + v.NameLen = buf[b] 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(SrcDrawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(DstDrawable)) - b += 4 + v.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + b += 4 // padding - xgb.Put16(buf[b:], uint16(SrcX)) + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(SrcY)) + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(DstX)) + v.DefaultChar = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(DstY)) + v.PropertiesLen = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Width) + 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 - xgb.Put16(buf[b:], Height) + v.FontDescent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put32(buf[b:], BitPlane) + v.RepliesHint = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// PolyPointCookie is a cookie used only for PolyPoint requests. -type PolyPointCookie struct { - *xgb.Cookie -} - -// PolyPoint 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) -// 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(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } -// Check returns an error if one occurred 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 { - return cook.Cookie.Check() + return v } -// 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 ListFontsWithInfo +// listFontsWithInfoRequest writes a ListFontsWithInfo request to a byte slice. +func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 64 // request opcode + buf[b] = 50 // 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.Put16(buf[b:], MaxNames) + b += 2 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + xgb.Put16(buf[b:], PatternLen) + b += 2 - b += PointListBytes(buf[b:], Points) + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) return buf } -// PolyLineCookie is a cookie used only for PolyLine requests. -type PolyLineCookie struct { +// ListHostsCookie is a cookie used only for ListHosts requests. +type ListHostsCookie struct { *xgb.Cookie } -// PolyLine 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{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 { + cookie := c.NewCookie(true, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} +// ListHostsUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{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 { - return cook.Cookie.Check() +// 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) } -// 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) +// 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 + } + if buf == nil { + return nil, nil + } + return listHostsReply(buf), nil +} - buf[b] = 65 // request opcode - b += 1 +// listHostsReply reads a byte slice into a ListHostsReply value. +func listHostsReply(buf []byte) *ListHostsReply { + v := new(ListHostsReply) + b := 1 // skip reply determinant - buf[b] = CoordinateMode + v.Mode = 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(Drawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + v.HostsLen = xgb.Get16(buf[b:]) + b += 2 - b += PointListBytes(buf[b:], Points) + b += 22 // padding + + v.Hosts = make([]Host, v.HostsLen) + b += HostReadList(buf[b:], v.Hosts) + + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = 110 // 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 } -// PolySegmentCookie is a cookie used only for PolySegment requests. -type PolySegmentCookie struct { +// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. +type ListInstalledColormapsCookie struct { *xgb.Cookie } -// PolySegment 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) - return PolySegmentCookie{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} } -// 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(polySegmentRequest(c, Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} +// ListInstalledColormapsUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{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 { - return cook.Cookie.Check() +// 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)) } -// 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] = 66 // request opcode - b += 1 +// 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 +} + +// 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += SegmentListBytes(buf[b:], Segments) - - return buf -} - -// PolyRectangleCookie is a cookie used only for PolyRectangle requests. -type PolyRectangleCookie struct { - *xgb.Cookie -} + v.CmapsLen = xgb.Get16(buf[b:]) + b += 2 -// PolyRectangle 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} + b += 22 // padding -// 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} -} + 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) -// Check returns an error if one occurred 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() + return v } -// 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 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] = 67 // request opcode + buf[b] = 83 // request opcode b += 1 b += 1 // padding @@ -11082,105 +11563,91 @@ 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)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - b += RectangleListBytes(buf[b:], Rectangles) - return buf } -// PolyArcCookie is a cookie used only for PolyArc requests. -type PolyArcCookie struct { +// ListPropertiesCookie is a cookie used only for ListProperties requests. +type ListPropertiesCookie struct { *xgb.Cookie } -// PolyArc sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyArcCookie{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} } -// PolyArcChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyArcCookie.Check() -func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} +// ListPropertiesUnchecked 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} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyArcCookie) Check() error { - return cook.Cookie.Check() +// 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)) } -// Write request to wire for PolyArc -// polyArcRequest writes a PolyArc request to a byte slice. -func polyArcRequest(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) +// 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 +} - buf[b] = 68 // 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 + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// FillPolyCookie is a cookie used only for FillPoly requests. -type FillPolyCookie struct { - *xgb.Cookie -} + v.AtomsLen = xgb.Get16(buf[b:]) + b += 2 -// FillPoly 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} -} + b += 22 // padding -// 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} -} + 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 FillPolyCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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] = 69 // request opcode + buf[b] = 21 // request opcode b += 1 b += 1 // padding @@ -11188,113 +11655,100 @@ func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, Co 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 - buf[b] = Shape - b += 1 - - buf[b] = CoordinateMode - b += 1 - - b += 2 // padding - - b += PointListBytes(buf[b:], Points) - return buf } -// PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests. -type PolyFillRectangleCookie struct { +// LookupColorCookie is a cookie used only for LookupColor requests. +type LookupColorCookie struct { *xgb.Cookie } -// PolyFillRectangle sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{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} } -// PolyFillRectangleChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyFillRectangleCookie.Check() -func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} +// LookupColorUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{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 PolyFillRectangleCookie) Check() error { - return cook.Cookie.Check() +// 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 } -// Write request to wire for PolyFillRectangle -// polyFillRectangleRequest writes a PolyFillRectangle request to a byte slice. -func polyFillRectangleRequest(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) +// 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 +} - buf[b] = 70 // 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(Drawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + v.ExactRed = xgb.Get16(buf[b:]) + b += 2 - b += RectangleListBytes(buf[b:], Rectangles) + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 -// PolyFillArcCookie is a cookie used only for PolyFillArc requests. -type PolyFillArcCookie struct { - *xgb.Cookie -} + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 -// PolyFillArc 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 -// 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(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} + v.VisualBlue = 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 PolyFillArcCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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] = 71 // request opcode + buf[b] = 92 // request opcode b += 1 b += 1 // padding @@ -11302,293 +11756,195 @@ func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) 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(Cmap)) b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + xgb.Put16(buf[b:], NameLen) + b += 2 - b += ArcListBytes(buf[b:], Arcs) + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. +type MapSubwindowsCookie struct { *xgb.Cookie } -// PutImage 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 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 MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { 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(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{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 { +// 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(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{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 PutImageCookie) Check() error { +func (cook MapSubwindowsCookie) 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 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] = 72 // request opcode + buf[b] = 9 // 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 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) 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))) - return buf } -// GetImageCookie is a cookie used only for GetImage requests. -type GetImageCookie struct { +// MapWindowCookie is a cookie used only for MapWindow requests. +type MapWindowCookie 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. +// MapWindow 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 MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{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 +// 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(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{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 MapWindowCookie) 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 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] = 73 // request opcode + buf[b] = 8 // 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 - 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(Window)) b += 4 return buf } -// PolyText8Cookie is a cookie used only for PolyText8 requests. -type PolyText8Cookie struct { +// NoOperationCookie is a cookie used only for NoOperation requests. +type NoOperationCookie struct { *xgb.Cookie } -// PolyText8 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 PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { +func NoOperation(c *xgb.Conn) NoOperationCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{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 { +// 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(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{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 PolyText8Cookie) Check() error { +func (cook NoOperationCookie) 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 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] = 74 // 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 - - 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))) - return buf } -// PolyText16Cookie is a cookie used only for PolyText16 requests. -type PolyText16Cookie struct { +// OpenFontCookie is a cookie used only for OpenFont requests. +type OpenFontCookie struct { *xgb.Cookie } -// PolyText16 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 PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { +func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} } -// PolyText16Checked sends a checked request. -// If an error occurs, it can be retrieved using PolyText16Cookie.Check() -func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { +// 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(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{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 PolyText16Cookie) Check() error { +func (cook OpenFontCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyText16 -// polyText16Request writes a PolyText16 request to a byte slice. -func polyText16Request(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 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] = 75 // request opcode + buf[b] = 45 // request opcode b += 1 b += 1 // padding @@ -11596,63 +11952,58 @@ func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y i 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(Fid)) b += 4 - xgb.Put16(buf[b:], uint16(X)) + xgb.Put16(buf[b:], NameLen) b += 2 - xgb.Put16(buf[b:], uint16(Y)) - b += 2 + b += 2 // padding - copy(buf[b:], Items[:len(Items)]) - b += xgb.Pad(int(len(Items))) + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// ImageText8Cookie is a cookie used only for ImageText8 requests. -type ImageText8Cookie struct { +// PolyArcCookie is a cookie used only for PolyArc requests. +type PolyArcCookie struct { *xgb.Cookie } -// ImageText8 sends an unchecked request. +// PolyArc 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 PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { cookie := c.NewCookie(false, false) - c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{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 { +// PolyArcChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyArcCookie.Check() +func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { cookie := c.NewCookie(true, false) - c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{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 PolyArcCookie) 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 PolyArc +// polyArcRequest writes a PolyArc request to a byte slice. +func polyArcRequest(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] = 76 // request opcode + buf[b] = 68 // 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 @@ -11663,57 +12014,49 @@ func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gconte 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)) + b += ArcListBytes(buf[b:], Arcs) return buf } -// ImageText16Cookie is a cookie used only for ImageText16 requests. -type ImageText16Cookie struct { +// PolyFillArcCookie is a cookie used only for PolyFillArc requests. +type PolyFillArcCookie struct { *xgb.Cookie } -// ImageText16 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 ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { +func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { cookie := c.NewCookie(false, false) - c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{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 { +// 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(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{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 ImageText16Cookie) Check() error { +func (cook PolyFillArcCookie) 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 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] = 77 // request opcode + buf[b] = 71 // 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 @@ -11724,206 +12067,207 @@ 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)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - b += Char2bListBytes(buf[b:], String) + b += ArcListBytes(buf[b:], Arcs) return buf } -// CreateColormapCookie is a cookie used only for CreateColormap requests. -type CreateColormapCookie struct { +// PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests. +type PolyFillRectangleCookie struct { *xgb.Cookie } -// CreateColormap sends an unchecked request. +// PolyFillRectangle 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 { +func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { cookie := c.NewCookie(false, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{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 { +// PolyFillRectangleChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyFillRectangleCookie.Check() +func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { cookie := c.NewCookie(true, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{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 { +func (cook PolyFillRectangleCookie) 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 +// Write request to wire for PolyFillRectangle +// polyFillRectangleRequest writes a PolyFillRectangle request to a byte slice. +func polyFillRectangleRequest(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] = 78 // request opcode + buf[b] = 70 // request opcode b += 1 - buf[b] = Alloc - 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(Mid)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put32(buf[b:], uint32(Visual)) - b += 4 + b += RectangleListBytes(buf[b:], Rectangles) return buf } -// FreeColormapCookie is a cookie used only for FreeColormap requests. -type FreeColormapCookie struct { +// PolyLineCookie is a cookie used only for PolyLine requests. +type PolyLineCookie struct { *xgb.Cookie } -// FreeColormap 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 FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { +func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { cookie := c.NewCookie(false, false) - c.NewRequest(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{cookie} + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{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 { +// 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(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{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 FreeColormapCookie) Check() error { +func (cook PolyLineCookie) 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 +// 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] = 79 // 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 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += PointListBytes(buf[b:], Points) + return buf } -// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. -type CopyColormapAndFreeCookie struct { +// PolyPointCookie is a cookie used only for PolyPoint requests. +type PolyPointCookie struct { *xgb.Cookie } -// CopyColormapAndFree 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 CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { +func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { cookie := c.NewCookie(false, false) - c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{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 { +// 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(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{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 CopyColormapAndFreeCookie) Check() error { +func (cook PolyPointCookie) 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 +// 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] = 80 // request opcode + buf[b] = 64 // 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 - xgb.Put32(buf[b:], uint32(Mid)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(SrcCmap)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += PointListBytes(buf[b:], Points) + return buf } -// InstallColormapCookie is a cookie used only for InstallColormap requests. -type InstallColormapCookie struct { +// PolyRectangleCookie is a cookie used only for PolyRectangle requests. +type PolyRectangleCookie struct { *xgb.Cookie } -// InstallColormap 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 InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { +func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { cookie := c.NewCookie(false, false) - c.NewRequest(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{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 { +// 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(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{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 { +func (cook PolyRectangleCookie) 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 +// 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] = 81 // request opcode + buf[b] = 67 // request opcode b += 1 b += 1 // padding @@ -11931,47 +12275,52 @@ func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { 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 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += RectangleListBytes(buf[b:], Rectangles) + return buf } -// UninstallColormapCookie is a cookie used only for UninstallColormap requests. -type UninstallColormapCookie struct { +// PolySegmentCookie is a cookie used only for PolySegment requests. +type PolySegmentCookie struct { *xgb.Cookie } -// UninstallColormap 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 UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { +func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { cookie := c.NewCookie(false, false) - c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{cookie} + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{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 { +// 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(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{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 UninstallColormapCookie) Check() error { +func (cook PolySegmentCookie) 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 +// 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] = 82 // request opcode + buf[b] = 66 // request opcode b += 1 b += 1 // padding @@ -11979,91 +12328,52 @@ func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { 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 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += SegmentListBytes(buf[b:], Segments) + return buf } -// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. -type ListInstalledColormapsCookie struct { +// PolyText16Cookie is a cookie used only for PolyText16 requests. +type PolyText16Cookie 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} -} - -// ListInstalledColormapsUnchecked sends an unchecked request. +// PolyText16 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 { - cookie := c.NewCookie(false, true) - c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) - return ListInstalledColormapsCookie{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)) +func PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} } -// 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 +// PolyText16Checked sends a checked request. +// If an error occurs, it can be retrieved using PolyText16Cookie.Check() +func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} } -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.CmapsLen = 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) - - 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 PolyText16Cookie) Check() error { + return cook.Cookie.Check() } -// 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 PolyText16 +// polyText16Request writes a PolyText16 request to a byte slice. +func polyText16Request(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] = 83 // request opcode + buf[b] = 75 // request opcode b += 1 b += 1 // padding @@ -12071,156 +12381,191 @@ 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(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:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) + return buf } -// AllocColorCookie is a cookie used only for AllocColor requests. -type AllocColorCookie struct { +// PolyText8Cookie is a cookie used only for PolyText8 requests. +type PolyText8Cookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} -} - -// AllocColorUnchecked 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 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} +func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} } -// 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 +// 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(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} } -// 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 +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// allocColorReply reads a byte slice into a AllocColorReply value. -func allocColorReply(buf []byte) *AllocColorReply { - v := new(AllocColorReply) - b := 1 // skip reply determinant +// 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] = 74 // 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.Red = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - v.Green = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(X)) b += 2 - v.Blue = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(Y)) b += 2 - b += 2 // padding + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) - v.Pixel = xgb.Get32(buf[b:]) - b += 4 + return buf +} - return v +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { + *xgb.Cookie } -// 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 +// PutImage 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{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 { + cookie := c.NewCookie(true, false) + 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 PutImageCookie) 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)))) b := 0 buf := make([]byte, size) - buf[b] = 84 // request opcode + buf[b] = 72 // 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(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], Red) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], Width) b += 2 - xgb.Put16(buf[b:], Green) + xgb.Put16(buf[b:], Height) b += 2 - xgb.Put16(buf[b:], Blue) + 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))) + return buf } -// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. -type AllocNamedColorCookie struct { +// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. +type QueryBestSizeCookie 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 { +// 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(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} } -// AllocNamedColorUnchecked 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 AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { +func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} } -// AllocNamedColorReply represents the data returned from a AllocNamedColor request. -type AllocNamedColorReply struct { +// 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 - Pixel uint32 - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 + Width uint16 + Height uint16 } -// 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 QueryBestSize request. +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12228,12 +12573,12 @@ func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { if buf == nil { return nil, nil } - return allocNamedColorReply(buf), nil + return queryBestSizeReply(buf), nil } -// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. -func allocNamedColorReply(buf []byte) *AllocNamedColorReply { - v := new(AllocNamedColorReply) +// 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 @@ -12244,94 +12589,76 @@ 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.ExactRed = xgb.Get16(buf[b:]) - b += 2 - - v.ExactGreen = xgb.Get16(buf[b:]) - b += 2 - - v.ExactBlue = xgb.Get16(buf[b:]) - b += 2 - - v.VisualRed = xgb.Get16(buf[b:]) - b += 2 - - v.VisualGreen = xgb.Get16(buf[b:]) + v.Width = xgb.Get16(buf[b:]) b += 2 - v.VisualBlue = xgb.Get16(buf[b:]) + v.Height = xgb.Get16(buf[b:]) b += 2 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 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] = 85 // 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 - xgb.Put16(buf[b:], NameLen) + xgb.Put16(buf[b:], Width) b += 2 - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + xgb.Put16(buf[b:], Height) + b += 2 return buf } -// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. -type AllocColorCellsCookie struct { +// QueryColorsCookie is a cookie used only for QueryColors requests. +type QueryColorsCookie 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 { +// 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(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} } -// AllocColorCellsUnchecked 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 AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { +func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} } -// AllocColorCellsReply represents the data returned from a AllocColorCells request. -type AllocColorCellsReply 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 - PixelsLen uint16 - MasksLen uint16 - // padding: 20 bytes - Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) - Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) + ColorsLen uint16 + // padding: 22 bytes + Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) } -// 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 QueryColors request. +func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12339,12 +12666,12 @@ func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { if buf == nil { return nil, nil } - return allocColorCellsReply(buf), nil + return queryColorsReply(buf), nil } -// allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. -func allocColorCellsReply(buf []byte) *AllocColorCellsReply { - v := new(AllocColorCellsReply) +// 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 @@ -12355,47 +12682,28 @@ 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:]) + v.ColorsLen = 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) + b += 22 // padding - 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.Colors = make([]Rgb, v.ColorsLen) + b += RgbReadList(buf[b:], v.Colors) 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 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] = 86 // request opcode + buf[b] = 91 // request opcode b += 1 - if Contiguous { - 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 @@ -12403,52 +12711,49 @@ func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors xgb.Put32(buf[b:], uint32(Cmap)) b += 4 - xgb.Put16(buf[b:], Colors) - b += 2 - - xgb.Put16(buf[b:], Planes) - b += 2 + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. -type AllocColorPlanesCookie struct { +// QueryExtensionCookie is a cookie used only for QueryExtension requests. +type QueryExtensionCookie 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 { +// 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(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} } -// AllocColorPlanesUnchecked 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 AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { +func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} } -// AllocColorPlanesReply represents the data returned from a AllocColorPlanes request. -type AllocColorPlanesReply 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 - PixelsLen uint16 - // padding: 2 bytes - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 8 bytes - Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) + Present bool + MajorOpcode byte + FirstEvent byte + FirstError byte } -// 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 QueryExtension request. +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12456,12 +12761,12 @@ func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { if buf == nil { return nil, nil } - return allocColorPlanesReply(buf), nil + return queryExtensionReply(buf), nil } -// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. -func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { - v := new(AllocColorPlanesReply) +// 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 @@ -12472,270 +12777,229 @@ 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 + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 - v.BlueMask = xgb.Get32(buf[b:]) - b += 4 + v.MajorOpcode = buf[b] + b += 1 - b += 8 // padding + v.FirstEvent = buf[b] + b += 1 - 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.FirstError = buf[b] + b += 1 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 +// 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] = 87 // request opcode + buf[b] = 98 // request opcode b += 1 - if Contiguous { - 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(Cmap)) - b += 4 - - xgb.Put16(buf[b:], Colors) - b += 2 - - xgb.Put16(buf[b:], Reds) + xgb.Put16(buf[b:], NameLen) b += 2 - xgb.Put16(buf[b:], Greens) - b += 2 + b += 2 // padding - xgb.Put16(buf[b:], Blues) - b += 2 + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// FreeColorsCookie is a cookie used only for FreeColors requests. -type FreeColorsCookie struct { +// QueryFontCookie is a cookie used only for QueryFont requests. +type QueryFontCookie 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} +// 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(queryFontRequest(c, Font), cookie) + return QueryFontCookie{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} +// QueryFontUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{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() +// 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 + 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)) } -// 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) +// 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 + } + if buf == nil { + return nil, nil + } + return queryFontReply(buf), nil +} - buf[b] = 88 // request opcode - b += 1 +// 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 - 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(Cmap)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], PlaneMask) - 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 - for i := 0; i < int(len(Pixels)); i++ { - xgb.Put32(buf[b:], Pixels[i]) - b += 4 - } - b = xgb.Pad(b) + v.MinCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 -// StoreColorsCookie is a cookie used only for StoreColors requests. -type StoreColorsCookie struct { - *xgb.Cookie -} + v.DefaultChar = xgb.Get16(buf[b:]) + b += 2 -// 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} -} + v.PropertiesLen = xgb.Get16(buf[b:]) + b += 2 -// 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} -} + v.DrawDirection = buf[b] + 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 StoreColorsCookie) Check() error { - return cook.Cookie.Check() -} + v.MinByte1 = buf[b] + b += 1 -// 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) + v.MaxByte1 = buf[b] + b += 1 - buf[b] = 89 // request opcode + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } b += 1 - b += 1 // padding + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.FontDescent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + v.CharInfosLen = xgb.Get32(buf[b:]) 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} -} + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) -// 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} -} + v.CharInfos = make([]Charinfo, v.CharInfosLen) + b += CharinfoReadList(buf[b:], v.CharInfos) -// Check returns an error if one occurred 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() + return v } -// 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)))) +// 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] = 90 // request opcode + buf[b] = 47 // request opcode b += 1 - buf[b] = Flags - 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.Put32(buf[b:], Pixel) + 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 } -// QueryColorsCookie is a cookie used only for QueryColors requests. -type QueryColorsCookie struct { +// QueryKeymapCookie is a cookie used only for QueryKeymap requests. +type QueryKeymapCookie 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 { +// 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(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} } -// QueryColorsUnchecked 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 QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { +func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} } -// QueryColorsReply represents the data returned from a QueryColors request. -type QueryColorsReply 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 - ColorsLen uint16 - // padding: 22 bytes - Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) + Keys []byte // size: 32 } -// 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 QueryKeymap request. +func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12743,12 +13007,12 @@ func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { if buf == nil { return nil, nil } - return queryColorsReply(buf), nil + return queryKeymapReply(buf), nil } -// queryColorsReply reads a byte slice into a QueryColorsReply value. -func queryColorsReply(buf []byte) *QueryColorsReply { - v := new(QueryColorsReply) +// 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 @@ -12759,80 +13023,68 @@ func queryColorsReply(buf []byte) *QueryColorsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ColorsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Colors = make([]Rgb, v.ColorsLen) - b += RgbReadList(buf[b:], v.Colors) + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) 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 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] = 91 // request opcode + buf[b] = 44 // 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 - - for i := 0; i < int(len(Pixels)); i++ { - xgb.Put32(buf[b:], Pixels[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// LookupColorCookie is a cookie used only for LookupColor requests. -type LookupColorCookie struct { +// QueryPointerCookie is a cookie used only for QueryPointer requests. +type QueryPointerCookie 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 { +// 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(lookupColorRequest(c, Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} } -// LookupColorUnchecked 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 LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { +func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { cookie := c.NewCookie(false, true) - c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{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 +// 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 } -// 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 QueryPointer request. +func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12840,15 +13092,20 @@ func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { if buf == nil { return nil, nil } - return lookupColorReply(buf), nil + return queryPointerReply(buf), nil } -// lookupColorReply reads a byte slice into a LookupColorReply value. -func lookupColorReply(buf []byte) *LookupColorReply { - v := new(LookupColorReply) +// 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 @@ -12856,35 +13113,40 @@ 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.Root = Window(xgb.Get32(buf[b:])) + b += 4 - v.ExactGreen = xgb.Get16(buf[b:]) + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - v.ExactBlue = xgb.Get16(buf[b:]) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.VisualRed = xgb.Get16(buf[b:]) + v.WinX = int16(xgb.Get16(buf[b:])) b += 2 - v.VisualGreen = xgb.Get16(buf[b:]) + v.WinY = int16(xgb.Get16(buf[b:])) b += 2 - v.VisualBlue = xgb.Get16(buf[b:]) + v.Mask = xgb.Get16(buf[b:]) b += 2 + b += 2 // padding + 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 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] = 92 // request opcode + buf[b] = 38 // request opcode b += 1 b += 1 // padding @@ -12892,211 +13154,210 @@ 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 { +// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. +type QueryTextExtentsCookie struct { *xgb.Cookie } -// CreateCursor sends an unchecked request. +// 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(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} +} + +// QueryTextExtentsUnchecked 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} +func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{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 } -// Check returns an error if one occurred 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() +// 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 + } + if buf == nil { + return nil, nil + } + return queryTextExtentsReply(buf), nil } -// 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) +// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. +func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { + v := new(QueryTextExtentsReply) + b := 1 // skip reply determinant - buf[b] = 93 // request opcode + v.DrawDirection = buf[b] 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(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mask)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units 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) + v.FontAscent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], BackBlue) + v.FontDescent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], X) + v.OverallAscent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], Y) + v.OverallDescent = int16(xgb.Get16(buf[b:])) b += 2 - return buf -} - -// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. -type CreateGlyphCursorCookie struct { - *xgb.Cookie -} + v.OverallWidth = int32(xgb.Get32(buf[b:])) + b += 4 -// CreateGlyphCursor 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} -} + v.OverallLeft = int32(xgb.Get32(buf[b:])) + b += 4 -// 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} -} + v.OverallRight = int32(xgb.Get32(buf[b:])) + b += 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 CreateGlyphCursorCookie) Check() error { - return cook.Cookie.Check() + return v } -// 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 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] = 94 // 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(Cid)) + xgb.Put32(buf[b:], uint32(Font)) b += 4 - xgb.Put32(buf[b:], uint32(SourceFont)) - b += 4 + b += Char2bListBytes(buf[b:], String) - xgb.Put32(buf[b:], uint32(MaskFont)) - b += 4 + // skip writing local field: StringLen (2) :: uint16 - xgb.Put16(buf[b:], SourceChar) - b += 2 + return buf +} - xgb.Put16(buf[b:], MaskChar) - b += 2 +// QueryTreeCookie is a cookie used only for QueryTree requests. +type QueryTreeCookie struct { + *xgb.Cookie +} - xgb.Put16(buf[b:], ForeRed) - b += 2 +// 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} +} - xgb.Put16(buf[b:], ForeGreen) - b += 2 +// QueryTreeUnchecked 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} +} + +// 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)) +} + +// 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 +} + +// queryTreeReply reads a byte slice into a QueryTreeReply value. +func queryTreeReply(buf []byte) *QueryTreeReply { + v := new(QueryTreeReply) + b := 1 // skip reply determinant - xgb.Put16(buf[b:], ForeBlue) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], BackRed) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], BackGreen) - b += 2 + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - xgb.Put16(buf[b:], BackBlue) - b += 2 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - return buf -} + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 -// FreeCursorCookie is a cookie used only for FreeCursor requests. -type FreeCursorCookie struct { - *xgb.Cookie -} + v.ChildrenLen = xgb.Get16(buf[b:]) + b += 2 -// 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} -} + b += 14 // padding -// 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} -} + 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) -// Check returns an error if one occurred 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() + return v } -// Write request to wire for FreeCursor -// freeCursorRequest writes a FreeCursor request to a byte slice. -func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { +// 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] = 95 // request opcode + buf[b] = 15 // request opcode b += 1 b += 1 // padding @@ -13104,7 +13365,7 @@ 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 return buf @@ -13176,468 +13437,366 @@ func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen return buf } -// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. -type QueryBestSizeCookie struct { +// ReparentWindowCookie is a cookie used only for ReparentWindow requests. +type ReparentWindowCookie 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. +// ReparentWindow 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 ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{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 +// 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(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{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 ReparentWindowCookie) 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 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] = 97 // request opcode + buf[b] = 7 // request opcode b += 1 - buf[b] = Class - 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)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Width) + xgb.Put32(buf[b:], uint32(Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) b += 2 - xgb.Put16(buf[b:], Height) + xgb.Put16(buf[b:], uint16(Y)) b += 2 return buf } -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { +// RotatePropertiesCookie is a cookie used only for RotateProperties requests. +type RotatePropertiesCookie 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. +// RotateProperties 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} +func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{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 +// 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(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{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 +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// queryExtensionReply reads a byte slice into a QueryExtensionReply value. -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) - b := 1 // skip reply determinant +// 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] = 114 // 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(Window)) b += 4 - if buf[b] == 1 { - v.Present = true - } else { - v.Present = false + 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 += 1 + b = xgb.Pad(b) - v.MajorOpcode = buf[b] - b += 1 + return buf +} - v.FirstEvent = buf[b] - b += 1 +// SendEventCookie is a cookie used only for SendEvent requests. +type SendEventCookie struct { + *xgb.Cookie +} - v.FirstError = buf[b] - b += 1 +// SendEvent 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{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 SendEventCookie) 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 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] = 98 // 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.Put16(buf[b:], NameLen) - b += 2 + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 - b += 2 // padding + xgb.Put32(buf[b:], EventMask) + b += 4 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + copy(buf[b:], Event[:32]) + b += xgb.Pad(int(32)) return buf } -// ListExtensionsCookie is a cookie used only for ListExtensions requests. -type ListExtensionsCookie struct { +// SetAccessControlCookie is a cookie used only for SetAccessControl requests. +type SetAccessControlCookie 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. +// SetAccessControl 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 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 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 +// 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} } -// 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 SetAccessControlCookie) 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 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] = 99 // request opcode + buf[b] = 111 // 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 { +// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. +type SetClipRectanglesCookie struct { *xgb.Cookie } -// ChangeKeyboardMapping 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 ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { +func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{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 { +// 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(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} + 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 ChangeKeyboardMappingCookie) Check() error { +func (cook SetClipRectanglesCookie) 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 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] = 100 // request opcode + buf[b] = 59 // request opcode b += 1 - buf[b] = KeycodeCount + buf[b] = Ordering b += 1 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:], uint16(ClipXOrigin)) + b += 2 - b += 2 // padding + xgb.Put16(buf[b:], uint16(ClipYOrigin)) + 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) + b += RectangleListBytes(buf[b:], Rectangles) return buf } -// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. -type GetKeyboardMappingCookie struct { +// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. +type SetCloseDownModeCookie 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. +// SetCloseDownMode 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 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 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 +// 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} } -// 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 SetCloseDownModeCookie) 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 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] = 101 // request opcode + buf[b] = 112 // 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 - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = Count - b += 1 - return buf } -// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. -type ChangeKeyboardControlCookie struct { +// SetDashesCookie is a cookie used only for SetDashes requests. +type SetDashesCookie struct { *xgb.Cookie } -// ChangeKeyboardControl 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 ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { +func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{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 { +// 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(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{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 ChangeKeyboardControlCookie) Check() error { +func (cook SetDashesCookie) 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 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] = 102 // request opcode + buf[b] = 58 // request opcode b += 1 b += 1 // padding @@ -13645,267 +13804,237 @@ func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uin 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(Gc)) 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:], DashOffset) + b += 2 + + xgb.Put16(buf[b:], DashesLen) + b += 2 + + copy(buf[b:], Dashes[:DashesLen]) + b += xgb.Pad(int(DashesLen)) return buf } -// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. -type GetKeyboardControlCookie struct { +// SetFontPathCookie is a cookie used only for SetFontPath requests. +type SetFontPathCookie 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. +// SetFontPath 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} +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} } -// 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 +// 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} } -// 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 +// Check returns an error if one occurred 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() } -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.LedMask = xgb.Get32(buf[b:]) - b += 4 +// 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) - v.KeyClickPercent = buf[b] + buf[b] = 51 // request opcode b += 1 - v.BellPercent = buf[b] - b += 1 + b += 1 // padding - v.BellPitch = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.BellDuration = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], FontQty) 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 + b += StrListBytes(buf[b:], Font) return buf } -// BellCookie is a cookie used only for Bell requests. -type BellCookie struct { +// SetInputFocusCookie is a cookie used only for SetInputFocus requests. +type SetInputFocusCookie struct { *xgb.Cookie } -// Bell 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 Bell(c *xgb.Conn, Percent int8) BellCookie { +func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { cookie := c.NewCookie(false, false) - c.NewRequest(bellRequest(c, Percent), cookie) - return BellCookie{cookie} + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{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 { +// 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(bellRequest(c, Percent), cookie) - return BellCookie{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 BellCookie) Check() error { +func (cook SetInputFocusCookie) 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 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] = 104 // request opcode + buf[b] = 42 // request opcode b += 1 - buf[b] = byte(Percent) + 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:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + return buf } -// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. -type ChangePointerControlCookie struct { +// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. +type SetModifierMappingCookie struct { *xgb.Cookie } -// ChangePointerControl sends an unchecked request. +// 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. // 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} +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} } -// 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} +// 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 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 } -// Check returns an error if one occurred 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() +// 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 } -// 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 +// 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] = 105 // request opcode + buf[b] = 118 // request opcode b += 1 - b += 1 // padding + buf[b] = KeycodesPerModifier + b += 1 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,209 +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 - return buf -} - -// SetAccessControlCookie is a cookie used only for SetAccessControl requests. -type SetAccessControlCookie struct { - *xgb.Cookie -} - -// SetAccessControl 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(setAccessControlRequest(c, Mode), cookie) - return SetAccessControlCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(setAccessControlRequest(c, Mode), cookie) - return SetAccessControlCookie{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 { - 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 - b := 0 - buf := make([]byte, size) + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 - buf[b] = 111 // request opcode - b += 1 + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 - buf[b] = Mode - b += 1 + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 return buf } -// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. -type SetCloseDownModeCookie struct { +// UngrabButtonCookie is a cookie used only for UngrabButton requests. +type UngrabButtonCookie struct { *xgb.Cookie } -// SetCloseDownMode 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 SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { +func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{cookie} + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{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 { +// 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(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{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 SetCloseDownModeCookie) Check() error { +func (cook UngrabButtonCookie) 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 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] = 112 // 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 } -// KillClientCookie is a cookie used only for KillClient requests. -type KillClientCookie struct { +// UngrabKeyCookie is a cookie used only for UngrabKey requests. +type UngrabKeyCookie struct { *xgb.Cookie } -// KillClient 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 KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { +func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(false, false) - c.NewRequest(killClientRequest(c, Resource), cookie) - return KillClientCookie{cookie} + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{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 { +// 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(killClientRequest(c, Resource), cookie) - return KillClientCookie{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 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 +func (cook UngrabKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// 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] = 113 // request opcode + buf[b] = 34 // request opcode b += 1 - b += 1 // padding + 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:], Resource) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + return buf } -// RotatePropertiesCookie is a cookie used only for RotateProperties requests. -type RotatePropertiesCookie struct { +// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. +type UngrabKeyboardCookie struct { *xgb.Cookie } -// RotateProperties 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 RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { +func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(false, false) - c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{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 { +// 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(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{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 RotatePropertiesCookie) Check() error { +func (cook UngrabKeyboardCookie) 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 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] = 114 // request opcode + buf[b] = 32 // request opcode b += 1 b += 1 // padding @@ -14433,438 +14558,313 @@ 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 { +// UngrabPointerCookie is a cookie used only for UngrabPointer requests. +type UngrabPointerCookie struct { *xgb.Cookie } -// ForceScreenSaver 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 ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { +func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{cookie} + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{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 { +// 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(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{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 ForceScreenSaverCookie) Check() error { +func (cook UngrabPointerCookie) 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 +// 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] = 115 // request opcode + buf[b] = 27 // 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 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + return buf } -// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. -type SetPointerMappingCookie struct { +// UngrabServerCookie is a cookie used only for UngrabServer requests. +type UngrabServerCookie 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. +// UngrabServer 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 UngrabServer(c *xgb.Conn) UngrabServerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{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 +// 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} } -// 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 UngrabServerCookie) 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 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] = 116 // request opcode - b += 1 - - buf[b] = MapLen + 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 - copy(buf[b:], Map[:MapLen]) - b += xgb.Pad(int(MapLen)) - return buf } -// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. -type GetPointerMappingCookie struct { +// UninstallColormapCookie is a cookie used only for UninstallColormap requests. +type UninstallColormapCookie 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. +// UninstallColormap 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 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 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 +// 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} } -// 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 UninstallColormapCookie) 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 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] = 117 // request opcode + buf[b] = 82 // 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 + return buf } -// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. -type SetModifierMappingCookie struct { +// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. +type UnmapSubwindowsCookie 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. +// UnmapSubwindows 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 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 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 +// 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} } -// 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 UnmapSubwindowsCookie) 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 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] = 118 // request opcode + buf[b] = 11 // 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 { +// UnmapWindowCookie is a cookie used only for UnmapWindow requests. +type UnmapWindowCookie 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. +// UnmapWindow 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 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 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 +// 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} } -// 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 UnmapWindowCookie) 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 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] = 119 // request opcode + buf[b] = 10 // 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 } -// NoOperationCookie is a cookie used only for NoOperation requests. -type NoOperationCookie struct { +// WarpPointerCookie is a cookie used only for WarpPointer requests. +type WarpPointerCookie struct { *xgb.Cookie } -// NoOperation 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 NoOperation(c *xgb.Conn) NoOperationCookie { +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(noOperationRequest(c), cookie) - return NoOperationCookie{cookie} + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} } -// NoOperationChecked sends a checked request. -// If an error occurs, it can be retrieved using NoOperationCookie.Check() -func NoOperationChecked(c *xgb.Conn) NoOperationCookie { +// 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(noOperationRequest(c), cookie) - return NoOperationCookie{cookie} + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{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 NoOperationCookie) Check() error { +func (cook WarpPointerCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for NoOperation -// noOperationRequest writes a NoOperation request to a byte slice. -func noOperationRequest(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] = 127 // 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 + 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 + + 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 + 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,44 +132,69 @@ func ListItemListSize(list []ListItem) int { return size } -// 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' + +// GetClientContextCookie is a cookie used only for GetClientContext requests. +type GetClientContextCookie 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 { +// 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 'QueryVersion' 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(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} } -// QueryVersionUnchecked 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 QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { +func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'QueryVersion' 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(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply 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 - ServerMajor uint16 - ServerMinor uint16 + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 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 GetClientContext request. +func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -201,12 +202,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return getClientContextReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// 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 @@ -217,18 +218,24 @@ 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 - v.ServerMinor = xgb.Get16(buf[b:]) - b += 2 + 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 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 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) @@ -236,76 +243,114 @@ func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 0 // 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] = ClientMajor - b += 1 - - buf[b] = ClientMinor - b += 1 + xgb.Put32(buf[b:], Resource) + b += 4 return buf } -// SetDeviceCreateContextCookie is a cookie used only for SetDeviceCreateContext requests. -type SetDeviceCreateContextCookie struct { +// GetDeviceContextCookie is a cookie used only for GetDeviceContext requests. +type GetDeviceContextCookie 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 { +// GetDeviceContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceContextCookie.Reply() +func GetDeviceContext(c *xgb.Conn, Device uint32) GetDeviceContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceContext' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{cookie} } -// 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 { +// GetDeviceContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceContextUnchecked(c *xgb.Conn, Device uint32) GetDeviceContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceContext' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{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 SetDeviceCreateContextCookie) Check() error { - return cook.Cookie.Check() +// GetDeviceContextReply represents the data returned from a GetDeviceContext request. +type GetDeviceContextReply 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 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)))) +// Reply blocks and returns the reply data for a GetDeviceContext request. +func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceContextReply(buf), nil +} + +// getDeviceContextReply reads a byte slice into a GetDeviceContextReply value. +func getDeviceContextReply(buf []byte) *GetDeviceContextReply { + v := new(GetDeviceContextReply) + 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 GetDeviceContext +// getDeviceContextRequest writes a GetDeviceContext request to a byte slice. +func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 1 // 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:], ContextLen) + xgb.Put32(buf[b:], Device) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } @@ -405,96 +450,35 @@ func getDeviceCreateContextRequest(c *xgb.Conn) []byte { return buf } -// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. -type SetDeviceContextCookie struct { +// GetPropertyContextCookie is a cookie used only for GetPropertyContext requests. +type GetPropertyContextCookie 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 { +// 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 'SetDeviceContext' 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, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{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 { +// GetPropertyContextUnchecked 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 { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceContext' 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, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{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 - - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetDeviceContextCookie is a cookie used only for GetDeviceContext requests. -type GetDeviceContextCookie struct { - *xgb.Cookie -} - -// GetDeviceContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceContextCookie.Reply() -func GetDeviceContext(c *xgb.Conn, Device uint32) GetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceContextRequest(c, Device), cookie) - return GetDeviceContextCookie{cookie} -} - -// GetDeviceContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceContextUnchecked(c *xgb.Conn, Device uint32) GetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceContextRequest(c, Device), cookie) - return GetDeviceContextCookie{cookie} -} - -// GetDeviceContextReply represents the data returned from a GetDeviceContext request. -type GetDeviceContextReply 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 @@ -503,8 +487,8 @@ type GetDeviceContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceContext request. -func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, 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 @@ -512,12 +496,12 @@ func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { if buf == nil { return nil, nil } - return getDeviceContextReply(buf), nil + return getPropertyContextReply(buf), nil } -// getDeviceContextReply reads a byte slice into a GetDeviceContextReply value. -func getDeviceContextReply(buf []byte) *GetDeviceContextReply { - v := new(GetDeviceContextReply) +// 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 @@ -543,115 +527,60 @@ func getDeviceContextReply(buf []byte) *GetDeviceContextReply { return v } -// Write request to wire for GetDeviceContext -// getDeviceContextRequest writes a GetDeviceContext request to a byte slice. -func getDeviceContextRequest(c *xgb.Conn, Device uint32) []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] = 4 // 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:], Device) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - 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) + xgb.Put32(buf[b:], uint32(Property)) 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 { +// GetPropertyCreateContextCookie is a cookie used only for GetPropertyCreateContext requests. +type GetPropertyCreateContextCookie 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 { +// GetPropertyCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyCreateContextCookie.Reply() +func GetPropertyCreateContext(c *xgb.Conn) GetPropertyCreateContextCookie { 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 'GetPropertyCreateContext' 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(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} } -// GetWindowCreateContextUnchecked sends an unchecked request. +// GetPropertyCreateContextUnchecked 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 GetPropertyCreateContextUnchecked(c *xgb.Conn) GetPropertyCreateContextCookie { 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 'GetPropertyCreateContext' 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(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} } -// GetWindowCreateContextReply represents the data returned from a GetWindowCreateContext request. -type GetWindowCreateContextReply struct { +// GetPropertyCreateContextReply represents the data returned from a GetPropertyCreateContext request. +type GetPropertyCreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -660,8 +589,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 GetPropertyCreateContext request. +func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -669,12 +598,12 @@ func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, if buf == nil { return nil, nil } - return getWindowCreateContextReply(buf), nil + return getPropertyCreateContextReply(buf), nil } -// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. -func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { - v := new(GetWindowCreateContextReply) +// getPropertyCreateContextReply reads a byte slice into a GetPropertyCreateContextReply value. +func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { + v := new(GetPropertyCreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -700,9 +629,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 GetPropertyCreateContext +// getPropertyCreateContextRequest writes a GetPropertyCreateContext request to a byte slice. +func getPropertyCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -710,7 +639,7 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -719,35 +648,35 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { return buf } -// GetWindowContextCookie is a cookie used only for GetWindowContext requests. -type GetWindowContextCookie struct { +// GetPropertyDataContextCookie is a cookie used only for GetPropertyDataContext requests. +type GetPropertyDataContextCookie 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 { +// 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 'GetWindowContext' 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, true) - c.NewRequest(getWindowContextRequest(c, Window), cookie) - return GetWindowContextCookie{cookie} + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} } -// GetWindowContextUnchecked sends an unchecked request. +// GetPropertyDataContextUnchecked 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 GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { 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 'GetPropertyDataContext' 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(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} } -// GetWindowContextReply represents the data returned from a GetWindowContext request. -type GetWindowContextReply struct { +// 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 @@ -756,8 +685,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 GetPropertyDataContext request. +func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -765,12 +694,12 @@ func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { if buf == nil { return nil, nil } - return getWindowContextReply(buf), nil + return getPropertyDataContextReply(buf), nil } -// getWindowContextReply reads a byte slice into a GetWindowContextReply value. -func getWindowContextReply(buf []byte) *GetWindowContextReply { - v := new(GetWindowContextReply) +// 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 @@ -796,17 +725,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 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] = 7 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -815,96 +744,41 @@ func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + return buf } -// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. -type SetPropertyCreateContextCookie struct { +// GetPropertyUseContextCookie is a cookie used only for GetPropertyUseContext requests. +type GetPropertyUseContextCookie 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 -} - -// GetPropertyCreateContextCookie is a cookie used only for GetPropertyCreateContext requests. -type GetPropertyCreateContextCookie struct { - *xgb.Cookie -} - -// GetPropertyCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyCreateContextCookie.Reply() -func GetPropertyCreateContext(c *xgb.Conn) GetPropertyCreateContextCookie { +// GetPropertyUseContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyUseContextCookie.Reply() +func GetPropertyUseContext(c *xgb.Conn) GetPropertyUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyCreateContextRequest(c), cookie) - return GetPropertyCreateContextCookie{cookie} + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} } -// GetPropertyCreateContextUnchecked sends an unchecked request. +// GetPropertyUseContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyCreateContextUnchecked(c *xgb.Conn) GetPropertyCreateContextCookie { +func GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyCreateContextRequest(c), cookie) - return GetPropertyCreateContextCookie{cookie} + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} } -// GetPropertyCreateContextReply represents the data returned from a GetPropertyCreateContext request. -type GetPropertyCreateContextReply struct { +// GetPropertyUseContextReply represents the data returned from a GetPropertyUseContext request. +type GetPropertyUseContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -913,8 +787,8 @@ type GetPropertyCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyCreateContext request. -func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetPropertyUseContext request. +func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -922,12 +796,12 @@ func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextRep if buf == nil { return nil, nil } - return getPropertyCreateContextReply(buf), nil + return getPropertyUseContextReply(buf), nil } -// getPropertyCreateContextReply reads a byte slice into a GetPropertyCreateContextReply value. -func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { - v := new(GetPropertyCreateContextReply) +// getPropertyUseContextReply reads a byte slice into a GetPropertyUseContextReply value. +func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { + v := new(GetPropertyUseContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -953,9 +827,9 @@ func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { return v } -// Write request to wire for GetPropertyCreateContext -// getPropertyCreateContextRequest writes a GetPropertyCreateContext request to a byte slice. -func getPropertyCreateContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetPropertyUseContext +// getPropertyUseContextRequest writes a GetPropertyUseContext request to a byte slice. +func getPropertyUseContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -963,7 +837,7 @@ func getPropertyCreateContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -972,93 +846,134 @@ func getPropertyCreateContextRequest(c *xgb.Conn) []byte { return buf } -// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. -type SetPropertyUseContextCookie struct { +// GetSelectionContextCookie is a cookie used only for GetSelectionContext requests. +type GetSelectionContextCookie 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 { +// 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 'SetPropertyUseContext' 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, false) - c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) - return SetPropertyUseContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{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 { +// GetSelectionContextUnchecked 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 { 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 'GetSelectionContext' 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(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{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() +// 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 + 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 GetSelectionContext request. +func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionContextReply(buf), nil +} + +// 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 + + 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 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] = 10 // 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:], ContextLen) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } -// GetPropertyUseContextCookie is a cookie used only for GetPropertyUseContext requests. -type GetPropertyUseContextCookie struct { +// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. +type GetSelectionCreateContextCookie struct { *xgb.Cookie } -// GetPropertyUseContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyUseContextCookie.Reply() -func GetPropertyUseContext(c *xgb.Conn) GetPropertyUseContextCookie { +// 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 'GetPropertyUseContext' 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(getPropertyUseContextRequest(c), cookie) - return GetPropertyUseContextCookie{cookie} + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} } -// GetPropertyUseContextUnchecked 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 GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { +func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyUseContext' 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(getPropertyUseContextRequest(c), cookie) - return GetPropertyUseContextCookie{cookie} + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} } -// GetPropertyUseContextReply represents the data returned from a GetPropertyUseContext request. -type GetPropertyUseContextReply 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 @@ -1067,8 +982,8 @@ type GetPropertyUseContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyUseContext request. -func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, 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 @@ -1076,12 +991,12 @@ func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, er if buf == nil { return nil, nil } - return getPropertyUseContextReply(buf), nil + return getSelectionCreateContextReply(buf), nil } -// getPropertyUseContextReply reads a byte slice into a GetPropertyUseContextReply value. -func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { - v := new(GetPropertyUseContextReply) +// 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 @@ -1107,9 +1022,9 @@ func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { return v } -// Write request to wire for GetPropertyUseContext -// getPropertyUseContextRequest writes a GetPropertyUseContext request to a byte slice. -func getPropertyUseContextRequest(c *xgb.Conn) []byte { +// 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) @@ -1117,7 +1032,7 @@ func getPropertyUseContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1126,35 +1041,35 @@ func getPropertyUseContextRequest(c *xgb.Conn) []byte { return buf } -// GetPropertyContextCookie is a cookie used only for GetPropertyContext requests. -type GetPropertyContextCookie struct { +// GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. +type GetSelectionDataContextCookie 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 { +// 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 'GetPropertyContext' 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(getPropertyContextRequest(c, Window, Property), cookie) - return GetPropertyContextCookie{cookie} + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} } -// GetPropertyContextUnchecked 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 GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { +func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { 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 'GetSelectionDataContext' 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(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} } -// GetPropertyContextReply represents the data returned from a GetPropertyContext request. -type GetPropertyContextReply 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 @@ -1163,8 +1078,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 GetSelectionDataContext request. +func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1172,12 +1087,12 @@ func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { if buf == nil { return nil, nil } - return getPropertyContextReply(buf), nil + return getSelectionDataContextReply(buf), nil } -// getPropertyContextReply reads a byte slice into a GetPropertyContextReply value. -func getPropertyContextReply(buf []byte) *GetPropertyContextReply { - v := new(GetPropertyContextReply) +// 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 @@ -1203,60 +1118,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 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) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 12 // 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 - - 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 { +// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. +type GetSelectionUseContextCookie 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 { +// 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 'GetPropertyDataContext' 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(getPropertyDataContextRequest(c, Window, Property), cookie) - return GetPropertyDataContextCookie{cookie} + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} } -// GetPropertyDataContextUnchecked 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 GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { +func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { 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 'GetSelectionUseContext' 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(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} } -// GetPropertyDataContextReply represents the data returned from a GetPropertyDataContext request. -type GetPropertyDataContextReply 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 @@ -1265,8 +1177,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 GetSelectionUseContext request. +func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1274,12 +1186,12 @@ func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, if buf == nil { return nil, nil } - return getPropertyDataContextReply(buf), nil + return getSelectionUseContextReply(buf), nil } -// getPropertyDataContextReply reads a byte slice into a GetPropertyDataContextReply value. -func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { - v := new(GetPropertyDataContextReply) +// 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 @@ -1305,70 +1217,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 GetSelectionUseContext +// getSelectionUseContextRequest writes a GetSelectionUseContext request to a byte slice. +func getSelectionUseContextRequest(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] = 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(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 { +// GetWindowContextCookie is a cookie used only for GetWindowContext requests. +type GetWindowContextCookie 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 { +// 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 'ListProperties' 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(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} } -// ListPropertiesUnchecked 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 ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { +func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { 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 'GetWindowContext' 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(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} } -// ListPropertiesReply represents the data returned from a ListProperties request. -type ListPropertiesReply 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 - 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 GetWindowContext request. +func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1376,12 +1282,12 @@ func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { if buf == nil { return nil, nil } - return listPropertiesReply(buf), nil + return getWindowContextReply(buf), nil } -// listPropertiesReply reads a byte slice into a ListPropertiesReply value. -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) +// 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 @@ -1392,20 +1298,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 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) @@ -1413,7 +1323,7 @@ func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1425,103 +1335,141 @@ func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. -type SetSelectionCreateContextCookie struct { +// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. +type GetWindowCreateContextCookie 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 { +// 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 'SetSelectionCreateContext' 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, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{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 { +// GetWindowCreateContextUnchecked 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 { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionCreateContext' 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, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{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() +// 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 + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// 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) +// 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 + } + if buf == nil { + return nil, nil + } + return getWindowCreateContextReply(buf), nil +} - buf[b] = c.Extensions["SELINUX"] - b += 1 +// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. +func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { + v := new(GetWindowCreateContextReply) + b := 1 // skip reply determinant - buf[b] = 15 // 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:], ContextLen) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 - return buf -} + b += 20 // padding -// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. -type GetSelectionCreateContextCookie struct { + { + 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 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] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// ListPropertiesCookie is a cookie used only for ListProperties requests. +type ListPropertiesCookie 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 { +// 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 'GetSelectionCreateContext' 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(getSelectionCreateContextRequest(c), cookie) - return GetSelectionCreateContextCookie{cookie} + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// GetSelectionCreateContextUnchecked 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 GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { +func ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { 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 'ListProperties' 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(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// GetSelectionCreateContextReply represents the data returned from a GetSelectionCreateContext request. -type GetSelectionCreateContextReply 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 GetSelectionCreateContext request. -func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, 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 @@ -1529,12 +1477,12 @@ func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextR if buf == nil { return nil, nil } - return getSelectionCreateContextReply(buf), nil + return listPropertiesReply(buf), nil } -// getSelectionCreateContextReply reads a byte slice into a GetSelectionCreateContextReply value. -func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { - v := new(GetSelectionCreateContextReply) +// 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 @@ -1545,137 +1493,78 @@ func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply 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 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] = 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)))) +// 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) buf[b] = c.Extensions["SELINUX"] 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:], ContextLen) + xgb.Put32(buf[b:], uint32(Window)) 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 { +// ListSelectionsCookie is a cookie used only for ListSelections requests. +type ListSelectionsCookie 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 { +// ListSelections sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSelectionsCookie.Reply() +func ListSelections(c *xgb.Conn) ListSelectionsCookie { 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 'ListSelections' 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(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} } -// GetSelectionUseContextUnchecked sends an unchecked request. +// ListSelectionsUnchecked 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 ListSelectionsUnchecked(c *xgb.Conn) ListSelectionsCookie { 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 'ListSelections' 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(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} } -// GetSelectionUseContextReply represents the data returned from a GetSelectionUseContext request. -type GetSelectionUseContextReply struct { +// ListSelectionsReply represents the data returned from a ListSelections request. +type ListSelectionsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ContextLen uint32 + SelectionsLen uint32 // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) + Selections []ListItem // size: ListItemListSize(Selections) } -// 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 ListSelections request. +func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1683,12 +1572,12 @@ func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, if buf == nil { return nil, nil } - return getSelectionUseContextReply(buf), nil + return listSelectionsReply(buf), nil } -// getSelectionUseContextReply reads a byte slice into a GetSelectionUseContextReply value. -func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { - v := new(GetSelectionUseContextReply) +// listSelectionsReply reads a byte slice into a ListSelectionsReply value. +func listSelectionsReply(buf []byte) *ListSelectionsReply { + v := new(ListSelectionsReply) b := 1 // skip reply determinant b += 1 // padding @@ -1699,24 +1588,20 @@ func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) + v.SelectionsLen = 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.Selections = make([]ListItem, v.SelectionsLen) + b += ListItemReadList(buf[b:], v.Selections) return v } -// Write request to wire for GetSelectionUseContext -// getSelectionUseContextRequest writes a GetSelectionUseContext request to a byte slice. -func getSelectionUseContextRequest(c *xgb.Conn) []byte { +// Write request to wire for ListSelections +// listSelectionsRequest writes a ListSelections request to a byte slice. +func listSelectionsRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -1724,7 +1609,7 @@ func getSelectionUseContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1733,45 +1618,44 @@ func getSelectionUseContextRequest(c *xgb.Conn) []byte { return buf } -// GetSelectionContextCookie is a cookie used only for GetSelectionContext requests. -type GetSelectionContextCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie 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 { +// 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 'GetSelectionContext' 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(getSelectionContextRequest(c, Selection), cookie) - return GetSelectionContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetSelectionContextUnchecked 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 GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { 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 'QueryVersion' 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(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetSelectionContextReply represents the data returned from a GetSelectionContext request. -type GetSelectionContextReply 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 GetSelectionContext request. -func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, 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 @@ -1779,12 +1663,12 @@ func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) if buf == nil { return nil, nil } - return getSelectionContextReply(buf), nil + return queryVersionReply(buf), nil } -// getSelectionContextReply reads a byte slice into a GetSelectionContextReply value. -func getSelectionContextReply(buf []byte) *GetSelectionContextReply { - v := new(GetSelectionContextReply) +// 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 @@ -1795,24 +1679,18 @@ func getSelectionContextReply(buf []byte) *GetSelectionContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) - } + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 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 { +// 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) @@ -1820,304 +1698,426 @@ func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { buf[b] = c.Extensions["SELINUX"] 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(Selection)) - b += 4 + buf[b] = ClientMajor + b += 1 + + buf[b] = ClientMinor + b += 1 return buf } -// GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. -type GetSelectionDataContextCookie struct { +// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. +type SetDeviceContextCookie 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 { +// 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 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceContext' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} } -// GetSelectionDataContextUnchecked 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 { +// 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 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceContext' 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} + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} } -// 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 - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 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 SetDeviceContextCookie) Check() error { + return cook.Cookie.Check() } -// 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 - } - if buf == nil { - return nil, nil - } - return getSelectionDataContextReply(buf), nil -} +// 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) -// getSelectionDataContextReply reads a byte slice into a GetSelectionDataContextReply value. -func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { - v := new(GetSelectionDataContextReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["SELINUX"] + b += 1 - b += 1 // padding + buf[b] = 3 // 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:], Device) b += 4 - v.ContextLen = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], ContextLen) b += 4 - b += 20 // padding + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.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 GetSelectionDataContext -// getSelectionDataContextRequest writes a GetSelectionDataContext request to a byte slice. -func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []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] = 20 // 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(Selection)) + xgb.Put32(buf[b:], ContextLen) b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + return buf } -// ListSelectionsCookie is a cookie used only for ListSelections requests. -type ListSelectionsCookie struct { +// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. +type SetPropertyCreateContextCookie struct { *xgb.Cookie } -// ListSelections sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListSelectionsCookie.Reply() -func ListSelections(c *xgb.Conn) ListSelectionsCookie { +// 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 'ListSelections' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(listSelectionsRequest(c), cookie) - return ListSelectionsCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} } -// ListSelectionsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListSelectionsUnchecked(c *xgb.Conn) ListSelectionsCookie { +// 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 'ListSelections' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(listSelectionsRequest(c), cookie) - return ListSelectionsCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} } -// ListSelectionsReply represents the data returned from a ListSelections request. -type ListSelectionsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - SelectionsLen uint32 - // padding: 20 bytes - Selections []ListItem // size: ListItemListSize(Selections) +// Check returns an error if one occurred 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() } -// Reply blocks and returns the reply data for a ListSelections request. -func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listSelectionsReply(buf), nil -} +// 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) -// listSelectionsReply reads a byte slice into a ListSelectionsReply value. -func listSelectionsReply(buf []byte) *ListSelectionsReply { - v := new(ListSelectionsReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["SELINUX"] + 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:], ContextLen) b += 4 - v.SelectionsLen = xgb.Get32(buf[b:]) - b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) - b += 20 // padding + return buf +} - v.Selections = make([]ListItem, v.SelectionsLen) - b += ListItemReadList(buf[b:], v.Selections) +// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. +type SetPropertyUseContextCookie struct { + *xgb.Cookie +} - return v +// 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} } -// Write request to wire for ListSelections -// listSelectionsRequest writes a ListSelections request to a byte slice. -func listSelectionsRequest(c *xgb.Conn) []byte { - size := 4 +// 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] = 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:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + return buf } -// GetClientContextCookie is a cookie used only for GetClientContext requests. -type GetClientContextCookie struct { +// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. +type SetSelectionCreateContextCookie 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 { +// 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 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetSelectionCreateContext' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} } -// GetClientContextUnchecked 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 { +// 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 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetSelectionCreateContext' 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} + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} } -// 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 - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 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 SetSelectionCreateContextCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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.") } - if buf == nil { - return nil, nil + 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.") } - return getClientContextReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} } -// getClientContextReply reads a byte slice into a GetClientContextReply value. -func getClientContextReply(buf []byte) *GetClientContextReply { - v := new(GetClientContextReply) - 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 SetSelectionUseContextCookie) Check() error { + return cook.Cookie.Check() +} - b += 1 // padding +// 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) - v.Sequence = xgb.Get16(buf[b:]) + 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 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], ContextLen) b += 4 - v.ContextLen = xgb.Get32(buf[b:]) - b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) - b += 20 // padding + return buf +} - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) +// 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} +} - return v +// 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} } -// 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 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] = 22 // 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:], Resource) + 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,208 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = 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 ( - TypeInputMask = 1 - TypeOutputMask = 2 - TypeVideoMask = 4 - TypeStillMask = 8 - TypeImageMask = 16 -) - -const ( - ImageFormatInfoTypeRgb = 0 - ImageFormatInfoTypeYuv = 1 -) - -const ( - ImageFormatInfoFormatPacked = 0 - ImageFormatInfoFormatPlanar = 1 -) - -const ( - AttributeFlagGettable = 1 - AttributeFlagSettable = 2 -) - -const ( - VideoNotifyReasonStarted = 0 - VideoNotifyReasonStopped = 1 - VideoNotifyReasonBusy = 2 - VideoNotifyReasonPreempted = 3 - VideoNotifyReasonHardError = 4 -) - -const ( - ScanlineOrderTopToBottom = 0 - ScanlineOrderBottomToTop = 1 -) - -const ( - GrabPortStatusSuccess = 0 - GrabPortStatusBadExtension = 1 - GrabPortStatusAlreadyGrabbed = 2 - GrabPortStatusInvalidTime = 3 - GrabPortStatusBadReply = 4 - GrabPortStatusBadAlloc = 5 -) - -type Port uint32 - -func NewPortId(c *xgb.Conn) (Port, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Port(id), nil -} - -type Encoding uint32 - -func NewEncodingId(c *xgb.Conn) (Encoding, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Encoding(id), nil -} - -type Rational struct { - Numerator int32 - Denominator int32 -} - -// RationalRead reads a byte slice into a Rational value. -func RationalRead(buf []byte, v *Rational) int { - b := 0 - - v.Numerator = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Denominator = int32(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// 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) -} - -// Bytes writes a Rational value to a byte slice. -func (v Rational) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Numerator)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Denominator)) - b += 4 - - return buf -} - -// 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 -} - -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 -} - type AdaptorInfo struct { BaseId Port NameSize uint16 @@ -349,53 +147,294 @@ func AdaptorInfoListSize(list []AdaptorInfo) int { return size } -type EncodingInfo struct { - Encoding Encoding - NameSize uint16 - Width uint16 - Height uint16 - // padding: 2 bytes - Rate Rational - Name string // size: xgb.Pad((int(NameSize) * 1)) +const ( + AttributeFlagGettable = 1 + AttributeFlagSettable = 2 +) + +type AttributeInfo struct { + Flags uint32 + Min int32 + Max int32 + Size uint32 + Name string // size: xgb.Pad((int(Size) * 1)) } -// EncodingInfoRead reads a byte slice into a EncodingInfo value. -func EncodingInfoRead(buf []byte, v *EncodingInfo) int { +// AttributeInfoRead reads a byte slice into a AttributeInfo value. +func AttributeInfoRead(buf []byte, v *AttributeInfo) int { b := 0 - v.Encoding = Encoding(xgb.Get32(buf[b:])) + v.Flags = xgb.Get32(buf[b:]) b += 4 - v.NameSize = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 + v.Min = int32(xgb.Get32(buf[b:])) + b += 4 - b += 2 // padding + v.Max = int32(xgb.Get32(buf[b:])) + b += 4 - v.Rate = Rational{} - b += RationalRead(buf[b:], &v.Rate) + v.Size = xgb.Get32(buf[b:]) + b += 4 { - byteString := make([]byte, v.NameSize) - copy(byteString[:v.NameSize], buf[b:]) + byteString := make([]byte, v.Size) + copy(byteString[:v.Size], buf[b:]) v.Name = string(byteString) - b += xgb.Pad(int(v.NameSize)) + b += xgb.Pad(int(v.Size)) } return b } -// EncodingInfoReadList reads a byte slice into a list of EncodingInfo values. -func EncodingInfoReadList(buf []byte, dest []EncodingInfo) 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] = EncodingInfo{} - b += EncodingInfoRead(buf[b:], &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 +} + +// BadBadControl is the error number for a BadBadControl. +const BadBadControl = 2 + +type BadControlError struct { + Sequence uint16 + NiceName string +} + +// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. +func BadControlErrorNew(buf []byte) xgb.Error { + v := BadControlError{} + v.NiceName = "BadControl" + + 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 BadBadControl error. +// This is mostly used internally. +func (err BadControlError) SequenceId() uint16 { + return err.Sequence +} + +// 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew +} + +// BadBadEncoding is the error number for a BadBadEncoding. +const BadBadEncoding = 1 + +type BadEncodingError struct { + Sequence uint16 + NiceName string +} + +// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice. +func BadEncodingErrorNew(buf []byte) xgb.Error { + v := BadEncodingError{} + v.NiceName = "BadEncoding" + + 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 BadBadEncoding error. +// This is mostly used internally. +func (err BadEncodingError) SequenceId() uint16 { + return err.Sequence +} + +// 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 +} + +// Error returns a rudimentary string representation of the BadBadEncoding error. + +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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew +} + +// BadBadPort is the error number for a BadBadPort. +const BadBadPort = 0 + +type BadPortError struct { + Sequence uint16 + NiceName string +} + +// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. +func BadPortErrorNew(buf []byte) xgb.Error { + v := BadPortError{} + v.NiceName = "BadPort" + + 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 BadBadPort error. +// This is mostly used internally. +func (err BadPortError) SequenceId() uint16 { + return err.Sequence +} + +// 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 +} + +// Error returns a rudimentary string representation of the BadBadPort error. + +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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew +} + +type Encoding uint32 + +func NewEncodingId(c *xgb.Conn) (Encoding, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Encoding(id), nil +} + +type EncodingInfo struct { + Encoding Encoding + NameSize uint16 + Width uint16 + Height uint16 + // padding: 2 bytes + Rate Rational + Name string // size: xgb.Pad((int(NameSize) * 1)) +} + +// EncodingInfoRead reads a byte slice into a EncodingInfo value. +func EncodingInfoRead(buf []byte, v *EncodingInfo) int { + b := 0 + + v.Encoding = Encoding(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Rate = Rational{} + b += RationalRead(buf[b:], &v.Rate) + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + return b +} + +// EncodingInfoReadList reads a byte slice into a list of EncodingInfo values. +func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = EncodingInfo{} + b += EncodingInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } @@ -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 @@ -846,130 +865,68 @@ func (v ImageFormatInfo) Bytes() []byte { xgb.Put32(buf[b:], v.VhorzUPeriod) b += 4 - xgb.Put32(buf[b:], v.VhorzVPeriod) - b += 4 - - xgb.Put32(buf[b:], v.VvertYPeriod) - b += 4 - - xgb.Put32(buf[b:], v.VvertUPeriod) - b += 4 - - xgb.Put32(buf[b:], v.VvertVPeriod) - b += 4 - - copy(buf[b:], v.VcompOrder[:32]) - b += xgb.Pad(int(32)) - - buf[b] = v.VscanlineOrder - b += 1 - - b += 11 // padding - - return buf -} - -// ImageFormatInfoListBytes writes a list of ImageFormatInfo values to a byte slice. -func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values. -func ImageFormatInfoListSize(list []ImageFormatInfo) int { - size := 0 - for _ = range list { - size += 128 - } - 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:], v.VhorzVPeriod) + b += 4 - xgb.Put32(buf[b:], uint32(v.Time)) + xgb.Put32(buf[b:], v.VvertYPeriod) b += 4 - xgb.Put32(buf[b:], uint32(v.Drawable)) + xgb.Put32(buf[b:], v.VvertUPeriod) b += 4 - xgb.Put32(buf[b:], uint32(v.Port)) + xgb.Put32(buf[b:], v.VvertVPeriod) b += 4 + copy(buf[b:], v.VcompOrder[:32]) + b += xgb.Pad(int(32)) + + buf[b] = v.VscanlineOrder + b += 1 + + b += 11 // padding + return buf } -// 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 +// ImageFormatInfoListBytes writes a list of ImageFormatInfo values to a byte slice. +func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) 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 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, ", ") + "}" +// ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values. +func ImageFormatInfoListSize(list []ImageFormatInfo) int { + size := 0 + for _ = range list { + size += 128 + } + return size } -func init() { - xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew +const ( + ImageFormatInfoFormatPacked = 0 + ImageFormatInfoFormatPlanar = 1 +) + +const ( + ImageFormatInfoTypeRgb = 0 + ImageFormatInfoTypeYuv = 1 +) + +type Port uint32 + +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' + +// Skipping definition for base type 'Card8' - 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 'Void' - return v -} +// Skipping definition for base type 'Double' -// 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 'Float' -// 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 'Int16' -// Error returns a rudimentary string representation of the BadBadControl error. +// Skipping definition for base type 'Int32' -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 'Int8' -func init() { - xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew -} +// Skipping definition for base type 'Card16' -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { +// 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,213 +1257,166 @@ 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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryAdaptors' 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} -} - -// QueryAdaptorsUnchecked sends an unchecked request. +// GetStill 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 { +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(false, true) - c.NewRequest(queryAdaptorsRequest(c, Window), cookie) - return QueryAdaptorsCookie{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) + cookie := c.NewCookie(false, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} } -// 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 +// 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 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - return queryAdaptorsReply(buf), nil + 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 reads a byte slice into a QueryAdaptorsReply value. -func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { - v := new(QueryAdaptorsReply) - 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.NumAdaptors = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Info = make([]AdaptorInfo, v.NumAdaptors) - b += AdaptorInfoReadList(buf[b:], v.Info) - - 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 GetStillCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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] = 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(Window)) + xgb.Put32(buf[b:], uint32(Port)) b += 4 - return buf -} - -// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. -type QueryEncodingsCookie 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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryEncodings' 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} -} + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 -// 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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryEncodings' 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} -} + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 -// 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) -} + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 -// 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 -} + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 -// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. -func queryEncodingsReply(buf []byte) *QueryEncodingsReply { - v := new(QueryEncodingsReply) - b := 1 // skip reply determinant + xgb.Put16(buf[b:], VidW) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], VidH) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DrwX)) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 - v.NumEncodings = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], DrwW) b += 2 - b += 22 // padding + xgb.Put16(buf[b:], DrwH) + b += 2 - v.Info = make([]EncodingInfo, v.NumEncodings) - b += EncodingInfoReadList(buf[b:], v.Info) + return buf +} - return v +// GetVideoCookie is a cookie used only for GetVideo requests. +type GetVideoCookie struct { + *xgb.Cookie } -// 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 +// 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 'GetVideo' 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} +} + +// 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 'GetVideo' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1473,6 +1425,36 @@ func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { 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 } @@ -1564,108 +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 - b := 0 - buf := make([]byte, size) +// 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 +} - buf[b] = c.Extensions["XVIDEO"] - b += 1 +// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. +func listImageFormatsReply(buf []byte) *ListImageFormatsReply { + v := new(ListImageFormatsReply) + b := 1 // skip reply determinant - buf[b] = 4 // 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(Port)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Time)) + v.NumFormats = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// PutVideoCookie is a cookie used only for PutVideo requests. -type PutVideoCookie struct { - *xgb.Cookie -} - -// PutVideo 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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutVideo' 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} -} + b += 20 // padding -// 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 'PutVideo' 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} -} + v.Format = make([]ImageFormatInfo, v.NumFormats) + b += ImageFormatInfoReadList(buf[b:], v.Format) -// Check returns an error if one occurred 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 { - return cook.Cookie.Check() + return v } -// 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 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] = 5 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1674,83 +1638,53 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto 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 } -// PutStillCookie is a cookie used only for PutStill requests. -type PutStillCookie struct { +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { *xgb.Cookie } -// PutStill 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 PutStill(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) PutStillCookie { +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 'PutStill' 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(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutStillCookie{cookie} + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} } -// PutStillChecked sends a checked request. -// If an error occurs, it can be retrieved using PutStillCookie.Check() -func PutStillChecked(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) PutStillCookie { +// 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 'PutStill' 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(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutStillCookie{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 PutStillCookie) Check() error { +func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutStill -// putStillRequest writes a PutStill request to a byte slice. -func putStillRequest(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] = 6 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1765,16 +1699,19 @@ func putStillRequest(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)) @@ -1789,45 +1726,54 @@ func putStillRequest(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 } -// GetVideoCookie is a cookie used only for GetVideo requests. -type GetVideoCookie struct { +// PutStillCookie is a cookie used only for PutStill requests. +type PutStillCookie struct { *xgb.Cookie } -// GetVideo sends an unchecked request. +// PutStill 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 PutStill(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) PutStillCookie { 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 'PutStill' 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(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{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 { +// PutStillChecked sends a checked request. +// If an error occurs, it can be retrieved using PutStillCookie.Check() +func PutStillChecked(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) PutStillCookie { 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 'PutStill' 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(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{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 PutStillCookie) 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 PutStill +// putStillRequest writes a PutStill request to a byte slice. +func putStillRequest(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 +1781,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] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1877,42 +1823,42 @@ 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 { +// PutVideoCookie is a cookie used only for PutVideo requests. +type PutVideoCookie struct { *xgb.Cookie } -// GetStill 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 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 { +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 'GetStill' 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(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetStillCookie{cookie} + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{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 { +// 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 'GetStill' 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(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetStillCookie{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 GetStillCookie) Check() error { +func (cook PutVideoCookie) 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 { +// 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) @@ -1920,7 +1866,7 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1962,189 +1908,98 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// StopVideoCookie is a cookie used only for StopVideo requests. -type StopVideoCookie struct { +// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. +type QueryAdaptorsCookie 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 { +// 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 '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(false, false) - c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) - return StopVideoCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{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 { +// 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 { 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)) - b += 4 - - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// 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,198 +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 { - *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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetPortAttribute' 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} -} - -// GetPortAttributeUnchecked 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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetPortAttribute' 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} -} - -// 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 - Value int32 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return getPortAttributeReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - 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 { +// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. +type QueryEncodingsCookie 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 { +// 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 'QueryPortAttributes' 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(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// QueryPortAttributesUnchecked 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 QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { +func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryPortAttributes' 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(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. -type QueryPortAttributesReply 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 - NumAttributes uint32 - TextSize uint32 - // padding: 16 bytes - Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) + NumEncodings uint16 + // padding: 22 bytes + Info []EncodingInfo // size: EncodingInfoListSize(Info) } -// Reply blocks and returns the reply data for a QueryPortAttributes request. -func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, 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 @@ -2460,12 +2162,12 @@ func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) if buf == nil { return nil, nil } - return queryPortAttributesReply(buf), nil + return queryEncodingsReply(buf), nil } - -// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. -func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { - v := new(QueryPortAttributesReply) + +// 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 @@ -2476,23 +2178,20 @@ func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { 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 + v.NumEncodings = xgb.Get16(buf[b:]) + b += 2 - 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 } @@ -2714,7 +2407,170 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 17 // 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(Port)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + 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:]) + 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(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2723,111 +2579,139 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 xgb.Put32(buf[b:], uint32(Port)) b += 4 - xgb.Put32(buf[b:], Id) - b += 4 - - xgb.Put16(buf[b:], Width) - b += 2 + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - xgb.Put16(buf[b:], Height) - b += 2 + b += 3 // padding return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. +type SelectVideoNotifyCookie struct { *xgb.Cookie } -// PutImage sends an unchecked request. +// SelectVideoNotify 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 SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { 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 'SelectVideoNotify' 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(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{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 { +// 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 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectVideoNotify' 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(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 PutImageCookie) Check() error { +func (cook SelectVideoNotifyCookie) 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 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] = 18 // 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(Port)) - b += 4 - 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,189 +174,29 @@ func SurfaceInfoListBytes(buf []byte, list []SurfaceInfo) 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) QueryVersionCookie { - 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.") - } - 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["XVIDEO-MOTIONCOMPENSATION"]; !ok { - 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(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 - Major uint32 - Minor 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.Major = xgb.Get32(buf[b:]) - b += 4 - - v.Minor = 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["XVIDEO-MOTIONCOMPENSATION"] - 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 -} - -// ListSurfaceTypesCookie is a cookie used only for ListSurfaceTypes requests. -type ListSurfaceTypesCookie 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 { - 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.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) - return ListSurfaceTypesCookie{cookie} -} - -// 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 'ListSurfaceTypes' 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} -} - -// 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)) -} - -// 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 +// Skipping definition for base type 'Bool' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Byte' - v.Num = xgb.Get32(buf[b:]) - b += 4 +// Skipping definition for base type 'Card8' - b += 20 // padding +// Skipping definition for base type 'Char' - v.Surfaces = make([]SurfaceInfo, v.Num) - b += SurfaceInfoReadList(buf[b:], v.Surfaces) +// Skipping definition for base type 'Void' - return v -} +// Skipping definition for base type 'Double' -// 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) +// Skipping definition for base type 'Float' - buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] - 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(PortId)) - b += 4 +// 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 { @@ -504,58 +320,131 @@ func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, Surfac return buf } -// DestroyContextCookie is a cookie used only for DestroyContext requests. -type DestroyContextCookie struct { +// CreateSubpictureCookie is a cookie used only for CreateSubpicture requests. +type CreateSubpictureCookie 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, ContextId Context) DestroyContextCookie { +// 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 'DestroyContext' 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, false) - c.NewRequest(destroyContextRequest(c, ContextId), cookie) - return DestroyContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) + return CreateSubpictureCookie{cookie} } -// DestroyContextChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyContextCookie.Check() -func DestroyContextChecked(c *xgb.Conn, ContextId Context) DestroyContextCookie { +// CreateSubpictureUnchecked 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 { if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'DestroyContext' 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, false) - c.NewRequest(destroyContextRequest(c, ContextId), cookie) - return DestroyContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) + return CreateSubpictureCookie{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() +// 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 + WidthActual uint16 + HeightActual uint16 + NumPaletteEntries uint16 + EntryBytes uint16 + ComponentOrder []byte // size: 4 + // padding: 12 bytes + PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Write request to wire for DestroyContext -// destroyContextRequest writes a DestroyContext request to a byte slice. -func destroyContextRequest(c *xgb.Conn, ContextId Context) []byte { - size := 8 +// 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 + } + if buf == nil { + return nil, nil + } + return createSubpictureReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + 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)) + + 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 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] = 3 // 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(ContextId)) + 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 } @@ -657,6 +546,116 @@ func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []b 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, ContextId Context) DestroyContextCookie { + if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, ContextId), 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, ContextId Context) DestroyContextCookie { + if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, ContextId), 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, ContextId Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextId)) + b += 4 + + return buf +} + +// DestroySubpictureCookie is a cookie used only for DestroySubpicture requests. +type DestroySubpictureCookie 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 { + 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.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) + return DestroySubpictureCookie{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 { + 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) + return DestroySubpictureCookie{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() +} + +// 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] = 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(SubpictureId)) + b += 4 + + return buf +} + // DestroySurfaceCookie is a cookie used only for DestroySurface requests. type DestroySurfaceCookie struct { *xgb.Cookie @@ -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 } -- cgit v1.2.3