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 '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' - -// 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' - // 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,34 +41,241 @@ 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 '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 'Byte' +// 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 + + 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 +} + +// GetOverlayWindow sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOverlayWindowCookie.Reply() +func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { + if _, ok := c.Extensions["COMPOSITE"]; !ok { + panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getOverlayWindowRequest(c, Window), cookie) + return GetOverlayWindowCookie{cookie} +} + +// GetOverlayWindowUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { + if _, ok := c.Extensions["COMPOSITE"]; !ok { + panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getOverlayWindowRequest(c, Window), cookie) + return GetOverlayWindowCookie{cookie} +} + +// GetOverlayWindowReply represents the data returned from a GetOverlayWindow request. +type GetOverlayWindowReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + OverlayWin xproto.Window + // padding: 20 bytes +} + +// Reply blocks and returns the reply data for a GetOverlayWindow request. +func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOverlayWindowReply(buf), nil +} + +// getOverlayWindowReply reads a byte slice into a GetOverlayWindowReply value. +func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { + v := new(GetOverlayWindowReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.OverlayWin = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for GetOverlayWindow +// getOverlayWindowRequest writes a GetOverlayWindow request to a byte slice. +func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 7 // request opcode + 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 +} + +// NameWindowPixmapCookie is a cookie used only for NameWindowPixmap requests. +type NameWindowPixmapCookie struct { + *xgb.Cookie +} + +// NameWindowPixmap 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 { + if _, ok := c.Extensions["COMPOSITE"]; !ok { + panic("Cannot issue request 'NameWindowPixmap' 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} +} + +// 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 'NameWindowPixmap' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + 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(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + return buf +} // QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { @@ -168,6 +375,66 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVers return buf } +// RedirectSubwindowsCookie is a cookie used only for RedirectSubwindows requests. +type RedirectSubwindowsCookie 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 { + if _, ok := c.Extensions["COMPOSITE"]; !ok { + panic("Cannot issue request 'RedirectSubwindows' 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} +} + +// 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 'RedirectSubwindows' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = Update + b += 1 + + b += 3 // padding + + return buf +} + // RedirectWindowCookie is a cookie used only for RedirectWindow requests. type RedirectWindowCookie struct { *xgb.Cookie @@ -228,42 +495,97 @@ func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byt return buf } -// RedirectSubwindowsCookie is a cookie used only for RedirectSubwindows requests. -type RedirectSubwindowsCookie struct { +// ReleaseOverlayWindowCookie is a cookie used only for ReleaseOverlayWindow requests. +type ReleaseOverlayWindowCookie struct { *xgb.Cookie } -// RedirectSubwindows 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 RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { +func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { 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 'ReleaseOverlayWindow' 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} + c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) + return ReleaseOverlayWindowCookie{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 { +// 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 'RedirectSubwindows' 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(redirectSubwindowsRequest(c, Window, Update), cookie) - return RedirectSubwindowsCookie{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 RedirectSubwindowsCookie) Check() error { +func (cook ReleaseOverlayWindowCookie) Check() error { return cook.Cookie.Check() } -// 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 { +// 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] = 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 + + return buf +} + +// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. +type UnredirectSubwindowsCookie struct { + *xgb.Cookie +} + +// UnredirectSubwindows 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 { + if _, ok := c.Extensions["COMPOSITE"]; !ok { + panic("Cannot issue request 'UnredirectSubwindows' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) + return UnredirectSubwindowsCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UnredirectSubwindowsCookie) 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 { size := 12 b := 0 buf := make([]byte, size) @@ -271,7 +593,7 @@ func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) [ buf[b] = c.Extensions["COMPOSITE"] 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 @@ -347,325 +669,3 @@ func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []b return buf } - -// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. -type UnredirectSubwindowsCookie struct { - *xgb.Cookie -} - -// UnredirectSubwindows 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 { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'UnredirectSubwindows' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) - return UnredirectSubwindowsCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UnredirectSubwindowsCookie) 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 { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["COMPOSITE"] - 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(Window)) - b += 4 - - buf[b] = Update - b += 1 - - b += 3 // padding - - return buf -} - -// CreateRegionFromBorderClipCookie is a cookie used only for CreateRegionFromBorderClip requests. -type CreateRegionFromBorderClipCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["COMPOSITE"] - 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(Region)) - b += 4 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// NameWindowPixmapCookie is a cookie used only for NameWindowPixmap requests. -type NameWindowPixmapCookie struct { - *xgb.Cookie -} - -// NameWindowPixmap 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 { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'NameWindowPixmap' 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} -} - -// 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 'NameWindowPixmap' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["COMPOSITE"] - 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(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Pixmap)) - b += 4 - - return buf -} - -// GetOverlayWindowCookie is a cookie used only for GetOverlayWindow requests. -type GetOverlayWindowCookie struct { - *xgb.Cookie -} - -// GetOverlayWindow sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetOverlayWindowCookie.Reply() -func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getOverlayWindowRequest(c, Window), cookie) - return GetOverlayWindowCookie{cookie} -} - -// GetOverlayWindowUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getOverlayWindowRequest(c, Window), cookie) - return GetOverlayWindowCookie{cookie} -} - -// GetOverlayWindowReply represents the data returned from a GetOverlayWindow request. -type GetOverlayWindowReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - OverlayWin xproto.Window - // padding: 20 bytes -} - -// Reply blocks and returns the reply data for a GetOverlayWindow request. -func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getOverlayWindowReply(buf), nil -} - -// getOverlayWindowReply reads a byte slice into a GetOverlayWindowReply value. -func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { - v := new(GetOverlayWindowReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.OverlayWin = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -// Write request to wire for GetOverlayWindow -// getOverlayWindowRequest writes a GetOverlayWindow request to a byte slice. -func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["COMPOSITE"] - b += 1 - - buf[b] = 7 // request opcode - 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 -} - -// ReleaseOverlayWindowCookie is a cookie used only for ReleaseOverlayWindow requests. -type ReleaseOverlayWindowCookie struct { - *xgb.Cookie -} - -// ReleaseOverlayWindow 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 { - if _, ok := c.Extensions["COMPOSITE"]; !ok { - panic("Cannot issue request 'ReleaseOverlayWindow' 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} -} - -// 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 'ReleaseOverlayWindow' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["COMPOSITE"] - 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 - - 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' +// BadBadDamage is the error number for a BadBadDamage. +const BadBadDamage = 0 -// Skipping definition for base type 'Int32' +type BadDamageError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Void' +// 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 '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 BadBadDamage error. +// This is mostly used internally. +func (err BadDamageError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Card32' +// 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 'Double' +// Error returns a rudimentary string representation of the BadBadDamage error. -// Skipping definition for base type 'Bool' +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 'Float' - -// Skipping definition for base type 'Card8' - -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 { +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// AddCookie is a cookie used only for Add requests. +type AddCookie 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["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} -} - -// 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} + cookie := c.NewCookie(false, false) + c.NewRequest(addRequest(c, Drawable, Region), cookie) + return AddCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err +// 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.") } - if buf == nil { - return nil, nil - } - 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,6 +406,104 @@ func destroyRequest(c *xgb.Conn, Damage Damage) []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 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} +} + +// 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 'QueryVersion' 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 +} + +// 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] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 + + return buf +} + // SubtractCookie is a cookie used only for Subtract requests. type SubtractCookie struct { *xgb.Cookie @@ -506,61 +564,3 @@ func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfi return buf } - -// AddCookie is a cookie used only for Add requests. -type AddCookie struct { - *xgb.Cookie -} - -// Add 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 { - if _, ok := c.Extensions["DAMAGE"]; !ok { - panic("Cannot issue request 'Add' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(addRequest(c, Drawable, Region), cookie) - return AddCookie{cookie} -} - -// Check returns an error if one occurred 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 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) - - buf[b] = c.Extensions["DAMAGE"] - 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Region)) - 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 -} +// Skipping definition for base type 'Bool' -// 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} -} +// Skipping definition for base type 'Byte' -// 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} -} +// Skipping definition for base type 'Card8' -// 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 -} +// Skipping definition for base type 'Char' -// 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 -} +// Skipping definition for base type 'Void' -// getVersionReply reads a byte slice into a GetVersionReply value. -func getVersionReply(buf []byte) *GetVersionReply { - v := new(GetVersionReply) - b := 1 // skip reply determinant +// Skipping definition for base type 'Double' - b += 1 // padding +// Skipping definition for base type 'Float' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Int32' - v.ServerMajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int8' - v.ServerMinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card16' - 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) - - buf[b] = c.Extensions["DPMS"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], ClientMajorVersion) - b += 2 - - xgb.Put16(buf[b:], ClientMinorVersion) - b += 2 - - return buf -} +// Skipping definition for base type 'Card32' // CapableCookie is a cookie used only for Capable requests. type CapableCookie struct { @@ -258,6 +163,165 @@ func capableRequest(c *xgb.Conn) []byte { return buf } +// DisableCookie is a cookie used only for Disable requests. +type DisableCookie 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 { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Disable' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} +} + +// Check returns an error if one occurred 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 Disable +// disableRequest writes a Disable request to a byte slice. +func disableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// EnableCookie is a cookie used only for Enable requests. +type EnableCookie struct { + *xgb.Cookie +} + +// Enable 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 { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Enable' 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} +} + +// 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 'Enable' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + 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 +} + +// ForceLevelCookie is a cookie used only for ForceLevel requests. +type ForceLevelCookie 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 { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'ForceLevel' 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} +} + +// 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 'ForceLevel' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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 +} + // GetTimeoutsCookie is a cookie used only for GetTimeouts requests. type GetTimeoutsCookie struct { *xgb.Cookie @@ -354,207 +418,79 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { return buf } -// SetTimeoutsCookie is a cookie used only for SetTimeouts requests. -type SetTimeoutsCookie struct { +// GetVersionCookie is a cookie used only for GetVersion requests. +type GetVersionCookie struct { *xgb.Cookie } -// SetTimeouts sends an unchecked request. +// 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 SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { +func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { 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 'GetVersion' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{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.") +// 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) - return SetTimeoutsCookie{cookie} + if buf == nil { + return nil, nil + } + return getVersionReply(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 SetTimeoutsCookie) Check() error { - return cook.Cookie.Check() -} +// getVersionReply reads a byte slice into a GetVersionReply value. +func getVersionReply(buf []byte) *GetVersionReply { + v := new(GetVersionReply) + b := 1 // skip reply determinant -// 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) + b += 1 // padding - 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 + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], StandbyTimeout) + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajorVersion = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], SuspendTimeout) + v.ServerMinorVersion = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], OffTimeout) - b += 2 - - return buf + return v } -// EnableCookie is a cookie used only for Enable requests. -type EnableCookie struct { - *xgb.Cookie -} - -// Enable 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 { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Enable' 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} -} - -// 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 'Enable' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["DPMS"] - 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 -} - -// DisableCookie is a cookie used only for Disable requests. -type DisableCookie 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 { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Disable' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(disableRequest(c), cookie) - return DisableCookie{cookie} -} - -// Check returns an error if one occurred 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 Disable -// disableRequest writes a Disable request to a byte slice. -func disableRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["DPMS"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// ForceLevelCookie is a cookie used only for ForceLevel requests. -type ForceLevelCookie 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 { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'ForceLevel' 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} -} - -// 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 'ForceLevel' 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for ForceLevel -// forceLevelRequest writes a ForceLevel request to a byte slice. -func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { +// 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,99 +922,6 @@ 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 { - *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 { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'CopyRegion' 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} -} - -// CopyRegionUnchecked 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 { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'CopyRegion' 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} -} - -// 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 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return copyRegionReply(buf), nil -} - -// 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 - - 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 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] = 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)) - b += 4 - - xgb.Put32(buf[b:], Region) - b += 4 - - xgb.Put32(buf[b:], Dest) - b += 4 - - xgb.Put32(buf[b:], Src) - b += 4 - - return buf -} - // GetBuffersWithFormatCookie is a cookie used only for GetBuffersWithFormat requests. type GetBuffersWithFormatCookie struct { *xgb.Cookie @@ -1125,6 +1030,309 @@ func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count ui 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 + + 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 +} + +// 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 GetParam +// getParamRequest writes a GetParam request to a byte slice. +func getParamRequest(c *xgb.Conn, Drawable xproto.Drawable, Param uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Param) + b += 4 + + return buf +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + // SwapBuffersCookie is a cookie used only for SwapBuffers requests. type SwapBuffersCookie struct { *xgb.Cookie @@ -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} + cookie := c.NewCookie(false, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{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 +// 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.") } - if buf == nil { - return nil, nil - } - 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,30 +40,30 @@ 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 'Byte' - // Skipping definition for base type 'Int8' +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + // QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie 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 -// Skipping definition for base type 'Int16' +type BadContextError GenericError -// Skipping definition for base type 'Int32' +// 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 'Void' +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Byte' +// 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 +} -// Skipping definition for base type 'Int8' +// 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, ", ") + "}" +} -// Skipping definition for base type 'Card16' +func init() { + xgb.NewExtErrorFuncs["GLX"][0] = BadContextErrorNew +} -// Skipping definition for base type 'Char' +// BadBadContextState is the error number for a BadBadContextState. +const BadBadContextState = 1 -// Skipping definition for base type 'Card32' +type BadContextStateError GenericError -// Skipping definition for base type 'Double' +// 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 +} -// Skipping definition for base type 'Bool' +// SequenceId returns the sequence id attached to the BadBadContextState error. +// This is mostly used internally. +func (err BadContextStateError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Float' +// 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 +} -const ( - PbcetDamaged = 32791 - PbcetSaved = 32792 -) +// 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, ", ") + "}" +} -const ( - PbcdtWindow = 32793 - PbcdtPbuffer = 32794 -) +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 +} + +// BadId returns the 'BadValue' number if one exists for the BadBadPbuffer error. If no bad value exists, 0 is returned. +func (err BadPbufferError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the 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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew +} + +// 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 +} + +// SequenceId returns the sequence id attached to the BadBadPixmap error. +// This is mostly used internally. +func (err BadPixmapError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadPixmap error. If no bad value exists, 0 is returned. +func (err BadPixmapError) BadId() uint32 { + return 0 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew +} + +// BadBadRenderRequest is the error number for a BadBadRenderRequest. +const BadBadRenderRequest = 6 + +type BadRenderRequestError GenericError + +// BadRenderRequestErrorNew constructs a BadRenderRequestError value that implements xgb.Error from a byte slice. +func BadRenderRequestErrorNew(buf []byte) xgb.Error { + v := BadRenderRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadRenderRequest" + 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,31 +596,79 @@ const ( GcGlAllAttribBits = 16777215 ) +// BadGeneric is the error number for a BadGeneric. +const BadGeneric = -1 + +type GenericError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 21 bytes +} + +// GenericErrorNew constructs a GenericError value that implements xgb.Error from a byte slice. +func GenericErrorNew(buf []byte) xgb.Error { + v := GenericError{} + v.NiceName = "Generic" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 21 // padding + + return v +} + +// SequenceId returns the sequence id attached to the BadGeneric error. +// This is mostly used internally. +func (err GenericError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadGeneric error. If no bad value exists, 0 is returned. +func (err GenericError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadGeneric error. + +func (err GenericError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew +} + const ( - RmGlRender = 7168 - RmGlFeedback = 7169 - RmGlSelect = 7170 + PbcdtWindow = 32793 + PbcdtPbuffer = 32794 ) -type Pixmap uint32 - -func NewPixmapId(c *xgb.Conn) (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} - -type Context uint32 - -func NewContextId(c *xgb.Conn) (Context, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Context(id), nil -} +const ( + PbcetDamaged = 32791 + PbcetSaved = 32792 +) type Pbuffer uint32 @@ -134,44 +680,6 @@ func NewPbufferId(c *xgb.Conn) (Pbuffer, error) { return Pbuffer(id), nil } -type Window uint32 - -func NewWindowId(c *xgb.Conn) (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} - -type Fbconfig uint32 - -func NewFbconfigId(c *xgb.Conn) (Fbconfig, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fbconfig(id), nil -} - -type Drawable uint32 - -func NewDrawableId(c *xgb.Conn) (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil -} - -type Float32 float64 - -type Float64 float64 - -type Bool32 uint32 - -type ContextTag uint32 - // PbufferClobber is the event number for a PbufferClobberEvent. const PbufferClobber = 0 @@ -312,373 +820,21 @@ 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 - - v.MajorOpcode = buf[b] - b += 1 - - b += 21 // padding - - return v -} - -// SequenceId returns the sequence id attached to the BadGeneric error. -// This is mostly used internally. -func (err GenericError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadGeneric error. If no bad value exists, 0 is returned. -func (err GenericError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadGeneric error. - -func (err GenericError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew -} - -// BadBadContext is the error number for a BadBadContext. -const BadBadContext = 0 - -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 -} - -// BadBadDrawable is the error number for a BadBadDrawable. -const BadBadDrawable = 2 - -type BadDrawableError GenericError - -// BadDrawableErrorNew constructs a BadDrawableError value that implements xgb.Error from a byte slice. -func BadDrawableErrorNew(buf []byte) xgb.Error { - v := BadDrawableError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadDrawable" - return v -} - -// SequenceId returns the sequence id attached to the BadBadDrawable error. -// This is mostly used internally. -func (err BadDrawableError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadBadDrawable error. If no bad value exists, 0 is returned. -func (err BadDrawableError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadBadDrawable error. -func (err BadDrawableError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadBadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["GLX"][2] = BadDrawableErrorNew -} - -// BadBadPixmap is the error number for a BadBadPixmap. -const BadBadPixmap = 3 - -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 -} - -// SequenceId returns the sequence id attached to the BadBadPixmap error. -// This is mostly used internally. -func (err BadPixmapError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadBadPixmap error. If no bad value exists, 0 is returned. -func (err BadPixmapError) BadId() uint32 { - return 0 -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew -} - -// 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 -} - -// 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 -} - -// BadBadRenderRequest is the error number for a BadBadRenderRequest. -const BadBadRenderRequest = 6 - -type BadRenderRequestError GenericError - -// BadRenderRequestErrorNew constructs a BadRenderRequestError value that implements xgb.Error from a byte slice. -func BadRenderRequestErrorNew(buf []byte) xgb.Error { - v := BadRenderRequestError(GenericErrorNew(buf).(GenericError)) - v.NiceName = "BadRenderRequest" - 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 -} - -// 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 -} +const ( + RmGlRender = 7168 + RmGlFeedback = 7169 + RmGlSelect = 7170 +) // BadUnsupportedPrivateRequest is the error number for a BadUnsupportedPrivateRequest. const BadUnsupportedPrivateRequest = 8 @@ -718,240 +874,132 @@ func init() { xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew } -// BadBadFBConfig is the error number for a BadBadFBConfig. -const BadBadFBConfig = 9 +type Window uint32 -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 +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil } -// SequenceId returns the sequence id attached to the BadBadFBConfig error. -// This is mostly used internally. -func (err BadFBConfigError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Bool' -// 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 -} +// Skipping definition for base type 'Byte' -// 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, ", ") + "}" -} +// Skipping definition for base type 'Card8' -func init() { - xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew -} +// Skipping definition for base type 'Char' -// BadBadPbuffer is the error number for a BadBadPbuffer. -const BadBadPbuffer = 10 +// Skipping definition for base type 'Void' -type BadPbufferError GenericError +// Skipping definition for base type 'Double' -// 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 -} +// Skipping definition for base type 'Float' -// 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 'Int8' -func init() { - xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew -} +// Skipping definition for base type 'Card16' -// BadBadCurrentDrawable is the error number for a BadBadCurrentDrawable. -const BadBadCurrentDrawable = 11 +// Skipping definition for base type 'Card32' -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 -} - -// 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 -} - -// 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 -} - -// RenderCookie is a cookie used only for Render requests. -type RenderCookie struct { +// AreTexturesResidentCookie is a cookie used only for AreTexturesResident requests. +type AreTexturesResidentCookie struct { *xgb.Cookie } -// Render sends an unchecked request. +// 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} +} + +// AreTexturesResidentUnchecked 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 AreTexturesResidentUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { 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 'AreTexturesResident' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) + return AreTexturesResidentCookie{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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Render' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") +// 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)) +} + +// 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(renderRequest(c, ContextTag, Data), cookie) - return RenderCookie{cookie} + if buf == nil { + return nil, nil + } + return areTexturesResidentReply(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 RenderCookie) Check() error { - return cook.Cookie.Check() +// 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 + + v.Data = make([]bool, (int(v.Length) * 4)) + for i := 0; i < int((int(v.Length) * 4)); i++ { + if buf[b] == 1 { + v.Data[i] = true + } else { + v.Data[i] = false + } + b += 1 + } + b = xgb.Pad(b) + + return v } -// Write request to wire for 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 AreTexturesResident +// areTexturesResidentRequest writes a AreTexturesResident request to a byte slice. +func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 143 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -960,75 +1008,206 @@ func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { 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 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// RenderLargeCookie is a cookie used only for RenderLarge requests. -type RenderLargeCookie struct { +// ChangeDrawableAttributesCookie is a cookie used only for ChangeDrawableAttributes requests. +type ChangeDrawableAttributesCookie struct { *xgb.Cookie } -// RenderLarge sends an unchecked request. +// ChangeDrawableAttributes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RenderLarge(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { +func ChangeDrawableAttributes(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { 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 'ChangeDrawableAttributes' 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(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{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 { +// 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 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeDrawableAttributes' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return RenderLargeCookie{cookie} + c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook RenderLargeCookie) Check() error { +func (cook ChangeDrawableAttributesCookie) 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 ChangeDrawableAttributes +// changeDrawableAttributesRequest writes a ChangeDrawableAttributes request to a byte slice. +func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(ContextTag)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], RequestNum) - b += 2 - - xgb.Put16(buf[b:], RequestTotal) - b += 2 - - 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 +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// Write request to wire for ClientInfo +// clientInfoRequest writes a ClientInfo request to a byte slice. +func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 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:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], StrLen) + b += 4 + + copy(buf[b:], String[:StrLen]) + b += xgb.Pad(int(StrLen)) + + return buf +} + +// CopyContextCookie is a cookie used only for CopyContext requests. +type CopyContextCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dest)) + b += 4 + + xgb.Put32(buf[b:], Mask) + b += 4 + + xgb.Put32(buf[b:], uint32(SrcContextTag)) + b += 4 return buf } @@ -1106,50 +1285,50 @@ func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, return buf } -// DestroyContextCookie is a cookie used only for DestroyContext requests. -type DestroyContextCookie struct { +// CreateContextAttribsARBCookie is a cookie used only for CreateContextAttribsARB requests. +type CreateContextAttribsARBCookie struct { *xgb.Cookie } -// DestroyContext sends an unchecked request. +// CreateContextAttribsARB sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyContext(c *xgb.Conn, Context Context) DestroyContextCookie { +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 'DestroyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContextAttribsARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(destroyContextRequest(c, Context), cookie) - return DestroyContextCookie{cookie} + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{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 { +// 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 'DestroyContext' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContextAttribsARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(destroyContextRequest(c, Context), cookie) - return DestroyContextCookie{cookie} + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyContextCookie) Check() error { +func (cook CreateContextAttribsARBCookie) 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 CreateContextAttribsARB +// createContextAttribsARBRequest writes a CreateContextAttribsARB request to a byte slice. +func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 34 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1158,594 +1337,32 @@ func destroyContextRequest(c *xgb.Conn, Context Context) []byte { xgb.Put32(buf[b:], uint32(Context)) b += 4 - return buf -} - -// MakeCurrentCookie is a cookie used only for MakeCurrent requests. -type MakeCurrentCookie 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. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) - return MakeCurrentCookie{cookie} -} - -// 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 -} - -// 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 - } - return makeCurrentReply(buf), nil -} - -// makeCurrentReply reads a byte slice into a MakeCurrentReply value. -func makeCurrentReply(buf []byte) *MakeCurrentReply { - v := new(MakeCurrentReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Fbconfig)) b += 4 - v.ContextTag = ContextTag(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], Screen) b += 4 - 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)) + xgb.Put32(buf[b:], uint32(ShareList)) b += 4 - xgb.Put32(buf[b:], uint32(Context)) - b += 4 - - xgb.Put32(buf[b:], uint32(OldContextTag)) - b += 4 - - return buf -} - -// IsDirectCookie is a cookie used only for IsDirect requests. -type IsDirectCookie 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. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsDirect' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(isDirectRequest(c, Context), cookie) - return IsDirectCookie{cookie} -} - -// 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 -} - -// 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 - } - return isDirectReply(buf), nil -} - -// isDirectReply reads a byte slice into a IsDirectReply value. -func isDirectReply(buf []byte) *IsDirectReply { - v := new(IsDirectReply) - b := 1 // skip reply determinant - - b += 1 // padding - - 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 + if IsDirect { + buf[b] = 1 } else { - v.IsDirect = false + buf[b] = 0 } b += 1 - b += 23 // padding + b += 3 // padding - return v -} - -// 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] = 6 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Context)) + xgb.Put32(buf[b:], NumAttribs) b += 4 - return buf -} - -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { - *xgb.Cookie -} - -// QueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() -func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryVersion' 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} -} - -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryVersionReply(buf), nil -} - -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - 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:], MajorVersion) - b += 4 - - xgb.Put32(buf[b:], MinorVersion) - b += 4 - - return buf -} - -// WaitGLCookie is a cookie used only for WaitGL requests. -type WaitGLCookie struct { - *xgb.Cookie -} - -// 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 'WaitGL' 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} -} - -// 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 'WaitGL' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["GLX"] - 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(ContextTag)) - b += 4 - - return buf -} - -// WaitXCookie is a cookie used only for WaitX requests. -type WaitXCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(waitXRequest(c, ContextTag), cookie) - return WaitXCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 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(ContextTag)) - b += 4 - - return buf -} - -// CopyContextCookie is a cookie used only for CopyContext requests. -type CopyContextCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Src)) - b += 4 - - xgb.Put32(buf[b:], uint32(Dest)) - b += 4 - - xgb.Put32(buf[b:], Mask) - b += 4 - - xgb.Put32(buf[b:], uint32(SrcContextTag)) - b += 4 - - return buf -} - -// SwapBuffersCookie is a cookie used only for SwapBuffers requests. -type SwapBuffersCookie struct { - *xgb.Cookie -} - -// SwapBuffers 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SwapBuffers' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) - return SwapBuffersCookie{cookie} -} - -// Check returns an error if one occurred 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 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) - - buf[b] = c.Extensions["GLX"] - 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(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// UseXFontCookie is a cookie used only for UseXFont requests. -type UseXFontCookie struct { - *xgb.Cookie -} - -// 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 'UseXFont' 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} -} - -// 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 'UseXFont' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["GLX"] - 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(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 + b = xgb.Pad(b) return buf } @@ -1814,823 +1431,6 @@ func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, return buf } -// GetVisualConfigsCookie is a cookie used only for GetVisualConfigs requests. -type GetVisualConfigsCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetVisualConfigs' 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} -} - -// GetVisualConfigsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetVisualConfigs' 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} -} - -// GetVisualConfigsReply represents the data returned from a GetVisualConfigs request. -type GetVisualConfigsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumVisuals uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) -} - -// Reply blocks and returns the reply data for a GetVisualConfigs request. -func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getVisualConfigsReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - 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:], Screen) - b += 4 - - return buf -} - -// DestroyGLXPixmapCookie is a cookie used only for DestroyGLXPixmap requests. -type DestroyGLXPixmapCookie struct { - *xgb.Cookie -} - -// DestroyGLXPixmap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) - return DestroyGLXPixmapCookie{cookie} -} - -// DestroyGLXPixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyGLXPixmapCookie.Check() -func DestroyGLXPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DestroyGLXPixmap' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - 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 DestroyGLXPixmapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for DestroyGLXPixmap -// destroyGLXPixmapRequest writes a DestroyGLXPixmap request to a byte slice. -func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - 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(GlxPixmap)) - 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook VendorPrivateCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for VendorPrivate -// vendorPrivateRequest writes a VendorPrivate request to a byte slice. -func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 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:], VendorCode) - b += 4 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) - - return buf -} - -// VendorPrivateWithReplyCookie is a cookie used only for VendorPrivateWithReply requests. -type VendorPrivateWithReplyCookie struct { - *xgb.Cookie -} - -// VendorPrivateWithReply sends a checked request. -// If an error occurs, it will be returned with the reply by calling VendorPrivateWithReplyCookie.Reply() -func VendorPrivateWithReply(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateWithReplyCookie{cookie} -} - -// VendorPrivateWithReplyUnchecked sends an unchecked request. -// 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) - return VendorPrivateWithReplyCookie{cookie} -} - -// VendorPrivateWithReplyReply represents the data returned from a VendorPrivateWithReply request. -type VendorPrivateWithReplyReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Retval uint32 - Data1 []byte // size: 24 - Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) -} - -// Reply blocks and returns the reply data for a VendorPrivateWithReply request. -func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return vendorPrivateWithReplyReply(buf), nil -} - -// vendorPrivateWithReplyReply reads a byte slice into a VendorPrivateWithReplyReply value. -func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { - v := new(VendorPrivateWithReplyReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Retval = xgb.Get32(buf[b:]) - b += 4 - - v.Data1 = make([]byte, 24) - copy(v.Data1[:24], buf[b:]) - b += xgb.Pad(int(24)) - - v.Data2 = make([]byte, (int(v.Length) * 4)) - copy(v.Data2[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v -} - -// 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] = 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:], VendorCode) - b += 4 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) - - return buf -} - -// QueryExtensionsStringCookie is a cookie used only for QueryExtensionsString requests. -type QueryExtensionsStringCookie struct { - *xgb.Cookie -} - -// QueryExtensionsString sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryExtensionsStringCookie.Reply() -func QueryExtensionsString(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) - return QueryExtensionsStringCookie{cookie} -} - -// QueryExtensionsStringUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) - return QueryExtensionsStringCookie{cookie} -} - -// QueryExtensionsStringReply represents the data returned from a QueryExtensionsString request. -type QueryExtensionsStringReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - // padding: 16 bytes -} - -// Reply blocks and returns the reply data for a QueryExtensionsString request. -func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryExtensionsStringReply(buf), nil -} - -// queryExtensionsStringReply reads a byte slice into a QueryExtensionsStringReply value. -func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { - v := new(QueryExtensionsStringReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -// 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] = 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:], Screen) - b += 4 - - return buf -} - -// QueryServerStringCookie is a cookie used only for QueryServerString requests. -type QueryServerStringCookie struct { - *xgb.Cookie -} - -// QueryServerString sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryServerStringCookie.Reply() -func QueryServerString(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryServerString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) - return QueryServerStringCookie{cookie} -} - -// QueryServerStringUnchecked sends an unchecked request. -// 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryServerString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) - return QueryServerStringCookie{cookie} -} - -// QueryServerStringReply represents the data returned from a QueryServerString request. -type QueryServerStringReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - StrLen uint32 - // padding: 16 bytes - String string // size: xgb.Pad((int(StrLen) * 1)) -} - -// Reply blocks and returns the reply data for a QueryServerString request. -func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryServerStringReply(buf), nil -} - -// queryServerStringReply reads a byte slice into a QueryServerStringReply value. -func queryServerStringReply(buf []byte) *QueryServerStringReply { - v := new(QueryServerStringReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.StrLen = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.StrLen) - copy(byteString[:v.StrLen], buf[b:]) - v.String = string(byteString) - b += xgb.Pad(int(v.StrLen)) - } - - return v -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for ClientInfo -// clientInfoRequest writes a ClientInfo request to a byte slice. -func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { - size := xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 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:], MajorVersion) - b += 4 - - xgb.Put32(buf[b:], MinorVersion) - b += 4 - - xgb.Put32(buf[b:], StrLen) - b += 4 - - copy(buf[b:], String[:StrLen]) - b += xgb.Pad(int(StrLen)) - - return buf -} - -// GetFBConfigsCookie is a cookie used only for GetFBConfigs requests. -type GetFBConfigsCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetFBConfigs' 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} -} - -// 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 'GetFBConfigs' 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} -} - -// 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)) -} - -// 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 -} - -// getFBConfigsReply reads a byte slice into a GetFBConfigsReply value. -func getFBConfigsReply(buf []byte) *GetFBConfigsReply { - v := new(GetFBConfigsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - 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 - - 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 GetFBConfigs -// getFBConfigsRequest writes a GetFBConfigs request to a byte slice. -func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 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:], Screen) - b += 4 - - 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, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { - 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(false, false) - c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), 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, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { - 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 - } - b = xgb.Pad(b) - - return buf -} - -// DestroyPixmapCookie is a cookie used only for DestroyPixmap requests. -type DestroyPixmapCookie struct { - *xgb.Cookie -} - -// 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.") - } - 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.") - } - 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() -} - -// 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] = 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(GlxPixmap)) - b += 4 - - return buf -} - // CreateNewContextCookie is a cookie used only for CreateNewContext requests. type CreateNewContextCookie struct { *xgb.Cookie @@ -2707,205 +1507,6 @@ func createNewContextRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Sc return buf } -// QueryContextCookie is a cookie used only for QueryContext requests. -type QueryContextCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryContext' 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} -} - -// QueryContextUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'QueryContext' 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} -} - -// 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 - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) -} - -// Reply blocks and returns the reply data for a QueryContext request. -func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryContextReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAttribs = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for 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] = 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(Context)) - b += 4 - - return buf -} - -// MakeContextCurrentCookie is a cookie used only for MakeContextCurrent requests. -type MakeContextCurrentCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeContextCurrent' 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} -} - -// MakeContextCurrentUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'MakeContextCurrent' 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} -} - -// 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 - ContextTag ContextTag - // padding: 20 bytes -} - -// 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 - } - if buf == nil { - return nil, nil - } - return makeContextCurrentReply(buf), nil -} - -// 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 - - 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 -} - -// 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] = 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(OldContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(ReadDrawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - // CreatePbufferCookie is a cookie used only for CreatePbuffer requests. type CreatePbufferCookie struct { *xgb.Cookie @@ -2976,210 +1577,65 @@ func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer return buf } -// DestroyPbufferCookie is a cookie used only for DestroyPbuffer requests. -type DestroyPbufferCookie struct { +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { *xgb.Cookie } -// DestroyPbuffer 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 DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { +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 'DestroyPbuffer' 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(destroyPbufferRequest(c, Pbuffer), cookie) - return DestroyPbufferCookie{cookie} + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{cookie} } -// DestroyPbufferChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyPbufferCookie.Check() -func DestroyPbufferChecked(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { +// 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 'DestroyPbuffer' 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(destroyPbufferRequest(c, Pbuffer), cookie) - return DestroyPbufferCookie{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 DestroyPbufferCookie) Check() error { +func (cook CreatePixmapCookie) Check() error { return cook.Cookie.Check() } -// 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 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] = 28 // 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(Pbuffer)) + xgb.Put32(buf[b:], Screen) b += 4 - return buf -} - -// GetDrawableAttributesCookie is a cookie used only for GetDrawableAttributes requests. -type GetDrawableAttributesCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetDrawableAttributes' 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} -} - -// 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 'GetDrawableAttributes' 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} -} - -// 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)) -} - -// Reply blocks and returns the reply data for a GetDrawableAttributes request. -func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDrawableAttributesReply(buf), nil -} - -// getDrawableAttributesReply reads a byte slice into a GetDrawableAttributesReply value. -func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { - v := new(GetDrawableAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Fbconfig)) b += 4 - v.NumAttribs = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], uint32(Pixmap)) b += 4 - b += 20 // padding - - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetDrawableAttributes -// getDrawableAttributesRequest writes a GetDrawableAttributes request to a byte slice. -func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 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(Drawable)) - b += 4 - - return buf -} - -// ChangeDrawableAttributesCookie is a cookie used only for ChangeDrawableAttributes requests. -type ChangeDrawableAttributesCookie 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 { - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for ChangeDrawableAttributes -// changeDrawableAttributesRequest writes a ChangeDrawableAttributes request to a byte slice. -func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 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(Drawable)) + xgb.Put32(buf[b:], uint32(GlxPixmap)) b += 4 xgb.Put32(buf[b:], NumAttribs) @@ -3267,6 +1723,195 @@ func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window x return buf } +// DeleteListsCookie is a cookie used only for DeleteLists requests. +type DeleteListsCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteLists' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} +} + +// Check returns an error if one occurred 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 DeleteLists +// deleteListsRequest writes a DeleteLists request to a byte slice. +func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], List) + b += 4 + + xgb.Put32(buf[b:], uint32(Range)) + b += 4 + + return buf +} + +// DeleteQueriesARBCookie is a cookie used only for DeleteQueriesARB requests. +type DeleteQueriesARBCookie struct { + *xgb.Cookie +} + +// DeleteQueriesARB 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteQueriesARB' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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(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 +} + +// DeleteTexturesCookie is a cookie used only for DeleteTextures requests. +type DeleteTexturesCookie struct { + *xgb.Cookie +} + +// DeleteTextures sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DeleteTextures(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} +} + +// DeleteTexturesChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteTexturesCookie.Check() +func DeleteTexturesChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DeleteTexturesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteTextures +// deleteTexturesRequest writes a DeleteTextures request to a byte slice. +func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 144 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + // DeleteWindowCookie is a cookie used only for DeleteWindow requests. type DeleteWindowCookie struct { *xgb.Cookie @@ -3322,129 +1967,50 @@ func deleteWindowRequest(c *xgb.Conn, Glxwindow Window) []byte { return buf } -// SetClientInfoARBCookie is a cookie used only for SetClientInfoARB requests. -type SetClientInfoARBCookie struct { +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { *xgb.Cookie } -// SetClientInfoARB 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 SetClientInfoARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { +func DestroyContext(c *xgb.Conn, Context Context) DestroyContextCookie { 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 'DestroyContext' 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} + c.NewRequest(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{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 { +// 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 'SetClientInfoARB' 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(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfoARBCookie{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 SetClientInfoARBCookie) Check() error { +func (cook DestroyContextCookie) Check() error { return cook.Cookie.Check() } -// 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 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) buf[b] = c.Extensions["GLX"] b += 1 - 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:], MajorVersion) - b += 4 - - 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 -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for CreateContextAttribsARB -// createContextAttribsARBRequest writes a CreateContextAttribsARB request to a byte slice. -func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { - size := xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 34 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3453,171 +2019,169 @@ func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbcon 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:], uint32(ShareList)) - b += 4 - - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - xgb.Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - xgb.Put32(buf[b:], Attribs[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// SetClientInfo2ARBCookie is a cookie used only for SetClientInfo2ARB requests. -type SetClientInfo2ARBCookie struct { +// DestroyGLXPixmapCookie is a cookie used only for DestroyGLXPixmap requests. +type DestroyGLXPixmapCookie struct { *xgb.Cookie } -// SetClientInfo2ARB 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 SetClientInfo2ARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { +func DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { 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 'DestroyGLXPixmap' 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} + c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{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 { +// 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 'SetClientInfo2ARB' 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(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return SetClientInfo2ARBCookie{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 SetClientInfo2ARBCookie) Check() error { +func (cook DestroyGLXPixmapCookie) Check() error { return cook.Cookie.Check() } -// 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)))) +// 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) buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 35 // 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:], MajorVersion) + xgb.Put32(buf[b:], uint32(GlxPixmap)) b += 4 - 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 } -// NewListCookie is a cookie used only for NewList requests. -type NewListCookie struct { +// DestroyPbufferCookie is a cookie used only for DestroyPbuffer requests. +type DestroyPbufferCookie struct { *xgb.Cookie } -// NewList 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 NewList(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { +func DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { 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 'DestroyPbuffer' 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} + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{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 { +// 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 'NewList' 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(newListRequest(c, ContextTag, List, Mode), cookie) - return NewListCookie{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 NewListCookie) Check() error { +func (cook DestroyPbufferCookie) Check() error { return cook.Cookie.Check() } -// 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 +// 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] = 101 // 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(ContextTag)) + xgb.Put32(buf[b:], uint32(Pbuffer)) b += 4 - xgb.Put32(buf[b:], List) - b += 4 + return buf +} - xgb.Put32(buf[b:], Mode) +// DestroyPixmapCookie is a cookie used only for DestroyPixmap requests. +type DestroyPixmapCookie struct { + *xgb.Cookie +} + +// 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.") + } + 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.") + } + 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() +} + +// 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] = 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(GlxPixmap)) b += 4 return buf @@ -3678,42 +2242,42 @@ func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } -// DeleteListsCookie is a cookie used only for DeleteLists requests. -type DeleteListsCookie struct { +// FeedbackBufferCookie is a cookie used only for FeedbackBuffer requests. +type FeedbackBufferCookie struct { *xgb.Cookie } -// DeleteLists 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 DeleteLists(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { +func FeedbackBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { 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 'FeedbackBuffer' 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} + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{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 { +// 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 'DeleteLists' 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(deleteListsRequest(c, ContextTag, List, Range), cookie) - return DeleteListsCookie{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 DeleteListsCookie) Check() error { +func (cook FeedbackBufferCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DeleteLists -// deleteListsRequest writes a DeleteLists request to a byte slice. -func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) []byte { +// Write request to wire for 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) @@ -3721,7 +2285,7 @@ func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range i buf[b] = c.Extensions["GLX"] b += 1 - buf[b] = 103 // request opcode + buf[b] = 105 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3730,10 +2294,149 @@ func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range i xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], List) + xgb.Put32(buf[b:], uint32(Size)) b += 4 - xgb.Put32(buf[b:], uint32(Range)) + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + return buf +} + +// FinishCookie is a cookie used only for Finish requests. +type FinishCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'Finish' 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} +} + +// FinishUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'Finish' 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} +} + +// 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 +} + +// 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 + } + if buf == nil { + return nil, nil + } + return finishReply(buf), nil +} + +// 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 + + 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 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 +} + +// 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 @@ -3830,479 +2533,44 @@ func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { return buf } -// FeedbackBufferCookie is a cookie used only for FeedbackBuffer requests. -type FeedbackBufferCookie struct { +// GenQueriesARBCookie is a cookie used only for GenQueriesARB requests. +type GenQueriesARBCookie 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 { +// 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 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) - return FeedbackBufferCookie{cookie} -} - -// FeedbackBufferChecked sends a checked request. -// If an error occurs, it can be retrieved using FeedbackBufferCookie.Check() -func FeedbackBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'FeedbackBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) - return FeedbackBufferCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FeedbackBufferCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FeedbackBuffer -// feedbackBufferRequest writes a FeedbackBuffer request to a byte slice. -func feedbackBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 105 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(Size)) - b += 4 - - xgb.Put32(buf[b:], uint32(Type)) - b += 4 - - return buf -} - -// SelectBufferCookie is a cookie used only for SelectBuffer requests. -type SelectBufferCookie struct { - *xgb.Cookie -} - -// 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} -} - -// SelectBufferChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectBufferCookie.Check() -func SelectBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'SelectBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) - return SelectBufferCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SelectBufferCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for 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] = 106 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(Size)) - b += 4 - - return buf -} - -// RenderModeCookie is a cookie used only for RenderMode requests. -type RenderModeCookie 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 { - 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 'GenQueriesARB' 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(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} } -// RenderModeUnchecked 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 RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { +func GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { 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 'GenQueriesARB' 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(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} } -// 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 - RetVal uint32 - N uint32 - NewMode uint32 - // padding: 12 bytes - Data []uint32 // size: xgb.Pad((int(N) * 4)) -} - -// 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 - } - if buf == nil { - return nil, nil - } - return renderModeReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = xgb.Get32(buf[b:]) - b += 4 - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.NewMode = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for 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] = 107 // request 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:], Mode) - b += 4 - - return buf -} - -// FinishCookie is a cookie used only for Finish requests. -type FinishCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Finish' 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} -} - -// FinishUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'Finish' 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} -} - -// 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 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return finishReply(buf), nil -} - -// 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 - - 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 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 - - xgb.Put32(buf[b:], Pname) - b += 4 - - xgb.Put32(buf[b:], uint32(Datum)) - b += 4 - - return buf -} - -// PixelStoreiCookie is a cookie used only for PixelStorei requests. -type PixelStoreiCookie struct { - *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} -} - -// 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} -} - -// Check returns an error if one occurred 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) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 110 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - xgb.Put32(buf[b:], uint32(Datum)) - b += 4 - - return buf -} - -// ReadPixelsCookie is a cookie used only for ReadPixels requests. -type ReadPixelsCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ReadPixels' 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} -} - -// ReadPixelsUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'ReadPixels' 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} -} - -// ReadPixelsReply represents the data returned from a ReadPixels request. -type ReadPixelsReply 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 // padding: 24 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) + Data []uint32 // size: xgb.Pad((int(Length) * 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 GenQueriesARB request. +func (cook GenQueriesARBCookie) Reply() (*GenQueriesARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -4310,12 +2578,12 @@ func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { if buf == nil { return nil, nil } - return readPixelsReply(buf), nil + return genQueriesARBReply(buf), nil } -// readPixelsReply reads a byte slice into a ReadPixelsReply value. -func readPixelsReply(buf []byte) *ReadPixelsReply { - v := new(ReadPixelsReply) +// 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 @@ -4328,24 +2596,27 @@ func readPixelsReply(buf []byte) *ReadPixelsReply { b += 24 // padding - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) + v.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 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 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] = 111 // request opcode + buf[b] = 162 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4354,38 +2625,107 @@ 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)) + xgb.Put32(buf[b:], uint32(N)) b += 4 - xgb.Put32(buf[b:], uint32(Y)) - b += 4 + return buf +} - xgb.Put32(buf[b:], uint32(Width)) - b += 4 +// GenTexturesCookie is a cookie used only for GenTextures requests. +type GenTexturesCookie struct { + *xgb.Cookie +} - xgb.Put32(buf[b:], uint32(Height)) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 +// 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 'GenTextures' 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} +} + +// GenTexturesUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GenTextures' 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} +} + +// 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: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// 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 + } + if buf == nil { + return nil, nil + } + return genTexturesReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// 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 - if LsbFirst { - buf[b] = 1 - } else { - buf[b] = 0 - } + buf[b] = 145 // request opcode b += 1 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + return buf } @@ -4604,6 +2944,793 @@ func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte return buf } +// GetColorTableCookie is a cookie used only for GetColorTable requests. +type GetColorTableCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetColorTable' 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} +} + +// 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 'GetColorTable' 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} +} + +// 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)) +} + +// Reply blocks and returns the reply data for a GetColorTable request. +func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableReply(buf), nil +} + +// getColorTableReply reads a byte slice into a GetColorTableReply value. +func getColorTableReply(buf []byte) *GetColorTableReply { + v := new(GetColorTableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetColorTable +// getColorTableRequest writes a GetColorTable request to a byte slice. +func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 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(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 +} + +// GetColorTableParameterfvCookie is a cookie used only for GetColorTableParameterfv requests. +type GetColorTableParameterfvCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetColorTableParameterfv' 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} +} + +// GetColorTableParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetColorTableParameterfv' 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} +} + +// GetColorTableParameterfvReply represents the data returned from a GetColorTableParameterfv request. +type GetColorTableParameterfvReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetColorTableParameterfv request. +func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterfvReply(buf), nil +} + +// 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 + + 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 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] = 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetColorTableParameterivCookie is a cookie used only for GetColorTableParameteriv requests. +type GetColorTableParameterivCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetColorTableParameteriv' 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} +} + +// GetColorTableParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetColorTableParameteriv' 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} +} + +// GetColorTableParameterivReply represents the data returned from a GetColorTableParameteriv request. +type GetColorTableParameterivReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetColorTableParameteriv request. +func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterivReply(buf), nil +} + +// 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 + + 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 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] = 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetCompressedTexImageARBCookie is a cookie used only for GetCompressedTexImageARB requests. +type GetCompressedTexImageARBCookie struct { + *xgb.Cookie +} + +// GetCompressedTexImageARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCompressedTexImageARBCookie.Reply() +func GetCompressedTexImageARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} +} + +// GetCompressedTexImageARBUnchecked sends an unchecked request. +// 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 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} +} + +// GetCompressedTexImageARBReply represents the data returned from a GetCompressedTexImageARB request. +type GetCompressedTexImageARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 8 bytes + Size int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// 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 +} + +// getCompressedTexImageARBReply reads a byte slice into a GetCompressedTexImageARBReply value. +func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { + v := new(GetCompressedTexImageARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Size = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// 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] = 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + return buf +} + +// GetConvolutionFilterCookie is a cookie used only for GetConvolutionFilter requests. +type GetConvolutionFilterCookie struct { + *xgb.Cookie +} + +// GetConvolutionFilter sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionFilterCookie.Reply() +func GetConvolutionFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} +} + +// GetConvolutionFilterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} +} + +// GetConvolutionFilterReply represents the data returned from a GetConvolutionFilter request. +type GetConvolutionFilterReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 8 bytes + Width int32 + Height int32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a GetConvolutionFilter request. +func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionFilterReply(buf), nil +} + +// getConvolutionFilterReply reads a byte slice into a GetConvolutionFilterReply value. +func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { + v := new(GetConvolutionFilterReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// 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] = 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(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 +} + +// GetConvolutionParameterfvCookie is a cookie used only for GetConvolutionParameterfv requests. +type GetConvolutionParameterfvCookie struct { + *xgb.Cookie +} + +// GetConvolutionParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterfvCookie.Reply() +func GetConvolutionParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetConvolutionParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{cookie} +} + +// GetConvolutionParameterfvUnchecked sends an unchecked request. +// 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 '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 + } + b = xgb.Pad(b) + + return v +} + +// 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] = 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetConvolutionParameterivCookie is a cookie used only for GetConvolutionParameteriv requests. +type GetConvolutionParameterivCookie struct { + *xgb.Cookie +} + +// GetConvolutionParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterivCookie.Reply() +func GetConvolutionParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} +} + +// GetConvolutionParameterivUnchecked sends an unchecked request. +// 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 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} +} + +// GetConvolutionParameterivReply represents the data returned from a GetConvolutionParameteriv request. +type GetConvolutionParameterivReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// 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 +} + +// getConvolutionParameterivReply reads a byte slice into a GetConvolutionParameterivReply value. +func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { + v := new(GetConvolutionParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// 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] = 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + // GetDoublevCookie is a cookie used only for GetDoublev requests. type GetDoublevCookie struct { *xgb.Cookie @@ -4713,6 +3840,105 @@ func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte return buf } +// GetDrawableAttributesCookie is a cookie used only for GetDrawableAttributes requests. +type GetDrawableAttributesCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetDrawableAttributes' 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} +} + +// 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 'GetDrawableAttributes' 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} +} + +// 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)) +} + +// Reply blocks and returns the reply data for a GetDrawableAttributes request. +func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDrawableAttributesReply(buf), nil +} + +// getDrawableAttributesReply reads a byte slice into a GetDrawableAttributesReply value. +func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { + v := new(GetDrawableAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAttribs = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDrawableAttributes +// getDrawableAttributesRequest writes a GetDrawableAttributes request to a byte slice. +func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 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(Drawable)) + b += 4 + + return buf +} + // GetErrorCookie is a cookie used only for GetError requests. type GetErrorCookie struct { *xgb.Cookie @@ -4801,6 +4027,109 @@ func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } +// GetFBConfigsCookie is a cookie used only for GetFBConfigs requests. +type GetFBConfigsCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetFBConfigs' 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} +} + +// 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 'GetFBConfigs' 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} +} + +// 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)) +} + +// 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 +} + +// getFBConfigsReply reads a byte slice into a GetFBConfigsReply value. +func getFBConfigsReply(buf []byte) *GetFBConfigsReply { + v := new(GetFBConfigsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + 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 + + 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 GetFBConfigs +// getFBConfigsRequest writes a GetFBConfigs request to a byte slice. +func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 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:], Screen) + b += 4 + + return buf +} + // GetFloatvCookie is a cookie used only for GetFloatv requests. type GetFloatvCookie struct { *xgb.Cookie @@ -4910,6 +4239,352 @@ func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { return buf } +// GetHistogramCookie is a cookie used only for GetHistogram requests. +type GetHistogramCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetHistogram' 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} +} + +// GetHistogramUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetHistogram' 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} +} + +// GetHistogramReply represents the data returned from a GetHistogram request. +type GetHistogramReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 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 GetHistogram request. +func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for 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] = 154 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// GetHistogramParameterfvCookie is a cookie used only for GetHistogramParameterfv requests. +type GetHistogramParameterfvCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetHistogramParameterfv' 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} +} + +// 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 'GetHistogramParameterfv' 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} +} + +// 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)) +} + +// 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 +} + +// getHistogramParameterfvReply reads a byte slice into a GetHistogramParameterfvReply value. +func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { + v := new(GetHistogramParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + 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 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] = 155 // request 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 +} + +// GetHistogramParameterivCookie is a cookie used only for GetHistogramParameteriv requests. +type GetHistogramParameterivCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetHistogramParameteriv' 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} +} + +// GetHistogramParameterivUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetHistogramParameteriv' 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} +} + +// GetHistogramParameterivReply represents the data returned from a GetHistogramParameteriv request. +type GetHistogramParameterivReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// 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 + } + if buf == nil { + return nil, nil + } + return getHistogramParameterivReply(buf), nil +} + +// 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 + + 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 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] = 156 // request 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 +} + // GetIntegervCookie is a cookie used only for GetIntegerv requests. type GetIntegervCookie struct { *xgb.Cookie @@ -5803,6 +5478,345 @@ func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname return buf } +// GetMinmaxCookie is a cookie used only for GetMinmax requests. +type GetMinmaxCookie struct { + *xgb.Cookie +} + +// GetMinmax sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxCookie.Reply() +func GetMinmax(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +// GetMinmaxUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMinmaxUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +// GetMinmaxReply represents the data returned from a GetMinmax request. +type GetMinmaxReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a GetMinmax request. +func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxReply(buf), nil +} + +// getMinmaxReply reads a byte slice into a GetMinmaxReply value. +func getMinmaxReply(buf []byte) *GetMinmaxReply { + v := new(GetMinmaxReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetMinmax +// getMinmaxRequest writes a GetMinmax request to a byte slice. +func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 157 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// GetMinmaxParameterfvCookie is a cookie used only for GetMinmaxParameterfv requests. +type GetMinmaxParameterfvCookie struct { + *xgb.Cookie +} + +// GetMinmaxParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterfvCookie.Reply() +func GetMinmaxParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +// GetMinmaxParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +// GetMinmaxParameterfvReply represents the data returned from a GetMinmaxParameterfv request. +type GetMinmaxParameterfvReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetMinmaxParameterfv request. +func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterfvReply(buf), nil +} + +// getMinmaxParameterfvReply reads a byte slice into a GetMinmaxParameterfvReply value. +func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { + v := new(GetMinmaxParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameterfv +// getMinmaxParameterfvRequest writes a GetMinmaxParameterfv request to a byte slice. +func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 158 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetMinmaxParameterivCookie is a cookie used only for GetMinmaxParameteriv requests. +type GetMinmaxParameterivCookie struct { + *xgb.Cookie +} + +// GetMinmaxParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterivCookie.Reply() +func GetMinmaxParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +// GetMinmaxParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +// GetMinmaxParameterivReply represents the data returned from a GetMinmaxParameteriv request. +type GetMinmaxParameterivReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetMinmaxParameteriv request. +func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterivReply(buf), nil +} + +// getMinmaxParameterivReply reads a byte slice into a GetMinmaxParameterivReply value. +func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { + v := new(GetMinmaxParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameteriv +// getMinmaxParameterivRequest writes a GetMinmaxParameteriv request to a byte slice. +func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 159 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + // GetPixelMapfvCookie is a cookie used only for GetPixelMapfv requests. type GetPixelMapfvCookie struct { *xgb.Cookie @@ -6229,6 +6243,461 @@ func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) return buf } +// GetQueryObjectivARBCookie is a cookie used only for GetQueryObjectivARB requests. +type GetQueryObjectivARBCookie struct { + *xgb.Cookie +} + +// GetQueryObjectivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryObjectivARBCookie.Reply() +func GetQueryObjectivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +// GetQueryObjectivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +// GetQueryObjectivARBReply represents the data returned from a GetQueryObjectivARB request. +type GetQueryObjectivARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetQueryObjectivARB request. +func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectivARBReply(buf), nil +} + +// getQueryObjectivARBReply reads a byte slice into a GetQueryObjectivARBReply value. +func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { + v := new(GetQueryObjectivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectivARB +// getQueryObjectivARBRequest writes a GetQueryObjectivARB request to a byte slice. +func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 165 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetQueryObjectuivARBCookie is a cookie used only for GetQueryObjectuivARB requests. +type GetQueryObjectuivARBCookie struct { + *xgb.Cookie +} + +// GetQueryObjectuivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryObjectuivARBCookie.Reply() +func GetQueryObjectuivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +// GetQueryObjectuivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryObjectuivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +// GetQueryObjectuivARBReply represents the data returned from a GetQueryObjectuivARB request. +type GetQueryObjectuivARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetQueryObjectuivARB request. +func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectuivARBReply(buf), nil +} + +// getQueryObjectuivARBReply reads a byte slice into a GetQueryObjectuivARBReply value. +func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { + v := new(GetQueryObjectuivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectuivARB +// getQueryObjectuivARBRequest writes a GetQueryObjectuivARB request to a byte slice. +func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 166 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetQueryivARBCookie is a cookie used only for GetQueryivARB requests. +type GetQueryivARBCookie struct { + *xgb.Cookie +} + +// GetQueryivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryivARBCookie.Reply() +func GetQueryivARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +// GetQueryivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetQueryivARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +// GetQueryivARBReply represents the data returned from a GetQueryivARB request. +type GetQueryivARBReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Reply blocks and returns the reply data for a GetQueryivARB request. +func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryivARBReply(buf), nil +} + +// getQueryivARBReply reads a byte slice into a GetQueryivARBReply value. +func getQueryivARBReply(buf []byte) *GetQueryivARBReply { + v := new(GetQueryivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryivARB +// getQueryivARBRequest writes a GetQueryivARB request to a byte slice. +func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 164 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// GetSeparableFilterCookie is a cookie used only for GetSeparableFilter requests. +type GetSeparableFilterCookie struct { + *xgb.Cookie +} + +// GetSeparableFilter sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSeparableFilterCookie.Reply() +func GetSeparableFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +// GetSeparableFilterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSeparableFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +// GetSeparableFilterReply represents the data returned from a GetSeparableFilter request. +type GetSeparableFilterReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 8 bytes + RowW int32 + ColH int32 + // padding: 8 bytes + RowsAndCols []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a GetSeparableFilter request. +func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSeparableFilterReply(buf), nil +} + +// getSeparableFilterReply reads a byte slice into a GetSeparableFilterReply value. +func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { + v := new(GetSeparableFilterReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.RowW = int32(xgb.Get32(buf[b:])) + b += 4 + + v.ColH = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + v.RowsAndCols = make([]byte, (int(v.Length) * 4)) + copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetSeparableFilter +// getSeparableFilterRequest writes a GetSeparableFilter request to a byte slice. +func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 153 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + // GetStringCookie is a cookie used only for GetString requests. type GetStringCookie struct { *xgb.Cookie @@ -7020,230 +7489,6 @@ func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetTexParameteriv' 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} -} - -// 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 'GetTexParameteriv' 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} -} - -// 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)) -} - -// 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] = 137 // request 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 -} - // GetTexLevelParameterfvCookie is a cookie used only for GetTexLevelParameterfv requests. type GetTexLevelParameterfvCookie struct { *xgb.Cookie @@ -7474,6 +7719,428 @@ func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target ui 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetTexParameteriv' 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} +} + +// 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 'GetTexParameteriv' 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} +} + +// 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)) +} + +// 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] = 137 // request 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 +} + +// GetVisualConfigsCookie is a cookie used only for GetVisualConfigs requests. +type GetVisualConfigsCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetVisualConfigs' 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} +} + +// GetVisualConfigsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'GetVisualConfigs' 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} +} + +// GetVisualConfigsReply represents the data returned from a GetVisualConfigs request. +type GetVisualConfigsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumVisuals uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Reply blocks and returns the reply data for a GetVisualConfigs request. +func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVisualConfigsReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + 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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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:], Screen) + b += 4 + + return buf +} + +// IsDirectCookie is a cookie used only for IsDirect requests. +type IsDirectCookie 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. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'IsDirect' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} +} + +// 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 +} + +// 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 + } + return isDirectReply(buf), nil +} + +// isDirectReply reads a byte slice into a IsDirectReply value. +func isDirectReply(buf []byte) *IsDirectReply { + v := new(IsDirectReply) + b := 1 // skip reply determinant + + b += 1 // padding + + 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 +} + +// 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] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + // IsListCookie is a cookie used only for IsList requests. type IsListCookie struct { *xgb.Cookie @@ -7565,2179 +8232,6 @@ func isListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32) []byte { 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 { - *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 { - 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} -} - -// 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} -} - -// 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)) -} - -// 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 -} - -// 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 - - v.Data = make([]bool, (int(v.Length) * 4)) - for i := 0; i < int((int(v.Length) * 4)); i++ { - if buf[b] == 1 { - v.Data[i] = true - } else { - v.Data[i] = false - } - b += 1 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for AreTexturesResident -// areTexturesResidentRequest writes a AreTexturesResident request to a byte slice. -func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 143 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Textures[i]) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// DeleteTexturesCookie is a cookie used only for DeleteTextures requests. -type DeleteTexturesCookie struct { - *xgb.Cookie -} - -// DeleteTextures sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteTextures(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) - return DeleteTexturesCookie{cookie} -} - -// DeleteTexturesChecked sends a checked request. -// If an error occurs, it can be retrieved using DeleteTexturesCookie.Check() -func DeleteTexturesChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteTextures' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) - return DeleteTexturesCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DeleteTexturesCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for DeleteTextures -// deleteTexturesRequest writes a DeleteTextures request to a byte slice. -func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 144 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - xgb.Put32(buf[b:], Textures[i]) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// GenTexturesCookie is a cookie used only for GenTextures requests. -type GenTexturesCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenTextures' 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} -} - -// GenTexturesUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenTextures' 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} -} - -// 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: 24 bytes - Data []uint32 // size: xgb.Pad((int(Length) * 4)) -} - -// 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 - } - if buf == nil { - return nil, nil - } - return genTexturesReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// 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] = 145 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(N)) - b += 4 - - return buf -} - -// IsTextureCookie is a cookie used only for IsTexture requests. -type IsTextureCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsTexture' 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} -} - -// IsTextureUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'IsTexture' 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} -} - -// 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 - RetVal Bool32 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return isTextureReply(buf), nil -} - -// 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 - - 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 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] = 146 // request 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) - b += 4 - - return buf -} - -// GetColorTableCookie is a cookie used only for GetColorTable requests. -type GetColorTableCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTable' 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} -} - -// 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 'GetColorTable' 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} -} - -// 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)) -} - -// Reply blocks and returns the reply data for a GetColorTable request. -func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getColorTableReply(buf), nil -} - -// getColorTableReply reads a byte slice into a GetColorTableReply value. -func getColorTableReply(buf []byte) *GetColorTableReply { - v := new(GetColorTableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v -} - -// Write request to wire for GetColorTable -// getColorTableRequest writes a GetColorTable request to a byte slice. -func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 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(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 -} - -// GetColorTableParameterfvCookie is a cookie used only for GetColorTableParameterfv requests. -type GetColorTableParameterfvCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameterfv' 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} -} - -// GetColorTableParameterfvUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameterfv' 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} -} - -// GetColorTableParameterfvReply represents the data returned from a GetColorTableParameterfv request. -type GetColorTableParameterfvReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) -} - -// Reply blocks and returns the reply data for a GetColorTableParameterfv request. -func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getColorTableParameterfvReply(buf), nil -} - -// 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 - - 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 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] = 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(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// GetColorTableParameterivCookie is a cookie used only for GetColorTableParameteriv requests. -type GetColorTableParameterivCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameteriv' 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} -} - -// GetColorTableParameterivUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetColorTableParameteriv' 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} -} - -// GetColorTableParameterivReply represents the data returned from a GetColorTableParameteriv request. -type GetColorTableParameterivReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) -} - -// Reply blocks and returns the reply data for a GetColorTableParameteriv request. -func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getColorTableParameterivReply(buf), nil -} - -// 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 - - 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 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] = 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(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// GetConvolutionFilterCookie is a cookie used only for GetConvolutionFilter requests. -type GetConvolutionFilterCookie struct { - *xgb.Cookie -} - -// GetConvolutionFilter sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetConvolutionFilterCookie.Reply() -func GetConvolutionFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetConvolutionFilterCookie{cookie} -} - -// GetConvolutionFilterUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetConvolutionFilterCookie{cookie} -} - -// GetConvolutionFilterReply represents the data returned from a GetConvolutionFilter request. -type GetConvolutionFilterReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 8 bytes - Width int32 - Height int32 - // padding: 8 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) -} - -// Reply blocks and returns the reply data for a GetConvolutionFilter request. -func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getConvolutionFilterReply(buf), nil -} - -// getConvolutionFilterReply reads a byte slice into a GetConvolutionFilterReply value. -func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { - v := new(GetConvolutionFilterReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Height = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 8 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v -} - -// 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] = 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(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 -} - -// GetConvolutionParameterfvCookie is a cookie used only for GetConvolutionParameterfv requests. -type GetConvolutionParameterfvCookie struct { - *xgb.Cookie -} - -// GetConvolutionParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterfvCookie.Reply() -func GetConvolutionParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterfvCookie{cookie} -} - -// GetConvolutionParameterfvUnchecked sends an unchecked request. -// 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 '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 - } - b = xgb.Pad(b) - - return v -} - -// 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] = 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(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// GetConvolutionParameterivCookie is a cookie used only for GetConvolutionParameteriv requests. -type GetConvolutionParameterivCookie struct { - *xgb.Cookie -} - -// GetConvolutionParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterivCookie.Reply() -func GetConvolutionParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterivCookie{cookie} -} - -// GetConvolutionParameterivUnchecked sends an unchecked request. -// 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 'GetConvolutionParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetConvolutionParameterivCookie{cookie} -} - -// GetConvolutionParameterivReply represents the data returned from a GetConvolutionParameteriv request. -type GetConvolutionParameterivReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) -} - -// 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 -} - -// getConvolutionParameterivReply reads a byte slice into a GetConvolutionParameterivReply value. -func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { - v := new(GetConvolutionParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// 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] = 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(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// GetSeparableFilterCookie is a cookie used only for GetSeparableFilter requests. -type GetSeparableFilterCookie struct { - *xgb.Cookie -} - -// GetSeparableFilter sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSeparableFilterCookie.Reply() -func GetSeparableFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetSeparableFilterCookie{cookie} -} - -// GetSeparableFilterUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSeparableFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetSeparableFilter' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) - return GetSeparableFilterCookie{cookie} -} - -// GetSeparableFilterReply represents the data returned from a GetSeparableFilter request. -type GetSeparableFilterReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 8 bytes - RowW int32 - ColH int32 - // padding: 8 bytes - RowsAndCols []byte // size: xgb.Pad(((int(Length) * 4) * 1)) -} - -// Reply blocks and returns the reply data for a GetSeparableFilter request. -func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSeparableFilterReply(buf), nil -} - -// getSeparableFilterReply reads a byte slice into a GetSeparableFilterReply value. -func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { - v := new(GetSeparableFilterReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.RowW = int32(xgb.Get32(buf[b:])) - b += 4 - - v.ColH = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 8 // padding - - v.RowsAndCols = make([]byte, (int(v.Length) * 4)) - copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v -} - -// Write request to wire for GetSeparableFilter -// getSeparableFilterRequest writes a GetSeparableFilter request to a byte slice. -func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 153 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// GetHistogramCookie is a cookie used only for GetHistogram requests. -type GetHistogramCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogram' 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} -} - -// GetHistogramUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogram' 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} -} - -// GetHistogramReply represents the data returned from a GetHistogram request. -type GetHistogramReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 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 GetHistogram request. -func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getHistogramReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v -} - -// Write request to wire for 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] = 154 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Reset { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// GetHistogramParameterfvCookie is a cookie used only for GetHistogramParameterfv requests. -type GetHistogramParameterfvCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogramParameterfv' 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} -} - -// 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 'GetHistogramParameterfv' 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} -} - -// 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)) -} - -// 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 -} - -// getHistogramParameterfvReply reads a byte slice into a GetHistogramParameterfvReply value. -func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { - v := new(GetHistogramParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - 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 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] = 155 // request 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 -} - -// GetHistogramParameterivCookie is a cookie used only for GetHistogramParameteriv requests. -type GetHistogramParameterivCookie 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogramParameteriv' 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} -} - -// GetHistogramParameterivUnchecked 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetHistogramParameteriv' 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} -} - -// GetHistogramParameterivReply represents the data returned from a GetHistogramParameteriv request. -type GetHistogramParameterivReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) -} - -// 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 - } - if buf == nil { - return nil, nil - } - return getHistogramParameterivReply(buf), nil -} - -// 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 - - 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 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] = 156 // request 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 -} - -// GetMinmaxCookie is a cookie used only for GetMinmax requests. -type GetMinmaxCookie struct { - *xgb.Cookie -} - -// GetMinmax sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMinmaxCookie.Reply() -func GetMinmax(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GetMinmaxCookie{cookie} -} - -// GetMinmaxUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMinmaxUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmax' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GetMinmaxCookie{cookie} -} - -// GetMinmaxReply represents the data returned from a GetMinmax request. -type GetMinmaxReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) -} - -// Reply blocks and returns the reply data for a GetMinmax request. -func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getMinmaxReply(buf), nil -} - -// getMinmaxReply reads a byte slice into a GetMinmaxReply value. -func getMinmaxReply(buf []byte) *GetMinmaxReply { - v := new(GetMinmaxReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v -} - -// Write request to wire for GetMinmax -// getMinmaxRequest writes a GetMinmax request to a byte slice. -func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 157 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Format) - b += 4 - - xgb.Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Reset { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// GetMinmaxParameterfvCookie is a cookie used only for GetMinmaxParameterfv requests. -type GetMinmaxParameterfvCookie struct { - *xgb.Cookie -} - -// GetMinmaxParameterfv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterfvCookie.Reply() -func GetMinmaxParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterfvCookie{cookie} -} - -// GetMinmaxParameterfvUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameterfv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterfvCookie{cookie} -} - -// GetMinmaxParameterfvReply represents the data returned from a GetMinmaxParameterfv request. -type GetMinmaxParameterfvReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum Float32 - // padding: 12 bytes - Data []Float32 // size: xgb.Pad((int(N) * 4)) -} - -// Reply blocks and returns the reply data for a GetMinmaxParameterfv request. -func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getMinmaxParameterfvReply(buf), nil -} - -// getMinmaxParameterfvReply reads a byte slice into a GetMinmaxParameterfvReply value. -func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { - v := new(GetMinmaxParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = Float32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]Float32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Float32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetMinmaxParameterfv -// getMinmaxParameterfvRequest writes a GetMinmaxParameterfv request to a byte slice. -func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 158 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// GetMinmaxParameterivCookie is a cookie used only for GetMinmaxParameteriv requests. -type GetMinmaxParameterivCookie struct { - *xgb.Cookie -} - -// GetMinmaxParameteriv sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterivCookie.Reply() -func GetMinmaxParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterivCookie{cookie} -} - -// GetMinmaxParameterivUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetMinmaxParameteriv' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) - return GetMinmaxParameterivCookie{cookie} -} - -// GetMinmaxParameterivReply represents the data returned from a GetMinmaxParameteriv request. -type GetMinmaxParameterivReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: xgb.Pad((int(N) * 4)) -} - -// Reply blocks and returns the reply data for a GetMinmaxParameteriv request. -func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getMinmaxParameterivReply(buf), nil -} - -// getMinmaxParameterivReply reads a byte slice into a GetMinmaxParameterivReply value. -func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { - v := new(GetMinmaxParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = xgb.Get32(buf[b:]) - b += 4 - - v.Datum = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetMinmaxParameteriv -// getMinmaxParameterivRequest writes a GetMinmaxParameteriv request to a byte slice. -func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["GLX"] - b += 1 - - buf[b] = 159 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// GetCompressedTexImageARBCookie is a cookie used only for GetCompressedTexImageARB requests. -type GetCompressedTexImageARBCookie struct { - *xgb.Cookie -} - -// GetCompressedTexImageARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCompressedTexImageARBCookie.Reply() -func GetCompressedTexImageARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) - return GetCompressedTexImageARBCookie{cookie} -} - -// GetCompressedTexImageARBUnchecked sends an unchecked request. -// 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 'GetCompressedTexImageARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) - return GetCompressedTexImageARBCookie{cookie} -} - -// GetCompressedTexImageARBReply represents the data returned from a GetCompressedTexImageARB request. -type GetCompressedTexImageARBReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 8 bytes - Size int32 - // padding: 12 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) -} - -// 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 -} - -// getCompressedTexImageARBReply reads a byte slice into a GetCompressedTexImageARBReply value. -func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { - v := new(GetCompressedTexImageARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Size = int32(xgb.Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v -} - -// 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] = 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(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], Target) - b += 4 - - xgb.Put32(buf[b:], uint32(Level)) - b += 4 - - return buf -} - -// DeleteQueriesARBCookie is a cookie used only for DeleteQueriesARB requests. -type DeleteQueriesARBCookie struct { - *xgb.Cookie -} - -// DeleteQueriesARB 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 { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'DeleteQueriesARB' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) - return DeleteQueriesARBCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 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(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 -} - -// GenQueriesARBCookie is a cookie used only for GenQueriesARB requests. -type GenQueriesARBCookie struct { - *xgb.Cookie -} - -// GenQueriesARB sends a checked request. -// If an error occurs, it will be returned with the reply by calling GenQueriesARBCookie.Reply() -func GenQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) - return GenQueriesARBCookie{cookie} -} - -// GenQueriesARBUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { - if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GenQueriesARB' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) - return GenQueriesARBCookie{cookie} -} - -// GenQueriesARBReply represents the data returned from a GenQueriesARB request. -type GenQueriesARBReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 24 bytes - Data []uint32 // size: xgb.Pad((int(Length) * 4)) -} - -// 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 -} - -// genQueriesARBReply reads a byte slice into a GenQueriesARBReply value. -func genQueriesARBReply(buf []byte) *GenQueriesARBReply { - v := new(GenQueriesARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// 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] = 162 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(ContextTag)) - b += 4 - - xgb.Put32(buf[b:], uint32(N)) - b += 4 - - return buf -} - // IsQueryARBCookie is a cookie used only for IsQueryARB requests. type IsQueryARBCookie struct { *xgb.Cookie @@ -9829,47 +8323,43 @@ func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { return buf } -// GetQueryivARBCookie is a cookie used only for GetQueryivARB requests. -type GetQueryivARBCookie struct { +// IsTextureCookie is a cookie used only for IsTexture requests. +type IsTextureCookie 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 { +// 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 'GetQueryivARB' 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(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) - return GetQueryivARBCookie{cookie} + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} } -// GetQueryivARBUnchecked 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 GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { +func IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { 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 'IsTexture' 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} + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} } -// GetQueryivARBReply represents the data returned from a GetQueryivARB request. -type GetQueryivARBReply 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 GetQueryivARB request. -func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, 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 @@ -9877,12 +8367,584 @@ func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { if buf == nil { return nil, nil } - return getQueryivARBReply(buf), nil + return isTextureReply(buf), nil } -// getQueryivARBReply reads a byte slice into a GetQueryivARBReply value. -func getQueryivARBReply(buf []byte) *GetQueryivARBReply { - v := new(GetQueryivARBReply) +// 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 + + 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 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] = 146 // request 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) + b += 4 + + return buf +} + +// MakeContextCurrentCookie is a cookie used only for MakeContextCurrent requests. +type MakeContextCurrentCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'MakeContextCurrent' 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} +} + +// MakeContextCurrentUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'MakeContextCurrent' 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} +} + +// 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 + ContextTag ContextTag + // padding: 20 bytes +} + +// 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 + } + if buf == nil { + return nil, nil + } + return makeContextCurrentReply(buf), nil +} + +// 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 + + 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 +} + +// 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] = 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(OldContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(ReadDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// MakeCurrentCookie is a cookie used only for MakeCurrent requests. +type MakeCurrentCookie 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. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'MakeCurrent' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} +} + +// 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 +} + +// 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 + } + return makeCurrentReply(buf), nil +} + +// makeCurrentReply reads a byte slice into a MakeCurrentReply value. +func makeCurrentReply(buf []byte) *MakeCurrentReply { + v := new(MakeCurrentReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextTag = ContextTag(xgb.Get32(buf[b:])) + b += 4 + + 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 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(OldContextTag)) + 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.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} +} + +// NewListChecked sends a checked request. +// If an error occurs, it can be retrieved using NewListCookie.Check() +func NewListChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'NewList' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook NewListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for NewList +// newListRequest writes a NewList request to a byte slice. +func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 101 // request 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 + + xgb.Put32(buf[b:], Mode) + 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 + + xgb.Put32(buf[b:], Pname) + b += 4 + + xgb.Put32(buf[b:], uint32(Datum)) + b += 4 + + return buf +} + +// PixelStoreiCookie is a cookie used only for PixelStorei requests. +type PixelStoreiCookie struct { + *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} +} + +// 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} +} + +// Check returns an error if one occurred 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) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 110 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + xgb.Put32(buf[b:], uint32(Datum)) + b += 4 + + return buf +} + +// QueryContextCookie is a cookie used only for QueryContext requests. +type QueryContextCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'QueryContext' 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} +} + +// QueryContextUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'QueryContext' 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} +} + +// 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 + NumAttribs uint32 + // padding: 20 bytes + Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) +} + +// Reply blocks and returns the reply data for a QueryContext request. +func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryContextReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAttribs = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for 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] = 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(Context)) + b += 4 + + return buf +} + +// QueryExtensionsStringCookie is a cookie used only for QueryExtensionsString requests. +type QueryExtensionsStringCookie struct { + *xgb.Cookie +} + +// QueryExtensionsString sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionsStringCookie.Reply() +func QueryExtensionsString(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} +} + +// QueryExtensionsStringUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'QueryExtensionsString' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} +} + +// QueryExtensionsStringReply represents the data returned from a QueryExtensionsString request. +type QueryExtensionsStringReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 4 bytes + N uint32 + // padding: 16 bytes +} + +// Reply blocks and returns the reply data for a QueryExtensionsString request. +func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionsStringReply(buf), nil +} + +// 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 @@ -9898,90 +8960,73 @@ func getQueryivARBReply(buf []byte) *GetQueryivARBReply { 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) + b += 16 // padding return v } -// Write request to wire for GetQueryivARB -// getQueryivARBRequest writes a GetQueryivARB request to a byte slice. -func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { - size := 16 +// 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] = 164 // 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:], Pname) + xgb.Put32(buf[b:], Screen) b += 4 return buf } -// GetQueryObjectivARBCookie is a cookie used only for GetQueryObjectivARB requests. -type GetQueryObjectivARBCookie struct { +// QueryServerStringCookie is a cookie used only for QueryServerString requests. +type QueryServerStringCookie 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 { +// 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 'GetQueryObjectivARB' 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(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) - return GetQueryObjectivARBCookie{cookie} + c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} } -// GetQueryObjectivARBUnchecked 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 GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { +func QueryServerStringUnchecked(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { 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 'QueryServerString' 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(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} } -// GetQueryObjectivARBReply represents the data returned from a GetQueryObjectivARB request. -type GetQueryObjectivARBReply 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 int32 - // padding: 12 bytes - Data []int32 // 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 GetQueryObjectivARB request. -func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, 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 @@ -9989,12 +9034,12 @@ func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) if buf == nil { return nil, nil } - return getQueryObjectivARBReply(buf), nil + return queryServerStringReply(buf), nil } -// getQueryObjectivARBReply reads a byte slice into a GetQueryObjectivARBReply value. -func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { - v := new(GetQueryObjectivARBReply) +// 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 @@ -10007,35 +9052,225 @@ func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { b += 4 // padding - v.N = xgb.Get32(buf[b:]) + v.StrLen = xgb.Get32(buf[b:]) b += 4 - v.Datum = int32(xgb.Get32(buf[b:])) - b += 4 + b += 16 // padding - 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 + { + 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 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 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] = 165 // 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:], Screen) + b += 4 + + xgb.Put32(buf[b:], Name) + b += 4 + + return buf +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'QueryVersion' 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} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'QueryVersion' 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} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + 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:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + +// ReadPixelsCookie is a cookie used only for ReadPixels requests. +type ReadPixelsCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'ReadPixels' 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} +} + +// ReadPixelsUnchecked 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'ReadPixels' 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} +} + +// 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 + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// 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 + } + if buf == nil { + return nil, nil + } + return readPixelsReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for 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] = 111 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -10044,56 +9279,207 @@ func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, P xgb.Put32(buf[b:], uint32(ContextTag)) b += 4 - xgb.Put32(buf[b:], Id) + xgb.Put32(buf[b:], uint32(X)) b += 4 - xgb.Put32(buf[b:], Pname) + xgb.Put32(buf[b:], uint32(Y)) b += 4 + xgb.Put32(buf[b:], uint32(Width)) + b += 4 + + xgb.Put32(buf[b:], uint32(Height)) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if LsbFirst { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + return buf } -// GetQueryObjectuivARBCookie is a cookie used only for GetQueryObjectuivARB requests. -type GetQueryObjectuivARBCookie struct { +// RenderCookie is a cookie used only for Render requests. +type RenderCookie 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 { +// Render sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Render(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { if _, ok := c.Extensions["GLX"]; !ok { - panic("Cannot issue request 'GetQueryObjectuivARB' 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, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'Render' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// RenderLargeCookie is a cookie used only for RenderLarge requests. +type RenderLargeCookie struct { + *xgb.Cookie +} + +// RenderLarge sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func RenderLarge(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'RenderLarge' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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(ContextTag)) + b += 4 + + xgb.Put16(buf[b:], RequestNum) + b += 2 + + 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 +} + +// RenderModeCookie is a cookie used only for RenderMode requests. +type RenderModeCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'RenderMode' 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} + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} } -// GetQueryObjectuivARBUnchecked 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 GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { +func RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { 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 'RenderMode' 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} + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} } -// GetQueryObjectuivARBReply represents the data returned from a GetQueryObjectuivARB request. -type GetQueryObjectuivARBReply struct { +// RenderModeReply represents the data returned from a RenderMode request. +type RenderModeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint32 + RetVal uint32 + N uint32 + NewMode uint32 // padding: 12 bytes Data []uint32 // size: xgb.Pad((int(N) * 4)) } -// Reply blocks and returns the reply data for a GetQueryObjectuivARB request. -func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, error) { +// 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 @@ -10101,12 +9487,12 @@ func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, erro if buf == nil { return nil, nil } - return getQueryObjectuivARBReply(buf), nil + return renderModeReply(buf), nil } -// getQueryObjectuivARBReply reads a byte slice into a GetQueryObjectuivARBReply value. -func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { - v := new(GetQueryObjectuivARBReply) +// 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 @@ -10117,12 +9503,13 @@ func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += 4 // padding + v.RetVal = xgb.Get32(buf[b:]) + b += 4 v.N = xgb.Get32(buf[b:]) b += 4 - v.Datum = xgb.Get32(buf[b:]) + v.NewMode = xgb.Get32(buf[b:]) b += 4 b += 12 // padding @@ -10137,17 +9524,17 @@ func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { return v } -// Write request to wire for GetQueryObjectuivARB -// getQueryObjectuivARBRequest writes a GetQueryObjectuivARB request to a byte slice. -func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { - size := 16 +// 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] = 166 // request opcode + buf[b] = 107 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -10156,10 +9543,623 @@ 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) + xgb.Put32(buf[b:], Mode) + b += 4 + + return buf +} + +// SelectBufferCookie is a cookie used only for SelectBuffer requests. +type SelectBufferCookie struct { + *xgb.Cookie +} + +// 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} +} + +// SelectBufferChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectBufferCookie.Check() +func SelectBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'SelectBuffer' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SelectBufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for 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] = 106 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Size)) + b += 4 + + return buf +} + +// SetClientInfo2ARBCookie is a cookie used only for SetClientInfo2ARB requests. +type SetClientInfo2ARBCookie 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'SetClientInfo2ARB' 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} +} + +// 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 'SetClientInfo2ARB' 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} +} + +// Check returns an error if one occurred 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() +} + +// Write request to wire for SetClientInfo2ARB +// setClientInfo2ARBRequest writes a SetClientInfo2ARB request to a byte slice. +func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { + size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 35 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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:], MajorVersion) + b += 4 + + 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 +} + +// SwapBuffersCookie is a cookie used only for SwapBuffers requests. +type SwapBuffersCookie struct { + *xgb.Cookie +} + +// SwapBuffers 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'SwapBuffers' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) + return SwapBuffersCookie{cookie} +} + +// Check returns an error if one occurred 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 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) + + buf[b] = c.Extensions["GLX"] + 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(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// UseXFontCookie is a cookie used only for UseXFont requests. +type UseXFontCookie struct { + *xgb.Cookie +} + +// 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 'UseXFont' 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} +} + +// 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 'UseXFont' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["GLX"] + 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(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 +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook VendorPrivateCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for VendorPrivate +// vendorPrivateRequest writes a VendorPrivate request to a byte slice. +func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 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:], VendorCode) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// VendorPrivateWithReplyCookie is a cookie used only for VendorPrivateWithReply requests. +type VendorPrivateWithReplyCookie struct { + *xgb.Cookie +} + +// VendorPrivateWithReply sends a checked request. +// If an error occurs, it will be returned with the reply by calling VendorPrivateWithReplyCookie.Reply() +func VendorPrivateWithReply(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} +} + +// VendorPrivateWithReplyUnchecked sends an unchecked request. +// 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 { + if _, ok := c.Extensions["GLX"]; !ok { + panic("Cannot issue request 'VendorPrivateWithReply' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} +} + +// VendorPrivateWithReplyReply represents the data returned from a VendorPrivateWithReply request. +type VendorPrivateWithReplyReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Retval uint32 + Data1 []byte // size: 24 + Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a VendorPrivateWithReply request. +func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return vendorPrivateWithReplyReply(buf), nil +} + +// vendorPrivateWithReplyReply reads a byte slice into a VendorPrivateWithReplyReply value. +func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { + v := new(VendorPrivateWithReplyReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Retval = xgb.Get32(buf[b:]) + b += 4 + + v.Data1 = make([]byte, 24) + copy(v.Data1[:24], buf[b:]) + b += xgb.Pad(int(24)) + + v.Data2 = make([]byte, (int(v.Length) * 4)) + copy(v.Data2[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// 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] = 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:], VendorCode) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// WaitGLCookie is a cookie used only for WaitGL requests. +type WaitGLCookie struct { + *xgb.Cookie +} + +// 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 'WaitGL' 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} +} + +// 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 'WaitGL' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["GLX"] + 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(ContextTag)) + b += 4 + + return buf +} + +// WaitXCookie is a cookie used only for WaitX requests. +type WaitXCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(waitXRequest(c, ContextTag), cookie) + return WaitXCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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(ContextTag)) 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,52 +41,277 @@ func init() { xgb.NewExtErrorFuncs["RANDR"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card16' +// BadBadCrtc is the error number for a BadBadCrtc. +const BadBadCrtc = 1 -// Skipping definition for base type 'Char' +type BadCrtcError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Card32' +// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice. +func BadCrtcErrorNew(buf []byte) xgb.Error { + v := BadCrtcError{} + v.NiceName = "BadCrtc" -// Skipping definition for base type 'Double' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Bool' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Float' + return v +} -// Skipping definition for base type 'Card8' +// SequenceId returns the sequence id attached to the BadBadCrtc error. +// This is mostly used internally. +func (err BadCrtcError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Int16' +// BadId returns the 'BadValue' number if one exists for the BadBadCrtc error. If no bad value exists, 0 is returned. +func (err BadCrtcError) BadId() uint32 { + return 0 +} -// Skipping definition for base type 'Int32' +// Error returns a rudimentary string representation of the BadBadCrtc error. -// Skipping definition for base type 'Void' +func (err BadCrtcError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadCrtc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Byte' +func init() { + xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew +} -// Skipping definition for base type 'Int8' +// BadBadMode is the error number for a BadBadMode. +const BadBadMode = 2 + +type BadModeError struct { + Sequence uint16 + NiceName string +} + +// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. +func BadModeErrorNew(buf []byte) xgb.Error { + v := BadModeError{} + v.NiceName = "BadMode" + + 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 BadBadMode error. +// This is mostly used internally. +func (err BadModeError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadMode error. If no bad value exists, 0 is returned. +func (err BadModeError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadMode error. + +func (err BadModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew +} + +// BadBadOutput is the error number for a BadBadOutput. +const BadBadOutput = 0 + +type BadOutputError struct { + Sequence uint16 + NiceName string +} + +// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. +func BadOutputErrorNew(buf []byte) xgb.Error { + v := BadOutputError{} + v.NiceName = "BadOutput" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadBadOutput error. +// This is mostly used internally. +func (err BadOutputError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadOutput error. If no bad value exists, 0 is returned. +func (err BadOutputError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadOutput error. + +func (err BadOutputError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadOutput {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew +} const ( - RotationRotate0 = 1 - RotationRotate90 = 2 - RotationRotate180 = 4 - RotationRotate270 = 8 - RotationReflectX = 16 - RotationReflectY = 32 + ConnectionConnected = 0 + ConnectionDisconnected = 1 + ConnectionUnknown = 2 ) -const ( - SetConfigSuccess = 0 - SetConfigInvalidConfigTime = 1 - SetConfigInvalidTime = 2 - SetConfigFailed = 3 -) +type Crtc uint32 -const ( - NotifyMaskScreenChange = 1 - NotifyMaskCrtcChange = 2 - NotifyMaskOutputChange = 4 - NotifyMaskOutputProperty = 8 -) +func NewCrtcId(c *xgb.Conn) (Crtc, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Crtc(id), nil +} + +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 + + 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 +} + +// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. +func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = CrtcChange{} + b += CrtcChangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a CrtcChange value to a byte slice. +func (v CrtcChange) 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 + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Mode uint32 + +func NewModeId(c *xgb.Conn) (Mode, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Mode(id), nil +} const ( ModeFlagHsyncPositive = 1 @@ -105,186 +330,6 @@ const ( ModeFlagHalveClock = 8192 ) -const ( - ConnectionConnected = 0 - ConnectionDisconnected = 1 - ConnectionUnknown = 2 -) - -const ( - NotifyCrtcChange = 0 - NotifyOutputChange = 1 - NotifyOutputProperty = 2 -) - -type Mode uint32 - -func NewModeId(c *xgb.Conn) (Mode, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Mode(id), nil -} - -type Crtc uint32 - -func NewCrtcId(c *xgb.Conn) (Crtc, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Crtc(id), nil -} - -type Output uint32 - -func NewOutputId(c *xgb.Conn) (Output, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Output(id), nil -} - -type ScreenSize struct { - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 -} - -// ScreenSizeRead reads a byte slice into a ScreenSize value. -func ScreenSizeRead(buf []byte, v *ScreenSize) int { - b := 0 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.Mwidth = xgb.Get16(buf[b:]) - b += 2 - - v.Mheight = xgb.Get16(buf[b:]) - b += 2 - - return b -} - -// ScreenSizeReadList reads a byte slice into a list of ScreenSize values. -func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ScreenSize{} - b += ScreenSizeRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a ScreenSize value to a byte slice. -func (v ScreenSize) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], v.Mwidth) - b += 2 - - xgb.Put16(buf[b:], v.Mheight) - b += 2 - - return buf -} - -// 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 -} - -type RefreshRates struct { - NRates uint16 - Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) -} - -// RefreshRatesRead reads a byte slice into a RefreshRates value. -func RefreshRatesRead(buf []byte, v *RefreshRates) int { - b := 0 - - v.NRates = 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) - - return b -} - -// RefreshRatesReadList reads a byte slice into a list of RefreshRates values. -func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RefreshRates{} - b += RefreshRatesRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a RefreshRates value to a byte slice. -func (v RefreshRates) Bytes() []byte { - buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) - b := 0 - - xgb.Put16(buf[b:], 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 -} - -// RefreshRatesListBytes writes a list of RefreshRates values to a byte slice. -func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { - b := 0 - var structBytes []byte - for _, item := range list { - 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 -} - type ModeInfo struct { Id uint32 Width uint16 @@ -416,114 +461,259 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int { return b } -type CrtcChange struct { - Timestamp xproto.Timestamp - Window xproto.Window - Crtc Crtc - Mode Mode - Rotation uint16 - // padding: 2 bytes - X int16 - Y int16 - Width uint16 - Height uint16 +// Notify is the event number for a NotifyEvent. +const Notify = 1 + +type NotifyEvent struct { + Sequence uint16 + SubCode byte + U NotifyDataUnion } -// CrtcChangeRead reads a byte slice into a CrtcChange value. -func CrtcChangeRead(buf []byte, v *CrtcChange) int { - b := 0 +// 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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + v.SubCode = buf[b] + b += 1 - 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:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - b += 2 // padding + v.U = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &v.U) - 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 + return v } -// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. -func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { +// Bytes writes a NotifyEvent value to a byte slice. +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = CrtcChange{} - b += CrtcChangeRead(buf[b:], &dest[i]) + + // 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 xgb.Pad(b) -} - -// Bytes writes a CrtcChange value to a byte slice. -func (v CrtcChange) 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 return buf } -// 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 { - structBytes = item.Bytes() +// 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 +} + +// 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 +} + +// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. +func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { + var b int + + b = 0 // re-read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // re-read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // re-read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return 28 +} + +// 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] = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a NotifyDataUnion value to a byte slice. +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v NotifyDataUnion) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + { + structBytes := v.Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return buf +} + +// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. +func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { + b := 0 + var unionBytes []byte + for _, item := range list { + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } return b } +const ( + NotifyMaskScreenChange = 1 + NotifyMaskCrtcChange = 2 + NotifyMaskOutputChange = 4 + NotifyMaskOutputProperty = 8 +) + +type Output uint32 + +func NewOutputId(c *xgb.Conn) (Output, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Output(id), nil +} + type OutputChange struct { Timestamp xproto.Timestamp ConfigTimestamp xproto.Timestamp @@ -707,168 +897,85 @@ func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { return b } -// NotifyDataUnion is a represention of the NotifyDataUnion union type. -// Note that to *create* a Union, you should *never* create -// this struct directly (unless you know what you're doing). -// Instead use one of the following constructors for 'NotifyDataUnion': -// NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion -// NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion -// NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion -type NotifyDataUnion struct { - Cc CrtcChange - Oc OutputChange - Op OutputProperty +type RefreshRates struct { + NRates uint16 + Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) } -// NotifyDataUnionCcNew constructs a new NotifyDataUnion union type with the Cc field. -func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion { - var b int - buf := make([]byte, 28) +// RefreshRatesRead reads a byte slice into a RefreshRates value. +func RefreshRatesRead(buf []byte, v *RefreshRates) int { + b := 0 - { - structBytes := Cc.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + v.NRates = 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) - // 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 + return b } -// 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 -} - -// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. -func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { - var b int - - b = 0 // re-read the same bytes - v.Cc = CrtcChange{} - b += CrtcChangeRead(buf[b:], &v.Cc) - - b = 0 // re-read the same bytes - v.Oc = OutputChange{} - b += OutputChangeRead(buf[b:], &v.Oc) - - b = 0 // re-read the same bytes - v.Op = OutputProperty{} - b += OutputPropertyRead(buf[b:], &v.Op) - - return 28 -} - -// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values. -func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { +// RefreshRatesReadList reads a byte slice into a list of RefreshRates values. +func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = NotifyDataUnion{} - b += NotifyDataUnionRead(buf[b:], &dest[i]) + dest[i] = RefreshRates{} + b += RefreshRatesRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a NotifyDataUnion value to a byte slice. -// Each field in a union must contain the same data. -// So simply pick the first field and write that to the wire. -func (v NotifyDataUnion) Bytes() []byte { - buf := make([]byte, 28) +// Bytes writes a RefreshRates value to a byte slice. +func (v RefreshRates) Bytes() []byte { + buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) b := 0 - { - structBytes := v.Cc.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + xgb.Put16(buf[b:], v.NRates) + b += 2 + + for i := 0; i < int(v.NRates); i++ { + xgb.Put16(buf[b:], v.Rates[i]) + b += 2 } + b = xgb.Pad(b) + return buf } -// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. -func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { +// RefreshRatesListBytes writes a list of RefreshRates values to a byte slice. +func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { b := 0 - var unionBytes []byte + var structBytes []byte for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } return b } +// RefreshRatesListSize computes the size (bytes) of a list of RefreshRates values. +func RefreshRatesListSize(list []RefreshRates) int { + size := 0 + for _, item := range list { + size += (2 + xgb.Pad((int(item.NRates) * 2))) + } + return size +} + +const ( + RotationRotate0 = 1 + RotationRotate90 = 2 + RotationRotate180 = 4 + RotationRotate270 = 8 + RotationReflectX = 16 + RotationReflectY = 32 +) + // ScreenChangeNotify is the event number for a ScreenChangeNotifyEvent. const ScreenChangeNotify = 0 @@ -1007,251 +1114,356 @@ func init() { xgb.NewExtEventFuncs["RANDR"][0] = ScreenChangeNotifyEventNew } -// Notify is the event number for a NotifyEvent. -const Notify = 1 - -type NotifyEvent struct { - Sequence uint16 - SubCode byte - U NotifyDataUnion +type ScreenSize struct { + Width uint16 + Height uint16 + Mwidth uint16 + Mheight uint16 } -// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. -func NotifyEventNew(buf []byte) xgb.Event { - v := NotifyEvent{} - b := 1 // don't read event number - - 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) +// ScreenSizeRead reads a byte slice into a ScreenSize value. +func ScreenSizeRead(buf []byte, v *ScreenSize) int { b := 0 - // write event number - buf[b] = 1 - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - buf[b] = v.SubCode - b += 1 + v.Height = xgb.Get16(buf[b:]) + b += 2 - b += 2 // skip sequence number + v.Mwidth = xgb.Get16(buf[b:]) + b += 2 - { - unionBytes := v.U.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) + v.Mheight = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// ScreenSizeReadList reads a byte slice into a list of ScreenSize values. +func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenSize{} + b += ScreenSizeRead(buf[b:], &dest[i]) } + return xgb.Pad(b) +} + +// Bytes writes a ScreenSize value to a byte slice. +func (v ScreenSize) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Mwidth) + b += 2 + + xgb.Put16(buf[b:], v.Mheight) + b += 2 return buf } -// SequenceId returns the sequence id attached to the Notify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v NotifyEvent) SequenceId() uint16 { - return v.Sequence +// ScreenSizeListBytes writes a list of ScreenSize values to a byte slice. +func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of NotifyEvent. -func (v NotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode)) - return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +const ( + SetConfigSuccess = 0 + SetConfigInvalidConfigTime = 1 + SetConfigInvalidTime = 2 + SetConfigFailed = 3 +) -func init() { - xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew -} +// Skipping definition for base type 'Bool' -// BadBadOutput is the error number for a BadBadOutput. -const BadBadOutput = 0 +// Skipping definition for base type 'Byte' -type BadOutputError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Card8' -// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. -func BadOutputErrorNew(buf []byte) xgb.Error { - v := BadOutputError{} - v.NiceName = "BadOutput" +// Skipping definition for base type 'Char' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Void' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Double' - return v -} +// Skipping definition for base type 'Float' -// SequenceId returns the sequence id attached to the BadBadOutput error. -// This is mostly used internally. -func (err BadOutputError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Int16' -// BadId returns the 'BadValue' number if one exists for the BadBadOutput error. If no bad value exists, 0 is returned. -func (err BadOutputError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Int32' -// Error returns a rudimentary string representation of the BadBadOutput error. +// Skipping definition for base type 'Int8' -func (err BadOutputError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadOutput {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Card16' -func init() { - xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew -} +// Skipping definition for base type 'Card32' -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadBadCrtc error. -// This is mostly used internally. -func (err BadCrtcError) SequenceId() uint16 { - return err.Sequence -} - -// 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 -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew -} - -// BadBadMode is the error number for a BadBadMode. -const BadBadMode = 2 - -type BadModeError struct { - Sequence uint16 - NiceName string -} - -// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. -func BadModeErrorNew(buf []byte) xgb.Error { - v := BadModeError{} - v.NiceName = "BadMode" - - 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 BadBadMode error. -// This is mostly used internally. -func (err BadModeError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadBadMode error. If no bad value exists, 0 is returned. -func (err BadModeError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadBadMode error. - -func (err BadModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew -} - -// 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 { +// AddOutputMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request '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, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} +} + +// Check returns an error if one occurred 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 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) + + buf[b] = c.Extensions["RANDR"] + 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 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + return buf +} + +// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. +type ChangeOutputPropertyCookie struct { + *xgb.Cookie +} + +// ChangeOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} +} + +// ChangeOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeOutputPropertyCookie.Check() +func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + buf[b] = Mode + b += 1 + + b += 2 // padding + + xgb.Put32(buf[b:], NumUnits) + b += 4 + + copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) + b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) + + return buf +} + +// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. +type ConfigureOutputPropertyCookie struct { + *xgb.Cookie +} + +// ConfigureOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} +} + +// ConfigureOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ConfigureOutputPropertyCookie.Check() +func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ConfigureOutputPropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ConfigureOutputProperty +// configureOutputPropertyRequest writes a ConfigureOutputProperty request to a byte slice. +func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + if Pending { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Range { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// CreateModeCookie is a cookie used only for CreateMode requests. +type CreateModeCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// CreateModeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// CreateModeReply represents the data returned from a CreateMode request. +type CreateModeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + Mode Mode + // padding: 20 bytes } -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { +// Reply blocks and returns the reply data for a CreateMode request. +func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1259,12 +1471,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return createModeReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// createModeReply reads a byte slice into a CreateModeReply value. +func createModeReply(buf []byte) *CreateModeReply { + v := new(CreateModeReply) b := 1 // skip reply determinant b += 1 // padding @@ -1275,20 +1487,81 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get32(buf[b:]) + v.Mode = Mode(xgb.Get32(buf[b:])) b += 4 - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding + b += 20 // padding return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { +// 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] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + { + 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 +} + +// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. +type DeleteOutputModeCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) @@ -1296,62 +1569,175 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 0 // 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:], 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 { +// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. +type DeleteOutputPropertyCookie 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 { +// 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 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + 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} +} + +// 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} +} + +// Check returns an error if one occurred 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 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] = 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(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// DestroyModeCookie is a cookie used only for DestroyMode requests. +type DestroyModeCookie struct { + *xgb.Cookie +} + +// DestroyMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{cookie} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(Mode)) + b += 4 + + return buf +} + +// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. +type GetCrtcGammaCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetCrtcGamma' 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} + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} } -// SetScreenConfigUnchecked 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 SetScreenConfigUnchecked(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { +func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { 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 'GetCrtcGamma' 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} + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{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 +// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. +type GetCrtcGammaReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Size uint16 + // padding: 22 bytes + Red []uint16 // size: xgb.Pad((int(Size) * 2)) + Green []uint16 // size: xgb.Pad((int(Size) * 2)) + Blue []uint16 // size: xgb.Pad((int(Size) * 2)) } -// Reply blocks and returns the reply data for a SetScreenConfig request. -func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, 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 @@ -1359,12 +1745,225 @@ func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) { if buf == nil { return nil, nil } - return setScreenConfigReply(buf), nil + return getCrtcGammaReply(buf), nil } -// setScreenConfigReply reads a byte slice into a SetScreenConfigReply value. -func setScreenConfigReply(buf []byte) *SetScreenConfigReply { - v := new(SetScreenConfigReply) +// 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 + + 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, 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 + } + 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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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(Crtc)) + b += 4 + + return buf +} + +// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. +type GetCrtcGammaSizeCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetCrtcGammaSize' 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} +} + +// GetCrtcGammaSizeUnchecked 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetCrtcGammaSize' 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} +} + +// 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 GetCrtcGammaSize request. +func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcGammaSizeReply(buf), nil +} + +// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. +func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { + v := new(GetCrtcGammaSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + 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 + + return v +} + +// Write request to wire for GetCrtcGammaSize +// getCrtcGammaSizeRequest writes a GetCrtcGammaSize request to a byte slice. +func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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(Crtc)) + b += 4 + + return buf +} + +// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. +type GetCrtcInfoCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetCrtcInfo' 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} +} + +// GetCrtcInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetCrtcInfo' 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} +} + +// 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 GetCrtcInfo request. +func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcInfoReply(buf), nil +} + +// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. +func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { + v := new(GetCrtcInfoReply) b := 1 // skip reply determinant v.Status = buf[b] @@ -1376,517 +1975,36 @@ func setScreenConfigReply(buf []byte) *SetScreenConfigReply { 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] = 2 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(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 -} - -// 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, Window xproto.Window, Enable uint16) SelectInputCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SelectInput' 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} -} - -// 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 'SelectInput' 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} -} - -// Check returns an error if one occurred 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, Window xproto.Window, Enable uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - 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(Window)) - b += 4 - - xgb.Put16(buf[b:], Enable) - b += 2 - - b += 2 // padding - - return buf -} - -// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. -type GetScreenInfoCookie struct { - *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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenInfo' 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} -} - -// 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 'GetScreenInfo' 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} -} - -// GetScreenInfoReply represents the data returned from a GetScreenInfo request. -type GetScreenInfoReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Rotations byte - Root xproto.Window - Timestamp xproto.Timestamp - ConfigTimestamp xproto.Timestamp - NSizes uint16 - SizeID uint16 - Rotation uint16 - Rate uint16 - NInfo uint16 - // padding: 2 bytes - Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) - Rates []RefreshRates // size: RefreshRatesListSize(Rates) -} - -// Reply blocks and returns the reply data for a 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 -} - -// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. -func getScreenInfoReply(buf []byte) *GetScreenInfoReply { - v := new(GetScreenInfoReply) - b := 1 // skip reply determinant - - v.Rotations = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mode = Mode(xgb.Get32(buf[b:])) b += 4 - v.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) - - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - 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(Window)) - b += 4 - - return buf -} - -// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. -type GetScreenSizeRangeCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenSizeRange' 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} -} - -// 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenSizeRange' 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 -} - -// 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 -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinWidth = xgb.Get16(buf[b:]) - b += 2 - - v.MinHeight = xgb.Get16(buf[b:]) - b += 2 - - v.MaxWidth = xgb.Get16(buf[b:]) - b += 2 - - v.MaxHeight = xgb.Get16(buf[b:]) - b += 2 - - b += 16 // padding - - return v -} - -// Write request to wire for GetScreenSizeRange -// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. -func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - 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(Window)) - b += 4 - - return buf -} - -// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. -type SetScreenSizeCookie struct { - *xgb.Cookie -} - -// SetScreenSize sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenSize' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) - return SetScreenSizeCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 7 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - 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 -} - -// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. -type GetScreenResourcesCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResources' 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} -} - -// GetScreenResourcesUnchecked 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResources' 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} -} - -// 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 GetScreenResources request. -func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getScreenResourcesReply(buf), nil -} - -// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. -func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { - v := new(GetScreenResourcesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - 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 - - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.NumCrtcs = xgb.Get16(buf[b:]) + v.Rotations = xgb.Get16(buf[b:]) b += 2 v.NumOutputs = xgb.Get16(buf[b:]) b += 2 - v.NumModes = xgb.Get16(buf[b:]) + v.NumPossibleOutputs = 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:])) @@ -1894,19 +2012,176 @@ func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { } 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.Possible = make([]Output, v.NumPossibleOutputs) + for i := 0; i < int(v.NumPossibleOutputs); i++ { + v.Possible[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for GetScreenResources -// getScreenResourcesRequest writes a GetScreenResources request to a byte slice. -func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetCrtcInfo +// getCrtcInfoRequest writes a GetCrtcInfo request to a byte slice. +func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + return buf +} + +// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. +type GetCrtcTransformCookie struct { + *xgb.Cookie +} + +// GetCrtcTransform sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcTransformCookie.Reply() +func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} +} + +// GetCrtcTransformUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} +} + +// GetCrtcTransformReply represents the data returned from a GetCrtcTransform request. +type GetCrtcTransformReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + PendingTransform render.Transform + HasTransforms bool + // padding: 3 bytes + CurrentTransform render.Transform + // padding: 4 bytes + PendingLen uint16 + PendingNparams uint16 + CurrentLen uint16 + CurrentNparams uint16 + PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1)) + PendingParams []render.Fixed // size: xgb.Pad((int(PendingNparams) * 4)) + CurrentFilterName string // size: xgb.Pad((int(CurrentLen) * 1)) + CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4)) +} + +// Reply blocks and returns the reply data for a GetCrtcTransform request. +func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcTransformReply(buf), nil +} + +// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. +func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { + v := new(GetCrtcTransformReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PendingTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.PendingTransform) + + if buf[b] == 1 { + v.HasTransforms = true + } else { + v.HasTransforms = false + } + b += 1 + + b += 3 // padding + + v.CurrentTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.CurrentTransform) + + b += 4 // padding + + v.PendingLen = xgb.Get16(buf[b:]) + b += 2 + + v.PendingNparams = xgb.Get16(buf[b:]) + b += 2 + + v.CurrentLen = xgb.Get16(buf[b:]) + b += 2 + + v.CurrentNparams = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.PendingLen) + copy(byteString[:v.PendingLen], buf[b:]) + v.PendingFilterName = string(byteString) + b += xgb.Pad(int(v.PendingLen)) + } + + v.PendingParams = make([]render.Fixed, v.PendingNparams) + for i := 0; i < int(v.PendingNparams); i++ { + v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + { + byteString := make([]byte, v.CurrentLen) + copy(byteString[:v.CurrentLen], buf[b:]) + v.CurrentFilterName = string(byteString) + b += xgb.Pad(int(v.CurrentLen)) + } + + v.CurrentParams = make([]render.Fixed, v.CurrentNparams) + for i := 0; i < int(v.CurrentNparams); i++ { + v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcTransform +// getCrtcTransformRequest writes a GetCrtcTransform request to a byte slice. +func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1914,13 +2189,13 @@ func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 27 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf @@ -2087,6 +2362,867 @@ func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Tim return buf } +// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. +type GetOutputPrimaryCookie 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. +// 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 'GetOutputPrimary' 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 +} + +// 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] = 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(Window)) + b += 4 + + return buf +} + +// GetOutputPropertyCookie is a cookie used only for GetOutputProperty requests. +type GetOutputPropertyCookie struct { + *xgb.Cookie +} + +// GetOutputProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOutputPropertyCookie.Reply() +func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} +} + +// GetOutputPropertyUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} +} + +// GetOutputPropertyReply represents the data returned from a GetOutputProperty request. +type GetOutputPropertyReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Format byte + Type xproto.Atom + BytesAfter uint32 + NumItems uint32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1)) +} + +// Reply blocks and returns the reply data for a GetOutputProperty request. +func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputPropertyReply(buf), nil +} + +// getOutputPropertyReply reads a byte slice into a GetOutputPropertyReply value. +func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { + v := new(GetOutputPropertyReply) + b := 1 // skip reply determinant + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Type = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 + + v.NumItems = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) + copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8)))) + + return v +} + +// Write request to wire for GetOutputProperty +// getOutputPropertyRequest writes a GetOutputProperty request to a byte slice. +func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 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(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + xgb.Put32(buf[b:], LongOffset) + b += 4 + + xgb.Put32(buf[b:], LongLength) + b += 4 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Pending { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + return buf +} + +// GetPanningCookie is a cookie used only for GetPanning requests. +type GetPanningCookie struct { + *xgb.Cookie +} + +// GetPanning sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPanningCookie.Reply() +func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} +} + +// GetPanningUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} +} + +// GetPanningReply represents the data returned from a GetPanning request. +type GetPanningReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte + Timestamp xproto.Timestamp + Left uint16 + Top uint16 + Width uint16 + Height uint16 + TrackLeft uint16 + TrackTop uint16 + TrackWidth uint16 + TrackHeight uint16 + BorderLeft int16 + BorderTop int16 + BorderRight int16 + BorderBottom int16 +} + +// Reply blocks and returns the reply data for a GetPanning request. +func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPanningReply(buf), nil +} + +// getPanningReply reads a byte slice into a GetPanningReply value. +func getPanningReply(buf []byte) *GetPanningReply { + v := new(GetPanningReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Left = xgb.Get16(buf[b:]) + b += 2 + + v.Top = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.TrackLeft = xgb.Get16(buf[b:]) + b += 2 + + v.TrackTop = xgb.Get16(buf[b:]) + b += 2 + + v.TrackWidth = xgb.Get16(buf[b:]) + b += 2 + + v.TrackHeight = xgb.Get16(buf[b:]) + b += 2 + + v.BorderLeft = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderTop = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderRight = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderBottom = int16(xgb.Get16(buf[b:])) + b += 2 + + return v +} + +// Write request to wire for GetPanning +// getPanningRequest writes a GetPanning request to a byte slice. +func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. +type GetScreenInfoCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetScreenInfo' 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} +} + +// 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 'GetScreenInfo' 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} +} + +// GetScreenInfoReply represents the data returned from a GetScreenInfo request. +type GetScreenInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Rotations byte + Root xproto.Window + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NSizes uint16 + SizeID uint16 + Rotation uint16 + Rate uint16 + NInfo uint16 + // padding: 2 bytes + Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) + Rates []RefreshRates // size: RefreshRatesListSize(Rates) +} + +// Reply blocks and returns the reply data for a 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 +} + +// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. +func getScreenInfoReply(buf []byte) *GetScreenInfoReply { + v := new(GetScreenInfoReply) + b := 1 // skip reply determinant + + v.Rotations = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NSizes = xgb.Get16(buf[b:]) + b += 2 + + v.SizeID = xgb.Get16(buf[b:]) + b += 2 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Rate = xgb.Get16(buf[b:]) + 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 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] = 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(Window)) + b += 4 + + return buf +} + +// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. +type GetScreenResourcesCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetScreenResources' 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} +} + +// GetScreenResourcesUnchecked 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetScreenResources' 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} +} + +// 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 GetScreenResources request. +func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenResourcesReply(buf), nil +} + +// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. +func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { + v := new(GetScreenResourcesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + 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 + + 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 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] = 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 + + return buf +} + +// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. +type GetScreenResourcesCurrentCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetScreenResourcesCurrent' 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} +} + +// GetScreenResourcesCurrentUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetScreenResourcesCurrent' 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} +} + +// 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 GetScreenResourcesCurrent request. +func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenResourcesCurrentReply(buf), nil +} + +// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. +func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { + v := new(GetScreenResourcesCurrentReply) + 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.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:]) + 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 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] = 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(Window)) + b += 4 + + return buf +} + +// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. +type GetScreenSizeRangeCookie 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetScreenSizeRange' 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} +} + +// 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 { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'GetScreenSizeRange' 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 +} + +// 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 +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MinHeight = xgb.Get16(buf[b:]) + b += 2 + + v.MaxWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MaxHeight = xgb.Get16(buf[b:]) + b += 2 + + b += 16 // padding + + return v +} + +// Write request to wire for GetScreenSizeRange +// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. +func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + 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(Window)) + b += 4 + + return buf +} + // ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. type ListOutputPropertiesCookie struct { *xgb.Cookie @@ -2308,390 +3444,45 @@ func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom return buf } -// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. -type ConfigureOutputPropertyCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie 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 { +// 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 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) - return ConfigureOutputPropertyCookie{cookie} -} - -// ConfigureOutputPropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using ConfigureOutputPropertyCookie.Check() -func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) - return ConfigureOutputPropertyCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ConfigureOutputPropertyCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ConfigureOutputProperty -// configureOutputPropertyRequest writes a ConfigureOutputProperty request to a byte slice. -func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Range { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - for i := 0; i < int(len(Values)); i++ { - xgb.Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. -type ChangeOutputPropertyCookie struct { - *xgb.Cookie -} - -// ChangeOutputProperty sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{cookie} -} - -// ChangeOutputPropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeOutputPropertyCookie.Check() -func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - xgb.Put32(buf[b:], uint32(Type)) - b += 4 - - buf[b] = Format - b += 1 - - buf[b] = Mode - b += 1 - - b += 2 // padding - - xgb.Put32(buf[b:], NumUnits) - b += 4 - - copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) - b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) - - return buf -} - -// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. -type DeleteOutputPropertyCookie 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 { - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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 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] = 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// GetOutputPropertyCookie is a cookie used only for GetOutputProperty requests. -type GetOutputPropertyCookie struct { - *xgb.Cookie -} - -// GetOutputProperty sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetOutputPropertyCookie.Reply() -func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return GetOutputPropertyCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetOutputPropertyUnchecked 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 GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return GetOutputPropertyCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetOutputPropertyReply represents the data returned from a GetOutputProperty request. -type GetOutputPropertyReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Format byte - Type xproto.Atom - BytesAfter uint32 - NumItems uint32 - // padding: 12 bytes - Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1)) -} - -// Reply blocks and returns the reply data for a GetOutputProperty request. -func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getOutputPropertyReply(buf), nil -} - -// getOutputPropertyReply reads a byte slice into a GetOutputPropertyReply value. -func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { - v := new(GetOutputPropertyReply) - b := 1 // skip reply determinant - - v.Format = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Type = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 - - v.BytesAfter = xgb.Get32(buf[b:]) - b += 4 - - v.NumItems = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) - copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) - b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8)))) - - return v -} - -// Write request to wire for GetOutputProperty -// getOutputPropertyRequest writes a GetOutputProperty request to a byte slice. -func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - b += 1 - - buf[b] = 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - xgb.Put32(buf[b:], uint32(Type)) - b += 4 - - xgb.Put32(buf[b:], LongOffset) - b += 4 - - xgb.Put32(buf[b:], LongLength) - b += 4 - - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - return buf -} - -// CreateModeCookie is a cookie used only for CreateMode requests. -type CreateModeCookie struct { - *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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'CreateMode' 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} -} - -// CreateModeUnchecked 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'CreateMode' 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} -} - -// CreateModeReply represents the data returned from a CreateMode request. -type CreateModeReply 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 - Mode Mode - // padding: 20 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes } -// 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 QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2699,12 +3490,12 @@ func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { if buf == nil { return nil, nil } - return createModeReply(buf), nil + return queryVersionReply(buf), nil } -// createModeReply reads a byte slice into a CreateModeReply value. -func createModeReply(buf []byte) *CreateModeReply { - v := new(CreateModeReply) +// 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 @@ -2715,25 +3506,86 @@ func createModeReply(buf []byte) *CreateModeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Mode = Mode(xgb.Get32(buf[b:])) + v.MajorVersion = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding return v } -// 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)))) +// 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] = 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:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + 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, Window xproto.Window, Enable uint16) SelectInputCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'SelectInput' 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} +} + +// 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 'SelectInput' 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} +} + +// Check returns an error if one occurred 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, Window xproto.Window, Enable uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2742,329 +3594,10 @@ func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Nam 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 -} - -// DestroyModeCookie is a cookie used only for DestroyMode requests. -type DestroyModeCookie struct { - *xgb.Cookie -} - -// DestroyMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyModeRequest(c, Mode), cookie) - return DestroyModeCookie{cookie} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 17 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Enable) b += 2 - xgb.Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// AddOutputModeCookie is a cookie used only for AddOutputMode requests. -type AddOutputModeCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) - return AddOutputModeCookie{cookie} -} - -// AddOutputModeChecked sends a checked request. -// If an error occurs, it can be retrieved using AddOutputModeCookie.Check() -func AddOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) - return AddOutputModeCookie{cookie} -} - -// Check returns an error if one occurred 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 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) - - buf[b] = c.Extensions["RANDR"] - 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 - - xgb.Put32(buf[b:], uint32(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. -type DeleteOutputModeCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["RANDR"] - 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(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. -type GetCrtcInfoCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcInfo' 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} -} - -// GetCrtcInfoUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcInfo' 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} -} - -// 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 GetCrtcInfo request. -func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCrtcInfoReply(buf), nil -} - -// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. -func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { - v := new(GetCrtcInfoReply) - 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 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.Mode = Mode(xgb.Get32(buf[b:])) - b += 4 - - v.Rotation = xgb.Get16(buf[b:]) - b += 2 - - v.Rotations = xgb.Get16(buf[b:]) - b += 2 - - v.NumOutputs = xgb.Get16(buf[b:]) - b += 2 - - v.NumPossibleOutputs = xgb.Get16(buf[b:]) - b += 2 - - v.Outputs = make([]Output, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Output(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - v.Possible = make([]Output, v.NumPossibleOutputs) - for i := 0; i < int(v.NumPossibleOutputs); i++ { - v.Possible[i] = Output(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetCrtcInfo -// getCrtcInfoRequest writes a GetCrtcInfo request to a byte slice. -func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Crtc)) - b += 4 - - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 + b += 2 // padding return buf } @@ -3187,212 +3720,6 @@ func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Co return buf } -// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. -type GetCrtcGammaSizeCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGammaSize' 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} -} - -// GetCrtcGammaSizeUnchecked 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGammaSize' 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} -} - -// 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 GetCrtcGammaSize request. -func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCrtcGammaSizeReply(buf), nil -} - -// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. -func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { - v := new(GetCrtcGammaSizeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - 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 - - return v -} - -// Write request to wire for GetCrtcGammaSize -// getCrtcGammaSizeRequest writes a GetCrtcGammaSize request to a byte slice. -func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - 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(Crtc)) - b += 4 - - return buf -} - -// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. -type GetCrtcGammaCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGamma' 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} -} - -// GetCrtcGammaUnchecked 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGamma' 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} -} - -// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. -type GetCrtcGammaReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Size uint16 - // padding: 22 bytes - Red []uint16 // size: xgb.Pad((int(Size) * 2)) - Green []uint16 // size: xgb.Pad((int(Size) * 2)) - Blue []uint16 // size: xgb.Pad((int(Size) * 2)) -} - -// Reply blocks and returns the reply data for a GetCrtcGamma request. -func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCrtcGammaReply(buf), nil -} - -// 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 - - 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, 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 - } - 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - 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(Crtc)) - b += 4 - - return buf -} - // SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests. type SetCrtcGammaCookie struct { *xgb.Cookie @@ -3471,142 +3798,6 @@ func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Gree return buf } -// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. -type GetScreenResourcesCurrentCookie 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResourcesCurrent' 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} -} - -// GetScreenResourcesCurrentUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResourcesCurrent' 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} -} - -// 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 GetScreenResourcesCurrent request. -func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getScreenResourcesCurrentReply(buf), nil -} - -// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. -func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { - v := new(GetScreenResourcesCurrentReply) - 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.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:]) - 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 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] = 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(Window)) - b += 4 - - return buf -} - // SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. type SetCrtcTransformCookie struct { *xgb.Cookie @@ -3682,292 +3873,59 @@ func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, return buf } -// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. -type GetCrtcTransformCookie struct { +// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. +type SetOutputPrimaryCookie struct { *xgb.Cookie } -// GetCrtcTransform sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCrtcTransformCookie.Reply() -func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} -} - -// GetCrtcTransformUnchecked sends an unchecked request. +// SetOutputPrimary sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { +func SetOutputPrimary(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{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)) +// 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} } -// Reply blocks and returns the reply data for a GetCrtcTransform request. -func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCrtcTransformReply(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 SetOutputPrimaryCookie) Check() error { + return cook.Cookie.Check() } -// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. -func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { - v := new(GetCrtcTransformReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.PendingTransform = render.Transform{} - b += render.TransformRead(buf[b:], &v.PendingTransform) - - if buf[b] == 1 { - v.HasTransforms = true - } else { - v.HasTransforms = false - } - b += 1 - - b += 3 // padding - - v.CurrentTransform = render.Transform{} - b += render.TransformRead(buf[b:], &v.CurrentTransform) - - b += 4 // padding - - v.PendingLen = xgb.Get16(buf[b:]) - b += 2 - - v.PendingNparams = xgb.Get16(buf[b:]) - b += 2 - - v.CurrentLen = xgb.Get16(buf[b:]) - b += 2 - - v.CurrentNparams = xgb.Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.PendingLen) - copy(byteString[:v.PendingLen], buf[b:]) - v.PendingFilterName = string(byteString) - b += xgb.Pad(int(v.PendingLen)) - } - - v.PendingParams = make([]render.Fixed, v.PendingNparams) - for i := 0; i < int(v.PendingNparams); i++ { - v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - { - byteString := make([]byte, v.CurrentLen) - copy(byteString[:v.CurrentLen], buf[b:]) - v.CurrentFilterName = string(byteString) - b += xgb.Pad(int(v.CurrentLen)) - } - - v.CurrentParams = make([]render.Fixed, v.CurrentNparams) - for i := 0; i < int(v.CurrentNparams); i++ { - v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetCrtcTransform -// getCrtcTransformRequest writes a GetCrtcTransform request to a byte slice. -func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { - size := 8 +// Write request to wire for SetOutputPrimary +// setOutputPrimaryRequest writes a SetOutputPrimary request to a byte slice. +func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 27 // request opcode + buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Crtc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - return buf -} - -// GetPanningCookie is a cookie used only for GetPanning requests. -type GetPanningCookie struct { - *xgb.Cookie -} - -// GetPanning sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPanningCookie.Reply() -func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getPanningRequest(c, Crtc), cookie) - return GetPanningCookie{cookie} -} - -// GetPanningUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getPanningRequest(c, Crtc), cookie) - return GetPanningCookie{cookie} -} - -// GetPanningReply represents the data returned from a GetPanning request. -type GetPanningReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte - Timestamp xproto.Timestamp - Left uint16 - Top uint16 - Width uint16 - Height uint16 - TrackLeft uint16 - TrackTop uint16 - TrackWidth uint16 - TrackHeight uint16 - BorderLeft int16 - BorderTop int16 - BorderRight int16 - BorderBottom int16 -} - -// Reply blocks and returns the reply data for a GetPanning request. -func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPanningReply(buf), nil -} - -// getPanningReply reads a byte slice into a GetPanningReply value. -func getPanningReply(buf []byte) *GetPanningReply { - v := new(GetPanningReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Left = xgb.Get16(buf[b:]) - b += 2 - - v.Top = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.TrackLeft = xgb.Get16(buf[b:]) - b += 2 - - v.TrackTop = xgb.Get16(buf[b:]) - b += 2 - - v.TrackWidth = xgb.Get16(buf[b:]) - b += 2 - - v.TrackHeight = xgb.Get16(buf[b:]) - b += 2 - - v.BorderLeft = int16(xgb.Get16(buf[b:])) - b += 2 - - v.BorderTop = int16(xgb.Get16(buf[b:])) - b += 2 - - v.BorderRight = int16(xgb.Get16(buf[b:])) - b += 2 - - v.BorderBottom = int16(xgb.Get16(buf[b:])) - b += 2 - - return v -} - -// Write request to wire for GetPanning -// getPanningRequest writes a GetPanning request to a byte slice. -func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RANDR"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Crtc)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 return buf @@ -4101,101 +4059,47 @@ 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) - return SetOutputPrimaryCookie{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 { - 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} -} - -// Check returns an error if one occurred 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 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] = 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(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Output)) - b += 4 - - return buf -} - -// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. -type GetOutputPrimaryCookie 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.") + panic("Cannot issue request 'SetScreenConfig' 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} + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{cookie} } -// GetOutputPrimaryUnchecked sends an unchecked request. +// SetScreenConfigUnchecked 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 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 'GetOutputPrimary' 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, true) - c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) - return GetOutputPrimaryCookie{cookie} + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{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 +// 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 } -// Reply blocks and returns the reply data for a GetOutputPrimary request. -func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { +// 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 @@ -4203,15 +4107,16 @@ func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { if buf == nil { return nil, nil } - return getOutputPrimaryReply(buf), nil + return setScreenConfigReply(buf), nil } -// getOutputPrimaryReply reads a byte slice into a GetOutputPrimaryReply value. -func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { - v := new(GetOutputPrimaryReply) +// setScreenConfigReply reads a byte slice into a SetScreenConfigReply value. +func setScreenConfigReply(buf []byte) *SetScreenConfigReply { + v := new(SetScreenConfigReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -4219,23 +4124,34 @@ func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Output = Output(xgb.Get32(buf[b:])) + 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 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 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] = 31 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4244,5 +4160,89 @@ func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + 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 +} + +// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. +type SetScreenSizeCookie struct { + *xgb.Cookie +} + +// SetScreenSize sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { + if _, ok := c.Extensions["RANDR"]; !ok { + panic("Cannot issue request 'SetScreenSize' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + 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,41 +40,127 @@ func init() { xgb.NewExtErrorFuncs["RECORD"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Float' +// BadBadContext is the error number for a BadBadContext. +const BadBadContext = 0 -// Skipping definition for base type 'Card8' +type BadContextError struct { + Sequence uint16 + NiceName string + InvalidRecord uint32 +} -// Skipping definition for base type 'Int16' +// 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 'Int32' + 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 'Byte' + v.InvalidRecord = xgb.Get32(buf[b:]) + b += 4 -// Skipping definition for base type 'Int8' + return v +} -// Skipping definition for base type 'Card16' +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Char' +// 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 +} -// Skipping definition for base type 'Card32' +// Error returns a rudimentary string representation of the BadBadContext error. -// Skipping definition for base type 'Double' +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, ", ") + "}" +} -// Skipping definition for base type 'Bool' +func init() { + xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +} -const ( - HTypeFromServerTime = 1 - HTypeFromClientTime = 2 - HTypeFromClientSequence = 4 -) +type ClientInfo struct { + ClientResource ClientSpec + NumRanges uint32 + Ranges []Range // size: xgb.Pad((int(NumRanges) * 24)) +} -const ( - CsCurrentClients = 1 - CsFutureClients = 2 - CsAllClients = 3 -) +// ClientInfoRead reads a byte slice into a ClientInfo value. +func ClientInfoRead(buf []byte, v *ClientInfo) int { + b := 0 + + v.ClientResource = ClientSpec(xgb.Get32(buf[b:])) + b += 4 + + v.NumRanges = xgb.Get32(buf[b:]) + b += 4 + + v.Ranges = make([]Range, v.NumRanges) + b += RangeReadList(buf[b:], v.Ranges) + + return b +} + +// 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] = ClientInfo{} + b += ClientInfoRead(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)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.ClientResource)) + b += 4 + + xgb.Put32(buf[b:], v.NumRanges) + b += 4 + + b += RangeListBytes(buf[b:], v.Ranges) + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + 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 ClientSpec uint32 type Context uint32 @@ -86,118 +172,14 @@ func NewContextId(c *xgb.Conn) (Context, error) { return Context(id), nil } +const ( + CsCurrentClients = 1 + CsFutureClients = 2 + CsAllClients = 3 +) + type ElementHeader byte -type ClientSpec uint32 - -type Range8 struct { - First byte - Last byte -} - -// Range8Read reads a byte slice into a Range8 value. -func Range8Read(buf []byte, v *Range8) int { - b := 0 - - v.First = buf[b] - b += 1 - - v.Last = buf[b] - b += 1 - - return b -} - -// 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) -} - -// Bytes writes a Range8 value to a byte slice. -func (v Range8) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.First - b += 1 - - buf[b] = v.Last - b += 1 - - return buf -} - -// 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 b -} - -type Range16 struct { - First uint16 - Last uint16 -} - -// 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 - - return b -} - -// 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]) - } - return xgb.Pad(b) -} - -// 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 -} - -// 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 ExtRange struct { Major Range8 Minor Range16 @@ -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.First = xgb.Get16(buf[b:]) + b += 2 - v.NumRanges = xgb.Get32(buf[b:]) - b += 4 - - 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.Put16(buf[b:], v.First) + b += 2 - xgb.Put32(buf[b:], v.NumRanges) - b += 4 - - 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,64 +440,493 @@ 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))) +type Range8 struct { + First byte + Last byte +} + +// Range8Read reads a byte slice into a Range8 value. +func Range8Read(buf []byte, v *Range8) int { + b := 0 + + v.First = buf[b] + b += 1 + + v.Last = buf[b] + b += 1 + + return b +} + +// 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 size + return xgb.Pad(b) } -// BadBadContext is the error number for a BadBadContext. -const BadBadContext = 0 +// Bytes writes a Range8 value to a byte slice. +func (v Range8) Bytes() []byte { + buf := make([]byte, 2) + b := 0 -type BadContextError struct { - Sequence uint16 - NiceName string - InvalidRecord uint32 + buf[b] = v.First + b += 1 + + buf[b] = v.Last + b += 1 + + return buf } -// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. -func BadContextErrorNew(buf []byte) xgb.Error { - v := BadContextError{} - v.NiceName = "BadContext" +// 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 b +} - b := 1 // skip error determinant - b += 1 // don't read error number +// 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, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), 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, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), 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, 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] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + 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 +} + +// DisableContextCookie is a cookie used only for DisableContext requests. +type DisableContextCookie struct { + *xgb.Cookie +} + +// DisableContext 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 { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'DisableContext' 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} +} + +// 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 'DisableContext' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + 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 v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.InvalidRecord = xgb.Get32(buf[b:]) + 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.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 } -// SequenceId returns the sequence id attached to the BadBadContext error. -// This is mostly used internally. -func (err BadContextError) SequenceId() uint16 { - return err.Sequence +// 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 } -// 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 +// FreeContextCookie is a cookie used only for FreeContext requests. +type FreeContextCookie struct { + *xgb.Cookie } -// Error returns a rudimentary string representation of the BadBadContext error. - -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, ", ") + "}" +// FreeContext 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 { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'FreeContext' 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} } -func init() { - xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +// 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 'FreeContext' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + return buf +} + +// GetContextCookie is a cookie used only for GetContext requests. +type GetContextCookie struct { + *xgb.Cookie +} + +// GetContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetContextCookie.Reply() +func GetContext(c *xgb.Conn, Context Context) GetContextCookie { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'GetContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getContextRequest(c, Context), cookie) + return GetContextCookie{cookie} +} + +// GetContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetContextUnchecked(c *xgb.Conn, Context Context) GetContextCookie { + if _, ok := c.Extensions["RECORD"]; !ok { + panic("Cannot issue request 'GetContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getContextRequest(c, Context), cookie) + return GetContextCookie{cookie} +} + +// GetContextReply represents the data returned from a GetContext request. +type GetContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Enabled bool + ElementHeader ElementHeader + // padding: 3 bytes + NumInterceptedClients uint32 + // padding: 16 bytes + InterceptedClients []ClientInfo // size: ClientInfoListSize(InterceptedClients) +} + +// Reply blocks and returns the reply data for a GetContext request. +func (cook GetContextCookie) Reply() (*GetContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getContextReply(buf), nil +} + +// getContextReply reads a byte slice into a GetContextReply value. +func getContextReply(buf []byte) *GetContextReply { + v := new(GetContextReply) + 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 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ElementHeader = ElementHeader(buf[b]) + b += 1 + + b += 3 // padding + + v.NumInterceptedClients = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.InterceptedClients = make([]ClientInfo, v.NumInterceptedClients) + b += ClientInfoReadList(buf[b:], v.InterceptedClients) + + return v +} + +// Write request to wire for GetContext +// getContextRequest writes a GetContext request to a byte slice. +func getContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + 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(Context)) + b += 4 + + return buf } // QueryVersionCookie is a cookie used only for QueryVersion requests. @@ -613,80 +1024,6 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) return buf } -// 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, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), 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, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), 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, 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] = 1 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Context)) - 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 -} - // RegisterClientsCookie is a cookie used only for RegisterClients requests. type RegisterClientsCookie struct { *xgb.Cookie @@ -824,340 +1161,3 @@ func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint3 return buf } - -// GetContextCookie is a cookie used only for GetContext requests. -type GetContextCookie struct { - *xgb.Cookie -} - -// GetContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetContextCookie.Reply() -func GetContext(c *xgb.Conn, Context Context) GetContextCookie { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'GetContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getContextRequest(c, Context), cookie) - return GetContextCookie{cookie} -} - -// GetContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetContextUnchecked(c *xgb.Conn, Context Context) GetContextCookie { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'GetContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getContextRequest(c, Context), cookie) - return GetContextCookie{cookie} -} - -// GetContextReply represents the data returned from a GetContext request. -type GetContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Enabled bool - ElementHeader ElementHeader - // padding: 3 bytes - NumInterceptedClients uint32 - // padding: 16 bytes - InterceptedClients []ClientInfo // size: ClientInfoListSize(InterceptedClients) -} - -// Reply blocks and returns the reply data for a GetContext request. -func (cook GetContextCookie) Reply() (*GetContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getContextReply(buf), nil -} - -// getContextReply reads a byte slice into a GetContextReply value. -func getContextReply(buf []byte) *GetContextReply { - v := new(GetContextReply) - 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 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.ElementHeader = ElementHeader(buf[b]) - b += 1 - - b += 3 // padding - - v.NumInterceptedClients = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.InterceptedClients = make([]ClientInfo, v.NumInterceptedClients) - b += ClientInfoReadList(buf[b:], v.InterceptedClients) - - return v -} - -// Write request to wire for GetContext -// getContextRequest writes a GetContext request to a byte slice. -func getContextRequest(c *xgb.Conn, Context Context) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RECORD"] - 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(Context)) - b += 4 - - 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - 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.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 -} - -// DisableContextCookie is a cookie used only for DisableContext requests. -type DisableContextCookie struct { - *xgb.Cookie -} - -// DisableContext 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 { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'DisableContext' 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} -} - -// 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 'DisableContext' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RECORD"] - 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(Context)) - b += 4 - - return buf -} - -// FreeContextCookie is a cookie used only for FreeContext requests. -type FreeContextCookie struct { - *xgb.Cookie -} - -// FreeContext 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 { - if _, ok := c.Extensions["RECORD"]; !ok { - panic("Cannot issue request 'FreeContext' 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} -} - -// 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 'FreeContext' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RECORD"] - 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(Context)) - b += 4 - - 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,690 +274,100 @@ func DirectformatListBytes(buf []byte, list []Directformat) int { return b } -type Pictforminfo struct { - Id Pictformat - Type byte - Depth byte - // padding: 2 bytes - Direct Directformat - Colormap xproto.Colormap +type Fixed int32 + +type Glyph uint32 + +// BadGlyph is the error number for a BadGlyph. +const BadGlyph = 4 + +type GlyphError struct { + Sequence uint16 + NiceName string } -// PictforminfoRead reads a byte slice into a Pictforminfo value. -func PictforminfoRead(buf []byte, v *Pictforminfo) int { - b := 0 +// 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.Id = Pictformat(xgb.Get32(buf[b:])) - b += 4 + b := 1 // skip error determinant + b += 1 // don't read error number - v.Type = buf[b] - b += 1 - - v.Depth = buf[b] - b += 1 - - b += 2 // padding - - v.Direct = Directformat{} - b += DirectformatRead(buf[b:], &v.Direct) - - v.Colormap = xproto.Colormap(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// PictforminfoReadList reads a byte slice into a list of Pictforminfo values. -func PictforminfoReadList(buf []byte, dest []Pictforminfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Pictforminfo{} - b += PictforminfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Pictforminfo value to a byte slice. -func (v Pictforminfo) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Id)) - b += 4 - - buf[b] = v.Type - b += 1 - - buf[b] = v.Depth - b += 1 - - b += 2 // padding - - { - structBytes := v.Direct.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(v.Colormap)) - b += 4 - - return buf -} - -// PictforminfoListBytes writes a list of Pictforminfo values to a byte slice. -func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type 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 -} - -// 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 -} - -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:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - b += 4 // padding - - v.Visuals = make([]Pictvisual, v.NumVisuals) - b += PictvisualReadList(buf[b:], v.Visuals) - - return b + return v } -// 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) +// 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 Pictdepth value to a byte slice. -func (v Pictdepth) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8)))) - b := 0 +// 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 +} - buf[b] = v.Depth - b += 1 +// Error returns a rudimentary string representation of the BadGlyph error. - b += 1 // padding +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, ", ") + "}" +} - xgb.Put16(buf[b:], v.NumVisuals) +func init() { + xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew +} + +// BadGlyphSet is the error number for a BadGlyphSet. +const BadGlyphSet = 3 + +type GlyphSetError struct { + Sequence uint16 + NiceName string +} + +// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice. +func GlyphSetErrorNew(buf []byte) xgb.Error { + v := GlyphSetError{} + v.NiceName = "GlyphSet" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - b += 4 // padding - - b += PictvisualListBytes(buf[b:], v.Visuals) - - return buf + return v } -// 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 +// SequenceId returns the sequence id attached to the BadGlyphSet error. +// This is mostly used internally. +func (err GlyphSetError) SequenceId() uint16 { + return err.Sequence } -// 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 +// 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 } -type Pictscreen struct { - NumDepths uint32 - Fallback Pictformat - Depths []Pictdepth // size: PictdepthListSize(Depths) +// 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, ", ") + "}" } -// 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 Indexvalue struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 -} - -// IndexvalueRead reads a byte slice into a Indexvalue value. -func IndexvalueRead(buf []byte, v *Indexvalue) int { - b := 0 - - v.Pixel = xgb.Get32(buf[b:]) - b += 4 - - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 - - v.Blue = xgb.Get16(buf[b:]) - b += 2 - - v.Alpha = xgb.Get16(buf[b:]) - b += 2 - - return b -} - -// IndexvalueReadList reads a byte slice into a list of Indexvalue values. -func IndexvalueReadList(buf []byte, dest []Indexvalue) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Indexvalue{} - b += IndexvalueRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Indexvalue value to a byte slice. -func (v Indexvalue) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - xgb.Put32(buf[b:], v.Pixel) - b += 4 - - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 - - xgb.Put16(buf[b:], v.Blue) - b += 2 - - xgb.Put16(buf[b:], v.Alpha) - b += 2 - - return buf -} - -// IndexvalueListBytes writes a list of Indexvalue values to a byte slice. -func IndexvalueListBytes(buf []byte, list []Indexvalue) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -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 -} - -// LinefixRead reads a byte slice into a Linefix value. -func LinefixRead(buf []byte, v *Linefix) int { - b := 0 - - v.P1 = Pointfix{} - b += PointfixRead(buf[b:], &v.P1) - - v.P2 = Pointfix{} - b += PointfixRead(buf[b:], &v.P2) - - return b -} - -// LinefixReadList reads a byte slice into a list of Linefix values. -func LinefixReadList(buf []byte, dest []Linefix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Linefix{} - b += LinefixRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Linefix value to a byte slice. -func (v Linefix) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - return buf -} - -// LinefixListBytes writes a list of Linefix values to a byte slice. -func LinefixListBytes(buf []byte, list []Linefix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Triangle struct { - P1 Pointfix - P2 Pointfix - P3 Pointfix -} - -// TriangleRead reads a byte slice into a Triangle value. -func TriangleRead(buf []byte, v *Triangle) int { - b := 0 - - v.P1 = Pointfix{} - b += PointfixRead(buf[b:], &v.P1) - - v.P2 = Pointfix{} - b += PointfixRead(buf[b:], &v.P2) - - v.P3 = Pointfix{} - b += PointfixRead(buf[b:], &v.P3) - - return b -} - -// TriangleReadList reads a byte slice into a list of Triangle values. -func TriangleReadList(buf []byte, dest []Triangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Triangle{} - b += TriangleRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Triangle value to a byte slice. -func (v Triangle) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.P3.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - return buf -} - -// TriangleListBytes writes a list of Triangle values to a byte slice. -func TriangleListBytes(buf []byte, list []Triangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Trapezoid struct { - Top Fixed - Bottom Fixed - Left Linefix - Right Linefix -} - -// TrapezoidRead reads a byte slice into a Trapezoid value. -func TrapezoidRead(buf []byte, v *Trapezoid) int { - b := 0 - - v.Top = Fixed(xgb.Get32(buf[b:])) - b += 4 - - v.Bottom = 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 { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Trapezoid{} - b += TrapezoidRead(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) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Top)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Bottom)) - 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 { - 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 Glyphinfo struct { @@ -1069,6 +452,800 @@ func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { return b } +type Glyphset uint32 + +func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Glyphset(id), nil +} + +type Indexvalue struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} + +// IndexvalueRead reads a byte slice into a Indexvalue value. +func IndexvalueRead(buf []byte, v *Indexvalue) int { + b := 0 + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Alpha = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// IndexvalueReadList reads a byte slice into a list of Indexvalue values. +func IndexvalueReadList(buf []byte, dest []Indexvalue) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Indexvalue{} + b += IndexvalueRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Indexvalue value to a byte slice. +func (v Indexvalue) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Pixel) + b += 4 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + xgb.Put16(buf[b:], v.Alpha) + b += 2 + + return buf +} + +// IndexvalueListBytes writes a list of Indexvalue values to a byte slice. +func IndexvalueListBytes(buf []byte, list []Indexvalue) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Linefix struct { + P1 Pointfix + P2 Pointfix +} + +// LinefixRead reads a byte slice into a Linefix value. +func LinefixRead(buf []byte, v *Linefix) int { + b := 0 + + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) + + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) + + return b +} + +// LinefixReadList reads a byte slice into a list of Linefix values. +func LinefixReadList(buf []byte, dest []Linefix) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Linefix{} + b += LinefixRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Linefix value to a byte slice. +func (v Linefix) Bytes() []byte { + buf := make([]byte, 16) + b := 0 + + { + structBytes := v.P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// LinefixListBytes writes a list of Linefix values to a byte slice. +func LinefixListBytes(buf []byte, list []Linefix) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// BadPictFormat is the error number for a BadPictFormat. +const BadPictFormat = 0 + +type PictFormatError struct { + Sequence uint16 + NiceName string +} + +// PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice. +func PictFormatErrorNew(buf []byte) xgb.Error { + v := PictFormatError{} + v.NiceName = "PictFormat" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadPictFormat error. +// This is mostly used internally. +func (err PictFormatError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadPictFormat error. If no bad value exists, 0 is returned. +func (err PictFormatError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadPictFormat error. + +func (err PictFormatError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictFormat {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew +} + +// BadPictOp is the error number for a BadPictOp. +const BadPictOp = 2 + +type PictOpError struct { + Sequence uint16 + NiceName string +} + +// PictOpErrorNew constructs a PictOpError value that implements xgb.Error from a byte slice. +func PictOpErrorNew(buf []byte) xgb.Error { + v := PictOpError{} + v.NiceName = "PictOp" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadPictOp error. +// This is mostly used internally. +func (err PictOpError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadPictOp error. If no bad value exists, 0 is returned. +func (err PictOpError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadPictOp error. + +func (err PictOpError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew +} + +const ( + PictOpClear = 0 + PictOpSrc = 1 + PictOpDst = 2 + PictOpOver = 3 + PictOpOverReverse = 4 + PictOpIn = 5 + PictOpInReverse = 6 + PictOpOut = 7 + PictOpOutReverse = 8 + PictOpAtop = 9 + PictOpAtopReverse = 10 + PictOpXor = 11 + PictOpAdd = 12 + PictOpSaturate = 13 + PictOpDisjointClear = 16 + PictOpDisjointSrc = 17 + PictOpDisjointDst = 18 + PictOpDisjointOver = 19 + PictOpDisjointOverReverse = 20 + PictOpDisjointIn = 21 + PictOpDisjointInReverse = 22 + PictOpDisjointOut = 23 + PictOpDisjointOutReverse = 24 + PictOpDisjointAtop = 25 + PictOpDisjointAtopReverse = 26 + PictOpDisjointXor = 27 + PictOpConjointClear = 32 + PictOpConjointSrc = 33 + PictOpConjointDst = 34 + PictOpConjointOver = 35 + PictOpConjointOverReverse = 36 + PictOpConjointIn = 37 + PictOpConjointInReverse = 38 + PictOpConjointOut = 39 + PictOpConjointOutReverse = 40 + PictOpConjointAtop = 41 + PictOpConjointAtopReverse = 42 + PictOpConjointXor = 43 + PictOpMultiply = 48 + PictOpScreen = 49 + PictOpOverlay = 50 + PictOpDarken = 51 + PictOpLighten = 52 + PictOpColorDodge = 53 + PictOpColorBurn = 54 + PictOpHardLight = 55 + PictOpSoftLight = 56 + PictOpDifference = 57 + PictOpExclusion = 58 + PictOpHSLHue = 59 + PictOpHSLSaturation = 60 + PictOpHSLColor = 61 + PictOpHSLLuminosity = 62 +) + +const ( + PictTypeIndexed = 0 + PictTypeDirect = 1 +) + +type Pictdepth struct { + Depth byte + // padding: 1 bytes + 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.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 +} + +// 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 +} + +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 +} + +const ( + PolyEdgeSharp = 0 + PolyEdgeSmooth = 1 +) + +const ( + PolyModePrecise = 0 + PolyModeImprecise = 1 +) + +const ( + RepeatNone = 0 + RepeatNormal = 1 + RepeatPad = 2 + RepeatReflect = 3 +) + +type Spanfix struct { + L Fixed + R Fixed + Y Fixed +} + +// SpanfixRead reads a byte slice into a Spanfix value. +func SpanfixRead(buf []byte, v *Spanfix) int { + b := 0 + + v.L = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.R = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Y = Fixed(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// 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] = Spanfix{} + b += SpanfixRead(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) + b := 0 + + xgb.Put32(buf[b:], uint32(v.L)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.R)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Y)) + b += 4 + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + SubPixelUnknown = 0 + SubPixelHorizontalRGB = 1 + SubPixelHorizontalBGR = 2 + SubPixelVerticalRGB = 3 + SubPixelVerticalBGR = 4 + SubPixelNone = 5 +) + type Transform struct { Matrix11 Fixed Matrix12 Fixed @@ -1172,121 +1349,6 @@ func TransformListBytes(buf []byte, list []Transform) int { return b } -type Animcursorelt struct { - Cursor xproto.Cursor - Delay uint32 -} - -// AnimcursoreltRead reads a byte slice into a Animcursorelt value. -func AnimcursoreltRead(buf []byte, v *Animcursorelt) int { - b := 0 - - v.Cursor = xproto.Cursor(xgb.Get32(buf[b:])) - b += 4 - - v.Delay = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// 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) -} - -// Bytes writes a Animcursorelt value to a byte slice. -func (v Animcursorelt) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Cursor)) - b += 4 - - xgb.Put32(buf[b:], v.Delay) - b += 4 - - return buf -} - -// 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 -} - -type Spanfix struct { - L Fixed - R Fixed - Y Fixed -} - -// SpanfixRead reads a byte slice into a Spanfix value. -func SpanfixRead(buf []byte, v *Spanfix) int { - b := 0 - - v.L = Fixed(xgb.Get32(buf[b:])) - b += 4 - - v.R = Fixed(xgb.Get32(buf[b:])) - b += 4 - - v.Y = Fixed(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// 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] = Spanfix{} - b += SpanfixRead(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) - b := 0 - - xgb.Put32(buf[b:], uint32(v.L)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.R)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Y)) - b += 4 - - return buf -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - type Trap struct { Top Spanfix Bot Spanfix @@ -1347,275 +1409,1519 @@ 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 +type Trapezoid struct { + Top Fixed + Bottom Fixed + Left Linefix + Right Linefix } -// PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice. -func PictFormatErrorNew(buf []byte) xgb.Error { - v := PictFormatError{} - v.NiceName = "PictFormat" +// TrapezoidRead reads a byte slice into a Trapezoid value. +func TrapezoidRead(buf []byte, v *Trapezoid) int { + b := 0 - b := 1 // skip error determinant - b += 1 // don't read error number + v.Top = Fixed(xgb.Get32(buf[b:])) + b += 4 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.Bottom = Fixed(xgb.Get32(buf[b:])) + b += 4 - return v + v.Left = Linefix{} + b += LinefixRead(buf[b:], &v.Left) + + v.Right = Linefix{} + b += LinefixRead(buf[b:], &v.Right) + + 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 +// 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] = Trapezoid{} + b += TrapezoidRead(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 Trapezoid value to a byte slice. +func (v Trapezoid) Bytes() []byte { + buf := make([]byte, 40) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Top)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Bottom)) + 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 } -// 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, ", ") + "}" +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -func init() { - xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew +type Triangle struct { + P1 Pointfix + P2 Pointfix + P3 Pointfix } -// BadPicture is the error number for a BadPicture. -const BadPicture = 1 +// TriangleRead reads a byte slice into a Triangle value. +func TriangleRead(buf []byte, v *Triangle) int { + b := 0 -type PictureError struct { - Sequence uint16 - NiceName string + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) + + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) + + v.P3 = Pointfix{} + b += PointfixRead(buf[b:], &v.P3) + + return b } -// 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 +// 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) } -// SequenceId returns the sequence id attached to the BadPicture error. -// This is mostly used internally. -func (err PictureError) SequenceId() uint16 { - return err.Sequence +// Bytes writes a Triangle value to a byte slice. +func (v Triangle) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + { + structBytes := v.P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P3.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf } -// 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 +// TriangleListBytes writes a list of Triangle values to a byte slice. +func TriangleListBytes(buf []byte, list []Triangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// Error returns a rudimentary string representation of the BadPicture error. +// Skipping definition for base type 'Bool' -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, ", ") + "}" -} +// Skipping definition for base type 'Byte' -func init() { - xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew -} +// Skipping definition for base type 'Card8' -// BadPictOp is the error number for a BadPictOp. -const BadPictOp = 2 +// Skipping definition for base type 'Char' -type PictOpError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Void' -// PictOpErrorNew constructs a PictOpError value that implements xgb.Error from a byte slice. -func PictOpErrorNew(buf []byte) xgb.Error { - v := PictOpError{} - v.NiceName = "PictOp" +// Skipping definition for base type 'Double' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Float' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - return v -} +// Skipping definition for base type 'Int32' -// 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 'Int8' -// 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 'Card16' -// Error returns a rudimentary string representation of the BadPictOp error. +// Skipping definition for base type 'Card32' -func (err PictOpError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew -} - -// BadGlyphSet is the error number for a BadGlyphSet. -const BadGlyphSet = 3 - -type GlyphSetError struct { - Sequence uint16 - NiceName string -} - -// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice. -func GlyphSetErrorNew(buf []byte) xgb.Error { - v := GlyphSetError{} - v.NiceName = "GlyphSet" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadGlyphSet error. -// This is mostly used internally. -func (err GlyphSetError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadGlyphSet error. If no bad value exists, 0 is returned. -func (err GlyphSetError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadGlyphSet error. - -func (err GlyphSetError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadGlyphSet {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew -} - -// BadGlyph is the error number for a BadGlyph. -const BadGlyph = 4 - -type GlyphError struct { - Sequence uint16 - NiceName string -} - -// GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice. -func GlyphErrorNew(buf []byte) xgb.Error { - v := GlyphError{} - v.NiceName = "Glyph" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadGlyph error. -// This is mostly used internally. -func (err GlyphError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadGlyph error. If no bad value exists, 0 is returned. -func (err GlyphError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadGlyph error. - -func (err GlyphError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadGlyph {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew -} - -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// AddGlyphsCookie is a cookie used only for AddGlyphs requests. +type AddGlyphsCookie struct { *xgb.Cookie } -// QueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() -func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { +// 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 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, 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 +} + +// AddTrapsCookie is a cookie used only for AddTraps requests. +type AddTrapsCookie struct { + *xgb.Cookie +} + +// 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 'AddTraps' 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} +} + +// 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 'AddTraps' 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} +} + +// Check returns an error if one occurred 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() +} + +// Write request to wire for AddTraps +// addTrapsRequest writes a AddTraps request to a byte slice. +func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 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(Picture)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOff)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOff)) + b += 2 + + b += TrapListBytes(buf[b:], Traps) + + return buf +} + +// 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] = 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(Picture)) + 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 +} + +// CompositeCookie is a cookie used only for Composite requests. +type CompositeCookie struct { + *xgb.Cookie +} + +// Composite 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'Composite' 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} +} + +// 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.") + } + 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["RENDER"] + 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 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mask)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + 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) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests. +type CompositeGlyphs16Cookie struct { + *xgb.Cookie +} + +// 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 'CompositeGlyphs16' 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} +} + +// 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 'CompositeGlyphs16' 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} +} + +// Check returns an error if one occurred 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() +} + +// Write request to wire for CompositeGlyphs16 +// compositeGlyphs16Request writes a CompositeGlyphs16 request to a byte slice. +func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 24 // 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 +} + +// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests. +type CompositeGlyphs32Cookie 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CompositeGlyphs32' 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} +} + +// 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 'CompositeGlyphs32' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 25 // 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 +} + +// 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 +} + +// 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 +} + +// CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests. +type CreateConicalGradientCookie struct { + *xgb.Cookie +} + +// CreateConicalGradient 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CreateConicalGradient' 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} +} + +// 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 'CreateConicalGradient' 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} +} + +// Check returns an error if one occurred 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 { + 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)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 36 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(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 +} + +// CreateCursorCookie is a cookie used only for CreateCursor requests. +type CreateCursorCookie 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CreateCursor' 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} +} + +// 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 'CreateCursor' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + + return buf +} + +// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests. +type CreateGlyphSetCookie struct { + *xgb.Cookie +} + +// CreateGlyphSet 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CreateGlyphSet' 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} +} + +// 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 'CreateGlyphSet' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gsid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) + b += 4 + + return buf +} + +// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests. +type CreateLinearGradientCookie struct { + *xgb.Cookie +} + +// CreateLinearGradient 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CreateLinearGradient' 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} +} + +// 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 'CreateLinearGradient' 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} +} + +// Check returns an error if one occurred 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 { + 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)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + 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(Picture)) + b += 4 + + { + structBytes := P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], NumStops) + b += 4 + + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + + return buf +} + +// CreatePictureCookie is a cookie used only for CreatePicture requests. +type CreatePictureCookie struct { + *xgb.Cookie +} + +// CreatePicture 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CreatePicture' 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} +} + +// 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 'CreatePicture' 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} +} + +// Check returns an error if one occurred 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 { + 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))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests. +type CreateRadialGradientCookie struct { + *xgb.Cookie +} + +// CreateRadialGradient 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CreateRadialGradient' 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} +} + +// 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 'CreateRadialGradient' 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} +} + +// Check returns an error if one occurred 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 { + 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)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 35 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Inner.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := Outer.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(InnerRadius)) + b += 4 + + xgb.Put32(buf[b:], uint32(OuterRadius)) + 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 +} + +// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. +type CreateSolidFillCookie struct { + *xgb.Cookie +} + +// CreateSolidFill 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'CreateSolidFill' 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} +} + +// 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 'CreateSolidFill' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + 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(Picture)) + b += 4 + + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// FillRectanglesCookie is a cookie used only for FillRectangles requests. +type FillRectanglesCookie 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 { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'FillRectangles' 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} +} + +// 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 'FillRectangles' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 26 // 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)) + b += 4 + + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + b += xproto.RectangleListBytes(buf[b:], Rects) + + return buf +} + +// FreeGlyphSetCookie is a cookie used only for FreeGlyphSet requests. +type FreeGlyphSetCookie struct { + *xgb.Cookie +} + +// FreeGlyphSet sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{cookie} +} + +// FreeGlyphSetChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGlyphSetCookie.Check() +func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreeGlyphSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGlyphSet +// freeGlyphSetRequest writes a FreeGlyphSet request to a byte slice. +func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Glyphset)) + b += 4 + + return buf +} + +// FreeGlyphsCookie is a cookie used only for FreeGlyphs requests. +type FreeGlyphsCookie struct { + *xgb.Cookie +} + +// FreeGlyphs sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{cookie} +} + +// FreeGlyphsChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGlyphsCookie.Check() +func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreeGlyphsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGlyphs +// freeGlyphsRequest writes a FreeGlyphs request to a byte slice. +func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + 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(Glyphset)) + b += 4 + + for i := 0; i < int(len(Glyphs)); i++ { + xgb.Put32(buf[b:], uint32(Glyphs[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// FreePictureCookie is a cookie used only for FreePicture requests. +type FreePictureCookie struct { + *xgb.Cookie +} + +// FreePicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{cookie} +} + +// FreePictureChecked sends a checked request. +// If an error occurs, it can be retrieved using FreePictureCookie.Check() +func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreePicture +// freePictureRequest writes a FreePicture request to a byte slice. +func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + return buf +} + +// QueryFiltersCookie is a cookie used only for QueryFilters requests. +type QueryFiltersCookie 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(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// QueryFiltersUnchecked 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 QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { 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 'QueryFilters' 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} + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// 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 - MajorVersion uint32 - MinorVersion uint32 + 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 QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { +// 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 @@ -1623,12 +2929,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return queryFiltersReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// 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 @@ -1639,37 +2945,44 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get32(buf[b:]) + v.NumAliases = xgb.Get32(buf[b:]) b += 4 - v.MinorVersion = xgb.Get32(buf[b:]) + 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 } -// 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 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] = 0 // 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:], ClientMajorVersion) - b += 4 - - xgb.Put32(buf[b:], ClientMinorVersion) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 return buf @@ -1890,134 +3203,158 @@ func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte { return buf } -// CreatePictureCookie is a cookie used only for CreatePicture requests. -type CreatePictureCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// CreatePicture sends an unchecked request. +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["RENDER"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. // 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 QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { 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 'QueryVersion' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } - cookie := c.NewCookie(true, false) - c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) - return CreatePictureCookie{cookie} + if buf == nil { + return nil, nil + } + return queryVersionReply(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 CreatePictureCookie) Check() error { - return cook.Cookie.Check() +// 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 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 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] = 4 // 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(Pid)) + xgb.Put32(buf[b:], ClientMajorVersion) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], ClientMinorVersion) b += 4 - xgb.Put32(buf[b:], uint32(Format)) - b += 4 - - xgb.Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// ChangePictureCookie is a cookie used only for ChangePicture requests. -type ChangePictureCookie struct { +// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests. +type ReferenceGlyphSetCookie struct { *xgb.Cookie } -// ChangePicture 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 ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { +func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { 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 'ReferenceGlyphSet' 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(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{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 { +// 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 'ChangePicture' 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(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) - return ChangePictureCookie{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 ChangePictureCookie) Check() error { +func (cook ReferenceGlyphSetCookie) 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 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] = 5 // 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 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Existing)) 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 } @@ -2085,50 +3422,50 @@ func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin i return buf } -// FreePictureCookie is a cookie used only for FreePicture requests. -type FreePictureCookie struct { +// SetPictureFilterCookie is a cookie used only for SetPictureFilter requests. +type SetPictureFilterCookie struct { *xgb.Cookie } -// FreePicture sends an unchecked request. +// SetPictureFilter sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { +func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { 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 'SetPictureFilter' 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(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{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 { +// SetPictureFilterChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureFilterCookie.Check() +func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(freePictureRequest(c, Picture), cookie) - return FreePictureCookie{cookie} + c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreePictureCookie) Check() error { +func (cook SetPictureFilterCookie) 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 SetPictureFilter +// setPictureFilterRequest writes a SetPictureFilter request to a byte slice. +func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte { + size := xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RENDER"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2137,95 +3474,80 @@ func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { xgb.Put32(buf[b:], uint32(Picture)) b += 4 + xgb.Put16(buf[b:], FilterLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Filter[:FilterLen]) + b += xgb.Pad(int(FilterLen)) + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 + } + b = xgb.Pad(b) + return buf } -// CompositeCookie is a cookie used only for Composite requests. -type CompositeCookie struct { +// SetPictureTransformCookie is a cookie used only for SetPictureTransform requests. +type SetPictureTransformCookie struct { *xgb.Cookie } -// Composite 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 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 SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { 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 'SetPictureTransform' 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(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{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 { +// 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 'Composite' 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(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) - return CompositeCookie{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 CompositeCookie) Check() error { +func (cook SetPictureTransformCookie) 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 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] = 8 // 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 - 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(Mask)) - b += 4 - - xgb.Put32(buf[b:], uint32(Dst)) - 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) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } @@ -2304,50 +3626,50 @@ func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskForma return buf } -// TrianglesCookie is a cookie used only for Triangles requests. -type TrianglesCookie struct { +// TriFanCookie is a cookie used only for TriFan requests. +type TriFanCookie struct { *xgb.Cookie } -// Triangles 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 Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { +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 'Triangles' 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(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return TrianglesCookie{cookie} + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{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 { +// 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 'Triangles' 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(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return TrianglesCookie{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 TrianglesCookie) Check() error { +func (cook TriFanCookie) 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 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] = 11 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2373,7 +3695,7 @@ func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - b += TriangleListBytes(buf[b:], Triangles) + b += PointfixListBytes(buf[b:], Points) return buf } @@ -2452,50 +3774,50 @@ func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat return buf } -// TriFanCookie is a cookie used only for TriFan requests. -type TriFanCookie struct { +// TrianglesCookie is a cookie used only for Triangles requests. +type TrianglesCookie struct { *xgb.Cookie } -// TriFan 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 TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { +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 'TriFan' 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(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriFanCookie{cookie} + c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) + return TrianglesCookie{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 { +// 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 'TriFan' 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(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return TriFanCookie{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 TriFanCookie) Check() error { +func (cook TrianglesCookie) 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 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] = 13 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2521,1329 +3843,7 @@ func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pi xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - b += PointfixListBytes(buf[b:], Points) - - return buf -} - -// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests. -type CreateGlyphSetCookie struct { - *xgb.Cookie -} - -// CreateGlyphSet 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateGlyphSet' 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} -} - -// 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 'CreateGlyphSet' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Gsid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Format)) - b += 4 - - return buf -} - -// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests. -type ReferenceGlyphSetCookie struct { - *xgb.Cookie -} - -// ReferenceGlyphSet 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'ReferenceGlyphSet' 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} -} - -// 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 'ReferenceGlyphSet' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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 - - xgb.Put32(buf[b:], uint32(Gsid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Existing)) - b += 4 - - return buf -} - -// FreeGlyphSetCookie is a cookie used only for FreeGlyphSet requests. -type FreeGlyphSetCookie struct { - *xgb.Cookie -} - -// FreeGlyphSet sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) - return FreeGlyphSetCookie{cookie} -} - -// FreeGlyphSetChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeGlyphSetCookie.Check() -func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) - return FreeGlyphSetCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeGlyphSetCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FreeGlyphSet -// freeGlyphSetRequest writes a FreeGlyphSet request to a byte slice. -func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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(Glyphset)) - b += 4 - - 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 -} - -// FreeGlyphs sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) - return FreeGlyphsCookie{cookie} -} - -// FreeGlyphsChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeGlyphsCookie.Check() -func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) - return FreeGlyphsCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeGlyphsCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FreeGlyphs -// freeGlyphsRequest writes a FreeGlyphs request to a byte slice. -func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - 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(Glyphset)) - b += 4 - - for i := 0; i < int(len(Glyphs)); i++ { - xgb.Put32(buf[b:], uint32(Glyphs[i])) - b += 4 - } - b = xgb.Pad(b) - - 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 { - *xgb.Cookie -} - -// 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 'CompositeGlyphs16' 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} -} - -// 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 'CompositeGlyphs16' 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for CompositeGlyphs16 -// compositeGlyphs16Request writes a CompositeGlyphs16 request to a byte slice. -func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 24 // 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 -} - -// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests. -type CompositeGlyphs32Cookie 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CompositeGlyphs32' 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} -} - -// 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 'CompositeGlyphs32' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 25 // 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 -} - -// FillRectanglesCookie is a cookie used only for FillRectangles requests. -type FillRectanglesCookie 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'FillRectangles' 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} -} - -// 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 'FillRectangles' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 26 // 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)) - 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 { - *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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateCursor' 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} -} - -// 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 'CreateCursor' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source)) - 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 { - *xgb.Cookie -} - -// SetPictureTransform 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureTransform' 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} -} - -// 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 'SetPictureTransform' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - return buf -} - -// QueryFiltersCookie is a cookie used only for QueryFilters requests. -type QueryFiltersCookie 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. -// 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 - - 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 -} - -// 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 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// SetPictureFilterCookie is a cookie used only for SetPictureFilter requests. -type SetPictureFilterCookie struct { - *xgb.Cookie -} - -// SetPictureFilter sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) - return SetPictureFilterCookie{cookie} -} - -// SetPictureFilterChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPictureFilterCookie.Check() -func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) - return SetPictureFilterCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetPictureFilterCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPictureFilter -// setPictureFilterRequest writes a SetPictureFilter request to a byte slice. -func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte { - size := xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 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(Picture)) - b += 4 - - xgb.Put16(buf[b:], FilterLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Filter[:FilterLen]) - b += xgb.Pad(int(FilterLen)) - - for i := 0; i < int(len(Values)); i++ { - xgb.Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// 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 { - *xgb.Cookie -} - -// 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 'AddTraps' 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} -} - -// 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 'AddTraps' 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for AddTraps -// addTrapsRequest writes a AddTraps request to a byte slice. -func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 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(Picture)) - b += 4 - - xgb.Put16(buf[b:], uint16(XOff)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOff)) - b += 2 - - b += TrapListBytes(buf[b:], Traps) - - return buf -} - -// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. -type CreateSolidFillCookie struct { - *xgb.Cookie -} - -// CreateSolidFill 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateSolidFill' 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} -} - -// 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 'CreateSolidFill' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - 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(Picture)) - b += 4 - - { - structBytes := Color.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - return buf -} - -// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests. -type CreateLinearGradientCookie struct { - *xgb.Cookie -} - -// CreateLinearGradient 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateLinearGradient' 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} -} - -// 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 'CreateLinearGradient' 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} -} - -// Check returns an error if one occurred 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 { - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - 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(Picture)) - b += 4 - - { - structBytes := P1.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := P2.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], NumStops) - b += 4 - - for i := 0; i < int(NumStops); i++ { - xgb.Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = xgb.Pad(b) - - b += ColorListBytes(buf[b:], Colors) - - return buf -} - -// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests. -type CreateRadialGradientCookie struct { - *xgb.Cookie -} - -// CreateRadialGradient 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateRadialGradient' 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} -} - -// 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 'CreateRadialGradient' 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} -} - -// Check returns an error if one occurred 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 { - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 35 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Inner.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := Outer.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(InnerRadius)) - b += 4 - - xgb.Put32(buf[b:], uint32(OuterRadius)) - 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 -} - -// CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests. -type CreateConicalGradientCookie struct { - *xgb.Cookie -} - -// CreateConicalGradient 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 { - if _, ok := c.Extensions["RENDER"]; !ok { - panic("Cannot issue request 'CreateConicalGradient' 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} -} - -// 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 'CreateConicalGradient' 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} -} - -// Check returns an error if one occurred 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 { - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["RENDER"] - b += 1 - - buf[b] = 36 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(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) + 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,110 +252,15 @@ 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 - - return buf -} - -// QueryClientsCookie is a cookie used only for QueryClients requests. -type QueryClientsCookie 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 { - 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.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryClientsRequest(c), cookie) - return QueryClientsCookie{cookie} -} - -// QueryClientsUnchecked 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 { - 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.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryClientsRequest(c), cookie) - return QueryClientsCookie{cookie} -} - -// 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 - NumClients uint32 - // padding: 20 bytes - Clients []Client // size: xgb.Pad((int(NumClients) * 8)) -} - -// 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 - } - if buf == nil { - return nil, nil - } - return queryClientsReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], Xid) b += 4 - v.NumClients = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Clients = make([]Client, v.NumClients) - b += ClientReadList(buf[b:], v.Clients) - - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["X-RESOURCE"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - return buf } @@ -454,44 +359,45 @@ func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte { return buf } -// QueryClientPixmapBytesCookie is a cookie used only for QueryClientPixmapBytes requests. -type QueryClientPixmapBytesCookie struct { +// QueryClientsCookie is a cookie used only for QueryClients requests. +type QueryClientsCookie 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 { +// 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 'QueryClientPixmapBytes' 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(queryClientPixmapBytesRequest(c, Xid), cookie) - return QueryClientPixmapBytesCookie{cookie} + c.NewRequest(queryClientsRequest(c), cookie) + return QueryClientsCookie{cookie} } -// QueryClientPixmapBytesUnchecked 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 QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { +func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie { 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 'QueryClients' 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(queryClientsRequest(c), cookie) + return QueryClientsCookie{cookie} } -// QueryClientPixmapBytesReply represents the data returned from a QueryClientPixmapBytes request. -type QueryClientPixmapBytesReply 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 - Bytes uint32 - BytesOverflow uint32 + NumClients uint32 + // padding: 20 bytes + Clients []Client // size: xgb.Pad((int(NumClients) * 8)) } -// 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 QueryClients request. +func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -499,12 +405,12 @@ func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, if buf == nil { return nil, nil } - return queryClientPixmapBytesReply(buf), nil + return queryClientsReply(buf), nil } -// queryClientPixmapBytesReply reads a byte slice into a QueryClientPixmapBytesReply value. -func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { - v := new(QueryClientPixmapBytesReply) +// 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 @@ -515,18 +421,109 @@ func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Bytes = xgb.Get32(buf[b:]) + v.NumClients = xgb.Get32(buf[b:]) b += 4 - v.BytesOverflow = xgb.Get32(buf[b:]) - b += 4 + b += 20 // padding + + v.Clients = make([]Client, v.NumClients) + b += ClientReadList(buf[b:], v.Clients) 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 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] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + 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, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + 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.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + if _, ok := c.Extensions["X-RESOURCE"]; !ok { + 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(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ServerMajor uint16 + ServerMinor uint16 +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -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 -} +const ( + StateOff = 0 + StateOn = 1 + StateCycle = 2 + StateDisabled = 3 +) -// 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} -} +// Skipping definition for base type 'Bool' -// 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} -} +// Skipping definition for base type '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 - ServerMajorVersion uint16 - ServerMinorVersion uint16 - // padding: 20 bytes -} +// Skipping definition for base type 'Card8' -// 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 -} +// Skipping definition for base type 'Char' -// 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 'Void' - b += 1 // padding +// Skipping definition for base type 'Double' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Float' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Int16' - v.ServerMajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int32' - v.ServerMinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int8' - b += 20 // padding +// Skipping definition for base type 'Card16' - 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 -} +// 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,61 +567,6 @@ 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 { - *xgb.Cookie -} - -// UnsetAttributes 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 { - 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) - return UnsetAttributesCookie{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 { - 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.") - } - cookie := c.NewCookie(true, false) - 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 UnsetAttributesCookie) 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["MIT-SCREEN-SAVER"] - 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(Drawable)) - b += 4 - - return buf -} - // SuspendCookie is a cookie used only for Suspend requests. type SuspendCookie struct { *xgb.Cookie @@ -682,3 +627,58 @@ func suspendRequest(c *xgb.Conn, Suspend bool) []byte { return buf } + +// UnsetAttributesCookie is a cookie used only for UnsetAttributes requests. +type UnsetAttributesCookie struct { + *xgb.Cookie +} + +// UnsetAttributes 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 { + 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.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) + return UnsetAttributesCookie{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 { + 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.") + } + cookie := c.NewCookie(true, false) + 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 UnsetAttributesCookie) 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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + 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(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,240 +169,45 @@ func init() { xgb.NewExtEventFuncs["SHAPE"][0] = NotifyEventNew } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { - *xgb.Cookie -} +type Op byte -// 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} -} +const ( + SkBounding = 0 + SkClip = 1 + SkInput = 2 +) -// 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} -} +const ( + SoSet = 0 + SoUnion = 1 + SoIntersect = 2 + SoSubtract = 3 + SoInvert = 4 +) -// 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 -} +// Skipping definition for base type 'Bool' -// 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 -} +// Skipping definition for base type 'Byte' -// 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 'Card8' - b += 1 // padding +// Skipping definition for base type 'Char' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Void' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Double' - v.MajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Float' - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - return v -} +// Skipping definition for base type 'Int32' -// 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 'Int8' - buf[b] = c.Extensions["SHAPE"] - b += 1 +// Skipping definition for base type 'Card16' - 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 -} - -// RectanglesCookie is a cookie used only for Rectangles requests. -type RectanglesCookie struct { - *xgb.Cookie -} - -// 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 'Rectangles' 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} -} - -// 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 'Rectangles' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["SHAPE"] - 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 - - buf[b] = byte(Operation) - b += 1 - - buf[b] = byte(DestinationKind) - b += 1 - - buf[b] = Ordering - b += 1 - - b += 1 // padding - - xgb.Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - xgb.Put16(buf[b:], uint16(XOffset)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOffset)) - b += 2 - - b += xproto.RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// MaskCookie is a cookie used only for Mask requests. -type MaskCookie 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 { - if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'Mask' 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} -} - -// 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 'Mask' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["SHAPE"] - 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 - - buf[b] = byte(Operation) - b += 1 - - buf[b] = byte(DestinationKind) - b += 1 - - b += 2 // padding - - xgb.Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - xgb.Put16(buf[b:], uint16(XOffset)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOffset)) - b += 2 - - xgb.Put32(buf[b:], uint32(SourceBitmap)) - b += 4 - - return buf -} +// Skipping definition for base type 'Card32' // CombineCookie is a cookie used only for Combine requests. type CombineCookie struct { @@ -519,6 +284,268 @@ func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind return buf } +// GetRectanglesCookie is a cookie used only for GetRectangles requests. +type GetRectanglesCookie 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 { + if _, ok := c.Extensions["SHAPE"]; !ok { + panic("Cannot issue request 'GetRectangles' 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} +} + +// 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 'GetRectangles' 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} +} + +// 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)) +} + +// Reply blocks and returns the reply data for a GetRectangles request. +func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getRectanglesReply(buf), nil +} + +// getRectanglesReply reads a byte slice into a GetRectanglesReply value. +func getRectanglesReply(buf []byte) *GetRectanglesReply { + v := new(GetRectanglesReply) + b := 1 // skip reply determinant + + v.Ordering = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RectanglesLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Rectangles = make([]xproto.Rectangle, v.RectanglesLen) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for GetRectangles +// getRectanglesRequest writes a GetRectangles request to a byte slice. +func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 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 + + 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 + + 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(DestinationWindow)) + b += 4 + + return buf +} + +// MaskCookie is a cookie used only for Mask requests. +type MaskCookie 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 { + if _, ok := c.Extensions["SHAPE"]; !ok { + panic("Cannot issue request 'Mask' 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} +} + +// 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 'Mask' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["SHAPE"] + 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 + + buf[b] = byte(Operation) + b += 1 + + buf[b] = byte(DestinationKind) + b += 1 + + b += 2 // padding + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(SourceBitmap)) + b += 4 + + return buf +} + // OffsetCookie is a cookie used only for Offset requests. type OffsetCookie struct { *xgb.Cookie @@ -720,6 +747,169 @@ func queryExtentsRequest(c *xgb.Conn, DestinationWindow xproto.Window) []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) 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} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + 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.Get16(buf[b:]) + b += 2 + + v.MinorVersion = 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) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + 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 +} + +// RectanglesCookie is a cookie used only for Rectangles requests. +type RectanglesCookie struct { + *xgb.Cookie +} + +// 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 'Rectangles' 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} +} + +// 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 'Rectangles' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["SHAPE"] + 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 + + buf[b] = byte(Operation) + b += 1 + + buf[b] = byte(DestinationKind) + b += 1 + + buf[b] = Ordering + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + // SelectInputCookie is a cookie used only for SelectInput requests. type SelectInputCookie struct { *xgb.Cookie @@ -783,193 +973,3 @@ func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable boo 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 - - 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(DestinationWindow)) - b += 4 - - return buf -} - -// GetRectanglesCookie is a cookie used only for GetRectangles requests. -type GetRectanglesCookie 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 { - if _, ok := c.Extensions["SHAPE"]; !ok { - panic("Cannot issue request 'GetRectangles' 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} -} - -// 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 'GetRectangles' 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} -} - -// 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)) -} - -// Reply blocks and returns the reply data for a GetRectangles request. -func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getRectanglesReply(buf), nil -} - -// getRectanglesReply reads a byte slice into a GetRectanglesReply value. -func getRectanglesReply(buf []byte) *GetRectanglesReply { - v := new(GetRectanglesReply) - b := 1 // skip reply determinant - - v.Ordering = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.RectanglesLen = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Rectangles = make([]xproto.Rectangle, v.RectanglesLen) - b += xproto.RectangleReadList(buf[b:], v.Rectangles) - - return v -} - -// Write request to wire for GetRectangles -// getRectanglesRequest writes a GetRectangles request to a byte slice. -func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SHAPE"] - b += 1 - - buf[b] = 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 - - buf[b] = byte(SourceKind) - b += 1 - - b += 3 // padding - - return buf -} 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' +// BadBadSeg is the error number for a BadBadSeg. +const BadBadSeg = 0 -// Skipping definition for base type 'Card32' +type BadSegError xproto.ValueError -// Skipping definition for base type 'Double' +// 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 'Bool' +// 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 'Float' +// 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 +} -// Skipping definition for base type 'Card8' +// 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, ", ") + "}" +} -// 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' - -type Seg uint32 - -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 Seg uint32 -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 -} - -// 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 + return 0, err } - if buf == nil { - return nil, nil - } - 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 +// Skipping definition for base type 'Bool' - if buf[b] == 1 { - v.SharedPixmaps = true - } else { - v.SharedPixmaps = false - } - 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.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' - v.Uid = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Float' - v.Gid = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - v.PixmapFormat = buf[b] - b += 1 +// Skipping definition for base type 'Int32' - b += 15 // padding +// Skipping definition for base type 'Int8' - return v -} +// Skipping definition for base type 'Card16' -// 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 -} +// Skipping definition for base type 'Card32' // AttachCookie is a cookie used only for Attach requests. type AttachCookie struct { @@ -388,6 +279,81 @@ func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte 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, 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 'CreatePixmap' 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} +} + +// 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 'CreatePixmap' 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} +} + +// Check returns an error if one occurred 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, 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] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + buf[b] = Depth + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Offset) + b += 4 + + return buf +} + // DetachCookie is a cookie used only for Detach requests. type DetachCookie struct { *xgb.Cookie @@ -443,105 +409,6 @@ func detachRequest(c *xgb.Conn, Shmseg Seg) []byte { return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { - *xgb.Cookie -} - -// 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 { - 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.") - } - 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} -} - -// 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 'PutImage' 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} -} - -// Check returns an error if one occurred 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, 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] = 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)) - 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 -} - // GetImageCookie is a cookie used only for GetImage requests. type GetImageCookie struct { *xgb.Cookie @@ -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)) - b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], Width) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], TotalWidth) b += 2 - xgb.Put16(buf[b:], Height) + xgb.Put16(buf[b:], TotalHeight) + b += 2 + + xgb.Put16(buf[b:], SrcX) + b += 2 + + xgb.Put16(buf[b:], SrcY) + b += 2 + + xgb.Put16(buf[b:], SrcWidth) + b += 2 + + xgb.Put16(buf[b:], SrcHeight) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) b += 2 buf[b] = Depth b += 1 - b += 3 // padding + buf[b] = Format + b += 1 + + buf[b] = SendEvent + b += 1 + + b += 1 // padding xgb.Put32(buf[b:], uint32(Shmseg)) b += 4 @@ -735,3 +626,112 @@ func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawabl return buf } + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["MIT-SHM"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["MIT-SHM"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + SharedPixmaps bool + MajorVersion uint16 + MinorVersion uint16 + Uid uint16 + Gid uint16 + PixmapFormat byte + // padding: 15 bytes +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SharedPixmaps = true + } else { + v.SharedPixmaps = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Uid = xgb.Get16(buf[b:]) + b += 2 + + v.Gid = xgb.Get16(buf[b:]) + b += 2 + + v.PixmapFormat = buf[b] + b += 1 + + b += 15 // padding + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SHM"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} diff --git a/nexgb/sync/sync.go b/nexgb/sync/sync.go index a7046b7..ff83384 100644 --- a/nexgb/sync/sync.go +++ b/nexgb/sync/sync.go @@ -2,7 +2,7 @@ package sync /* - This file was generated by sync.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by sync.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,29 +40,183 @@ func init() { xgb.NewExtErrorFuncs["SYNC"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Float' +type Alarm uint32 -// Skipping definition for base type 'Card8' +func NewAlarmId(c *xgb.Conn) (Alarm, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Alarm(id), nil +} -// Skipping definition for base type 'Int16' +// BadAlarm is the error number for a BadAlarm. +const BadAlarm = 1 -// Skipping definition for base type 'Int32' +type AlarmError struct { + Sequence uint16 + NiceName string + BadAlarm uint32 + MinorOpcode uint16 + MajorOpcode byte +} -// Skipping definition for base type 'Void' +// AlarmErrorNew constructs a AlarmError value that implements xgb.Error from a byte slice. +func AlarmErrorNew(buf []byte) xgb.Error { + v := AlarmError{} + v.NiceName = "Alarm" -// Skipping definition for base type 'Byte' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Int8' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card16' + v.BadAlarm = xgb.Get32(buf[b:]) + b += 4 -// Skipping definition for base type 'Char' + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card32' + v.MajorOpcode = buf[b] + b += 1 -// Skipping definition for base type 'Double' + return v +} -// Skipping definition for base type 'Bool' +// SequenceId returns the sequence id attached to the BadAlarm error. +// This is mostly used internally. +func (err AlarmError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadAlarm error. If no bad value exists, 0 is returned. +func (err AlarmError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadAlarm error. + +func (err AlarmError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadAlarm: %d", err.BadAlarm)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlarm {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew +} + +// AlarmNotify is the event number for a AlarmNotifyEvent. +const AlarmNotify = 1 + +type AlarmNotifyEvent struct { + Sequence uint16 + Kind byte + Alarm Alarm + CounterValue Int64 + AlarmValue Int64 + Timestamp xproto.Timestamp + State byte + // padding: 3 bytes +} + +// AlarmNotifyEventNew constructs a AlarmNotifyEvent value that implements xgb.Event from a byte slice. +func AlarmNotifyEventNew(buf []byte) xgb.Event { + v := AlarmNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Alarm = Alarm(xgb.Get32(buf[b:])) + b += 4 + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.AlarmValue = Int64{} + b += Int64Read(buf[b:], &v.AlarmValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a AlarmNotifyEvent value to a byte slice. +func (v AlarmNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Alarm)) + b += 4 + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.AlarmValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the AlarmNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v AlarmNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of AlarmNotifyEvent. +func (v AlarmNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Alarm: %d", v.Alarm)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "AlarmNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew +} const ( AlarmstateActive = 0 @@ -70,18 +224,6 @@ const ( AlarmstateDestroyed = 2 ) -const ( - TesttypePositiveTransition = 0 - TesttypeNegativeTransition = 1 - TesttypePositiveComparison = 2 - TesttypeNegativeComparison = 3 -) - -const ( - ValuetypeAbsolute = 0 - ValuetypeRelative = 1 -) - const ( CaCounter = 1 CaValueType = 2 @@ -91,16 +233,6 @@ const ( CaEvents = 32 ) -type Alarm uint32 - -func NewAlarmId(c *xgb.Conn) (Alarm, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Alarm(id), nil -} - type Counter uint32 func NewCounterId(c *xgb.Conn) (Counter, error) { @@ -111,6 +243,190 @@ func NewCounterId(c *xgb.Conn) (Counter, error) { return Counter(id), nil } +// BadCounter is the error number for a BadCounter. +const BadCounter = 0 + +type CounterError struct { + Sequence uint16 + NiceName string + BadCounter uint32 + MinorOpcode uint16 + MajorOpcode byte +} + +// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. +func CounterErrorNew(buf []byte) xgb.Error { + v := CounterError{} + v.NiceName = "Counter" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadCounter = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + return v +} + +// SequenceId returns the sequence id attached to the BadCounter error. +// This is mostly used internally. +func (err CounterError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadCounter error. If no bad value exists, 0 is returned. +func (err CounterError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadCounter error. + +func (err CounterError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadCounter: %d", err.BadCounter)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCounter {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew +} + +// CounterNotify is the event number for a CounterNotifyEvent. +const CounterNotify = 0 + +type CounterNotifyEvent struct { + Sequence uint16 + Kind byte + Counter Counter + WaitValue Int64 + CounterValue Int64 + Timestamp xproto.Timestamp + Count uint16 + Destroyed bool + // padding: 1 bytes +} + +// CounterNotifyEventNew constructs a CounterNotifyEvent value that implements xgb.Event from a byte slice. +func CounterNotifyEventNew(buf []byte) xgb.Event { + v := CounterNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.WaitValue = Int64{} + b += Int64Read(buf[b:], &v.WaitValue) + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.Destroyed = true + } else { + v.Destroyed = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Bytes writes a CounterNotifyEvent value to a byte slice. +func (v CounterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + { + structBytes := v.WaitValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + if v.Destroyed { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the CounterNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CounterNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of CounterNotifyEvent. +func (v CounterNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Counter: %d", v.Counter)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Destroyed: %t", v.Destroyed)) + return "CounterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew +} + type Fence uint32 func NewFenceId(c *xgb.Conn) (Fence, error) { @@ -259,6 +575,13 @@ func SystemcounterListSize(list []Systemcounter) int { return size } +const ( + TesttypePositiveTransition = 0 + TesttypeNegativeTransition = 1 + TesttypePositiveComparison = 2 + TesttypeNegativeComparison = 3 +) + type Trigger struct { Counter Counter WaitType uint32 @@ -330,6 +653,11 @@ func TriggerListBytes(buf []byte, list []Trigger) int { return b } +const ( + ValuetypeAbsolute = 0 + ValuetypeRelative = 1 +) + type Waitcondition struct { Trigger Trigger EventThreshold Int64 @@ -390,358 +718,708 @@ func WaitconditionListBytes(buf []byte, list []Waitcondition) int { return b } -// CounterNotify is the event number for a CounterNotifyEvent. -const CounterNotify = 0 +// Skipping definition for base type 'Bool' -type CounterNotifyEvent struct { - Sequence uint16 - Kind byte - Counter Counter - WaitValue Int64 - CounterValue Int64 - Timestamp xproto.Timestamp - Count uint16 - Destroyed bool - // padding: 1 bytes +// Skipping definition for base type 'Byte' + +// 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' + +// AwaitCookie is a cookie used only for Await requests. +type AwaitCookie struct { + *xgb.Cookie } -// CounterNotifyEventNew constructs a CounterNotifyEvent value that implements xgb.Event from a byte slice. -func CounterNotifyEventNew(buf []byte) xgb.Event { - v := CounterNotifyEvent{} - b := 1 // don't read event number - - v.Kind = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Counter = Counter(xgb.Get32(buf[b:])) - b += 4 - - v.WaitValue = Int64{} - b += Int64Read(buf[b:], &v.WaitValue) - - v.CounterValue = Int64{} - b += Int64Read(buf[b:], &v.CounterValue) - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Count = xgb.Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.Destroyed = true - } else { - v.Destroyed = false +// Await sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Await(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'Await' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") } - b += 1 - - b += 1 // padding - - return v + cookie := c.NewCookie(false, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{cookie} } -// Bytes writes a CounterNotifyEvent value to a byte slice. -func (v CounterNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// 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() +} + +// Write request to wire for Await +// awaitRequest writes a Await request to a byte slice. +func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { + size := xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) b := 0 + buf := make([]byte, size) - // write event number - buf[b] = 0 + buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = v.Kind + buf[b] = 7 // request opcode b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Counter)) - b += 4 - - { - structBytes := v.WaitValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - xgb.Put16(buf[b:], v.Count) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - if v.Destroyed { + b += WaitconditionListBytes(buf[b:], WaitList) + + return buf +} + +// AwaitFenceCookie is a cookie used only for AwaitFence requests. +type AwaitFenceCookie struct { + *xgb.Cookie +} + +// AwaitFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AwaitFence(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'AwaitFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} +} + +// AwaitFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using AwaitFenceCookie.Check() +func AwaitFenceChecked(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'AwaitFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["SYNC"] + 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 + + for i := 0; i < int(len(FenceList)); i++ { + xgb.Put32(buf[b:], uint32(FenceList[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// ChangeAlarmCookie is a cookie used only for ChangeAlarm requests. +type ChangeAlarmCookie 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 { + 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} +} + +// 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} +} + +// Check returns an error if one occurred 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] = 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(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 +} + +// ChangeCounterCookie is a cookie used only for ChangeCounter requests. +type ChangeCounterCookie struct { + *xgb.Cookie +} + +// 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 'ChangeCounter' 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} +} + +// ChangeCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCounterCookie.Check() +func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'ChangeCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeCounter +// changeCounterRequest writes a ChangeCounter request to a byte slice. +func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 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(Counter)) + 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 +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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 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] = 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 +} + +// CreateCounterCookie is a cookie used only for CreateCounter requests. +type CreateCounterCookie struct { + *xgb.Cookie +} + +// CreateCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateCounter(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'CreateCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) + return CreateCounterCookie{cookie} +} + +// CreateCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCounterCookie.Check() +func CreateCounterChecked(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'CreateCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) + return CreateCounterCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateCounter +// createCounterRequest writes a CreateCounter request to a byte slice. +func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Id)) + b += 4 + + { + structBytes := InitialValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// CreateFenceCookie is a cookie used only for CreateFence requests. +type CreateFenceCookie 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 { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'CreateFence' 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} +} + +// 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 'CreateFence' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + if InitiallyTriggered { buf[b] = 1 } else { buf[b] = 0 } b += 1 + 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} +} + +// 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} +} + +// Check returns an error if one occurred 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 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) + + buf[b] = c.Extensions["SYNC"] + 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(Alarm)) + b += 4 + + return buf +} + +// DestroyCounterCookie is a cookie used only for DestroyCounter requests. +type DestroyCounterCookie struct { + *xgb.Cookie +} + +// DestroyCounter 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 { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'DestroyCounter' 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} +} + +// 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 'DestroyCounter' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + 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(Counter)) + b += 4 + + return buf +} + +// DestroyFenceCookie is a cookie used only for DestroyFence requests. +type DestroyFenceCookie struct { + *xgb.Cookie +} + +// DestroyFence 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 { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'DestroyFence' 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} +} + +// 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 'DestroyFence' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// GetPriorityCookie is a cookie used only for GetPriority requests. +type GetPriorityCookie 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 { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'GetPriority' 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} +} + +// 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 'GetPriority' 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} +} + +// 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 +} + +// 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 - return buf -} - -// SequenceId returns the sequence id attached to the CounterNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CounterNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of CounterNotifyEvent. -func (v CounterNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, xgb.Sprintf("Counter: %d", v.Counter)) - fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, xgb.Sprintf("Destroyed: %t", v.Destroyed)) - return "CounterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew -} - -// AlarmNotify is the event number for a AlarmNotifyEvent. -const AlarmNotify = 1 - -type AlarmNotifyEvent struct { - Sequence uint16 - Kind byte - Alarm Alarm - CounterValue Int64 - AlarmValue Int64 - Timestamp xproto.Timestamp - State byte - // padding: 3 bytes -} - -// AlarmNotifyEventNew constructs a AlarmNotifyEvent value that implements xgb.Event from a byte slice. -func AlarmNotifyEventNew(buf []byte) xgb.Event { - v := AlarmNotifyEvent{} - b := 1 // don't read event number - - v.Kind = buf[b] - b += 1 - v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Alarm = Alarm(xgb.Get32(buf[b:])) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.CounterValue = Int64{} - b += Int64Read(buf[b:], &v.CounterValue) - - v.AlarmValue = Int64{} - b += Int64Read(buf[b:], &v.AlarmValue) - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.Priority = int32(xgb.Get32(buf[b:])) b += 4 - v.State = buf[b] - b += 1 - - b += 3 // padding - return v } -// Bytes writes a AlarmNotifyEvent value to a byte slice. -func (v AlarmNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// 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) - // write event number - buf[b] = 1 + buf[b] = c.Extensions["SYNC"] b += 1 - buf[b] = v.Kind + buf[b] = 13 // request opcode b += 1 - b += 2 // skip sequence number + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - xgb.Put32(buf[b:], uint32(v.Alarm)) + xgb.Put32(buf[b:], Id) b += 4 - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - { - structBytes := v.AlarmValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - buf[b] = v.State - b += 1 - - b += 3 // padding - return buf } -// SequenceId returns the sequence id attached to the AlarmNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v AlarmNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of AlarmNotifyEvent. -func (v AlarmNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, xgb.Sprintf("Alarm: %d", v.Alarm)) - fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "AlarmNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew -} - -// BadCounter is the error number for a BadCounter. -const BadCounter = 0 - -type CounterError struct { - Sequence uint16 - NiceName string - BadCounter uint32 - MinorOpcode uint16 - MajorOpcode byte -} - -// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. -func CounterErrorNew(buf []byte) xgb.Error { - v := CounterError{} - v.NiceName = "Counter" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.BadCounter = xgb.Get32(buf[b:]) - b += 4 - - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - return v -} - -// SequenceId returns the sequence id attached to the BadCounter error. -// This is mostly used internally. -func (err CounterError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadCounter error. If no bad value exists, 0 is returned. -func (err CounterError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadCounter error. - -func (err CounterError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadCounter: %d", err.BadCounter)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadCounter {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew -} - -// BadAlarm is the error number for a BadAlarm. -const BadAlarm = 1 - -type AlarmError struct { - Sequence uint16 - NiceName string - BadAlarm uint32 - MinorOpcode uint16 - MajorOpcode byte -} - -// AlarmErrorNew constructs a AlarmError value that implements xgb.Error from a byte slice. -func AlarmErrorNew(buf []byte) xgb.Error { - v := AlarmError{} - v.NiceName = "Alarm" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.BadAlarm = xgb.Get32(buf[b:]) - b += 4 - - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - return v -} - -// SequenceId returns the sequence id attached to the BadAlarm error. -// This is mostly used internally. -func (err AlarmError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadAlarm error. If no bad value exists, 0 is returned. -func (err AlarmError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadAlarm error. - -func (err AlarmError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadAlarm: %d", err.BadAlarm)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAlarm {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew -} - // InitializeCookie is a cookie used only for Initialize requests. type InitializeCookie struct { *xgb.Cookie @@ -932,567 +1610,6 @@ func listSystemCountersRequest(c *xgb.Conn) []byte { return buf } -// CreateCounterCookie is a cookie used only for CreateCounter requests. -type CreateCounterCookie struct { - *xgb.Cookie -} - -// CreateCounter sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateCounter(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'CreateCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) - return CreateCounterCookie{cookie} -} - -// CreateCounterChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateCounterCookie.Check() -func CreateCounterChecked(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'CreateCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) - return CreateCounterCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateCounterCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateCounter -// createCounterRequest writes a CreateCounter request to a byte slice. -func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SYNC"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Id)) - b += 4 - - { - structBytes := InitialValue.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - return buf -} - -// DestroyCounterCookie is a cookie used only for DestroyCounter requests. -type DestroyCounterCookie struct { - *xgb.Cookie -} - -// DestroyCounter 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 { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyCounter' 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} -} - -// 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 'DestroyCounter' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SYNC"] - 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(Counter)) - b += 4 - - return buf -} - -// QueryCounterCookie is a cookie used only for QueryCounter requests. -type QueryCounterCookie 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. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryCounterUnchecked(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(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 -} - -// 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 - } - return queryCounterReply(buf), nil -} - -// 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 -} - -// 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) - - buf[b] = c.Extensions["SYNC"] - 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(Counter)) - b += 4 - - return buf -} - -// AwaitCookie is a cookie used only for Await requests. -type AwaitCookie struct { - *xgb.Cookie -} - -// 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() -} - -// 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 - - buf[b] = 7 // 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) - - return buf -} - -// ChangeCounterCookie is a cookie used only for ChangeCounter requests. -type ChangeCounterCookie struct { - *xgb.Cookie -} - -// 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 'ChangeCounter' 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} -} - -// ChangeCounterChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeCounterCookie.Check() -func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ChangeCounter' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) - return ChangeCounterCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeCounterCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ChangeCounter -// changeCounterRequest writes a ChangeCounter request to a byte slice. -func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SYNC"] - b += 1 - - buf[b] = 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(Counter)) - 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 { - *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 { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'SetCounter' 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} -} - -// 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 'SetCounter' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Counter)) - 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 { - *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 { - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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 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] = 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 -} - -// ChangeAlarmCookie is a cookie used only for ChangeAlarm requests. -type ChangeAlarmCookie 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 { - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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] = 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(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 -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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 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) - - buf[b] = c.Extensions["SYNC"] - 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(Alarm)) - b += 4 - - return buf -} - // QueryAlarmCookie is a cookie used only for QueryAlarm requests. type QueryAlarmCookie struct { *xgb.Cookie @@ -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 { +// QueryCounterCookie is a cookie used only for QueryCounter requests. +type QueryCounterCookie 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 { +// 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 '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 { - *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 { - 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,243 +1793,13 @@ 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) - b += 4 - - return buf -} - -// CreateFenceCookie is a cookie used only for CreateFence requests. -type CreateFenceCookie 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 { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'CreateFence' 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} -} - -// 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 'CreateFence' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Fence)) - b += 4 - - if InitiallyTriggered { - buf[b] = 1 - } else { - buf[b] = 0 - } - 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Fence)) - b += 4 - - return buf -} - -// ResetFenceCookie is a cookie used only for ResetFence requests. -type ResetFenceCookie struct { - *xgb.Cookie -} - -// ResetFence sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ResetFence(c *xgb.Conn, Fence Fence) ResetFenceCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ResetFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(resetFenceRequest(c, Fence), cookie) - return ResetFenceCookie{cookie} -} - -// ResetFenceChecked sends a checked request. -// If an error occurs, it can be retrieved using ResetFenceCookie.Check() -func ResetFenceChecked(c *xgb.Conn, Fence Fence) ResetFenceCookie { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'ResetFence' using the uninitialized extension 'SYNC'. sync.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(resetFenceRequest(c, Fence), cookie) - return ResetFenceCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ResetFenceCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ResetFence -// resetFenceRequest writes a ResetFence request to a byte slice. -func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SYNC"] - 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 - - xgb.Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// DestroyFenceCookie is a cookie used only for DestroyFence requests. -type DestroyFenceCookie struct { - *xgb.Cookie -} - -// DestroyFence 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 { - if _, ok := c.Extensions["SYNC"]; !ok { - panic("Cannot issue request 'DestroyFence' 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} -} - -// 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 'DestroyFence' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SYNC"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Fence)) + xgb.Put32(buf[b:], uint32(Counter)) b += 4 return buf @@ -2071,60 +1900,231 @@ func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// AwaitFenceCookie is a cookie used only for AwaitFence requests. -type AwaitFenceCookie struct { +// ResetFenceCookie is a cookie used only for ResetFence requests. +type ResetFenceCookie struct { *xgb.Cookie } -// AwaitFence sends an unchecked request. +// ResetFence 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 ResetFence(c *xgb.Conn, Fence Fence) ResetFenceCookie { 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 'ResetFence' 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(resetFenceRequest(c, Fence), cookie) + return ResetFenceCookie{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 { +// ResetFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using ResetFenceCookie.Check() +func ResetFenceChecked(c *xgb.Conn, Fence Fence) ResetFenceCookie { 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 'ResetFence' 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(resetFenceRequest(c, Fence), cookie) + return ResetFenceCookie{cookie} } // Check returns an error if one occurred 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 ResetFenceCookie) 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 ResetFence +// resetFenceRequest writes a ResetFence request to a byte slice. +func resetFenceRequest(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] = 16 // 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 +} + +// SetCounterCookie is a cookie used only for SetCounter requests. +type SetCounterCookie 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 { + if _, ok := c.Extensions["SYNC"]; !ok { + panic("Cannot issue request 'SetCounter' 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} +} + +// 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 'SetCounter' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(Counter)) + b += 4 + + { + structBytes := Value.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + 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 +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(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,95 +159,6 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio return buf } -// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. -type GetXIDRangeCookie 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 { - 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.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getXIDRangeRequest(c), cookie) - return GetXIDRangeCookie{cookie} -} - -// GetXIDRangeUnchecked 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 { - 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.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getXIDRangeRequest(c), cookie) - return GetXIDRangeCookie{cookie} -} - -// 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 - StartId uint32 - Count uint32 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return getXIDRangeReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.StartId = xgb.Get32(buf[b:]) - b += 4 - - v.Count = xgb.Get32(buf[b:]) - b += 4 - - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XC-MISC"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - // GetXIDListCookie is a cookie used only for GetXIDList requests. type GetXIDListCookie struct { *xgb.Cookie @@ -346,3 +257,92 @@ func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { return buf } + +// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. +type GetXIDRangeCookie 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 { + 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.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} +} + +// GetXIDRangeUnchecked 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 { + 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.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} +} + +// 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 + StartId uint32 + Count uint32 +} + +// 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 + } + if buf == nil { + return nil, nil + } + return getXIDRangeReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.StartId = xgb.Get32(buf[b:]) + b += 4 + + v.Count = xgb.Get32(buf[b:]) + b += 4 + + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XC-MISC"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} 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,6 +90,117 @@ func EventListBytes(buf []byte, list []Event) int { return b } +// 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 +} + +// 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 'End' 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} +} + +// EndUnchecked 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 { + if _, ok := c.Extensions["XEVIE"]; !ok { + panic("Cannot issue request 'End' 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} +} + +// 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 + // padding: 24 bytes +} + +// 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 + } + if buf == nil { + return nil, nil + } + return endReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + 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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XEVIE"] + 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:], Cmap) + b += 4 + + return buf +} + // QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie @@ -212,43 +299,43 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVers return buf } -// StartCookie is a cookie used only for Start requests. -type StartCookie struct { +// SelectInputCookie is a cookie used only for SelectInput requests. +type SelectInputCookie 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 { +// 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 'Start' 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(startRequest(c, Screen), cookie) - return StartCookie{cookie} + c.NewRequest(selectInputRequest(c, EventMask), cookie) + return SelectInputCookie{cookie} } -// StartUnchecked 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 StartUnchecked(c *xgb.Conn, Screen uint32) StartCookie { +func SelectInputUnchecked(c *xgb.Conn, EventMask uint32) SelectInputCookie { 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 'SelectInput' 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(selectInputRequest(c, EventMask), cookie) + return SelectInputCookie{cookie} } -// StartReply represents the data returned from a Start request. -type StartReply 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 Start request. -func (cook StartCookie) Reply() (*StartReply, 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 @@ -256,12 +343,12 @@ func (cook StartCookie) Reply() (*StartReply, error) { if buf == nil { return nil, nil } - return startReply(buf), nil + return selectInputReply(buf), nil } -// startReply reads a byte slice into a StartReply value. -func startReply(buf []byte) *StartReply { - v := new(StartReply) +// 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 @@ -277,9 +364,9 @@ func startReply(buf []byte) *StartReply { 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 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) @@ -287,100 +374,13 @@ func startRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["XEVIE"] 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:], Screen) - b += 4 - - return buf -} - -// EndCookie is a cookie used only for End requests. -type EndCookie 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 { - if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'End' 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} -} - -// EndUnchecked 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 { - if _, ok := c.Extensions["XEVIE"]; !ok { - panic("Cannot issue request 'End' 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} -} - -// 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 - // padding: 24 bytes -} - -// 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 - } - if buf == nil { - return nil, nil - } - return endReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XEVIE"] - 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:], 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,118 +192,23 @@ 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 - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. -type QueryDirectRenderingCapableCookie struct { - *xgb.Cookie -} - -// QueryDirectRenderingCapable sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply() -func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { - 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. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) - return QueryDirectRenderingCapableCookie{cookie} -} - -// 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 -} - -// 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 - } - return queryDirectRenderingCapableReply(buf), nil -} - -// 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 -} - -// 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] = 1 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -314,111 +217,7 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - return buf -} - -// OpenConnectionCookie is a cookie used only for OpenConnection requests. -type OpenConnectionCookie struct { - *xgb.Cookie -} - -// OpenConnection sends a checked request. -// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply() -func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(openConnectionRequest(c, Screen), cookie) - return OpenConnectionCookie{cookie} -} - -// OpenConnectionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(openConnectionRequest(c, Screen), cookie) - return OpenConnectionCookie{cookie} -} - -// 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 - 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 OpenConnection request. -func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return openConnectionReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.SareaHandleLow = xgb.Get32(buf[b:]) - b += 4 - - v.SareaHandleHigh = xgb.Get32(buf[b:]) - b += 4 - - v.BusIdLen = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - { - byteString := make([]byte, v.BusIdLen) - copy(byteString[:v.BusIdLen], buf[b:]) - v.BusId = string(byteString) - b += xgb.Pad(int(v.BusIdLen)) - } - - return v -} - -// Write request to wire for OpenConnection -// 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) - - buf[b] = c.Extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Screen) + xgb.Put32(buf[b:], Magic) b += 4 return buf @@ -479,6 +278,307 @@ func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { return buf } +// CreateContextCookie is a cookie used only for CreateContext requests. +type CreateContextCookie struct { + *xgb.Cookie +} + +// CreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() +func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + 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. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} +} + +// 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 +} + +// 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 + } + return createContextReply(buf), nil +} + +// 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 +} + +// Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. +func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Visual) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// CreateDrawableCookie is a cookie used only for CreateDrawable requests. +type CreateDrawableCookie struct { + *xgb.Cookie +} + +// CreateDrawable sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply() +func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +// CreateDrawableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +// CreateDrawableReply represents the data returned from a CreateDrawable request. +type CreateDrawableReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + HwDrawableHandle uint32 +} + +// Reply blocks and returns the reply data for a CreateDrawable request. +func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createDrawableReply(buf), nil +} + +// createDrawableReply reads a byte slice into a CreateDrawableReply value. +func createDrawableReply(buf []byte) *CreateDrawableReply { + v := new(CreateDrawableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.HwDrawableHandle = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for CreateDrawable +// createDrawableRequest writes a CreateDrawable request to a byte slice. +func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { + *xgb.Cookie +} + +// DestroyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +// DestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyContextCookie.Check() +func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyContext +// destroyContextRequest writes a DestroyContext request to a byte slice. +func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. +type DestroyDrawableCookie struct { + *xgb.Cookie +} + +// DestroyDrawable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +// DestroyDrawableChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() +func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroyDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyDrawable +// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. +func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + // GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests. type GetClientDriverNameCookie struct { *xgb.Cookie @@ -590,43 +690,49 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { +// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. +type GetDeviceInfoCookie struct { *xgb.Cookie } -// CreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() -func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { +// GetDeviceInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply() +func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) - return CreateContextCookie{cookie} + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} } -// CreateContextUnchecked sends an unchecked request. +// GetDeviceInfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { +func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) - return CreateContextCookie{cookie} + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} } -// CreateContextReply represents the data returned from a CreateContext request. -type CreateContextReply struct { +// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request. +type GetDeviceInfoReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - HwContext uint32 + FramebufferHandleLow uint32 + FramebufferHandleHigh uint32 + FramebufferOriginOffset uint32 + FramebufferSize uint32 + FramebufferStride uint32 + DevicePrivateSize uint32 + DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) } -// Reply blocks and returns the reply data for a CreateContext request. -func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { +// Reply blocks and returns the reply data for a GetDeviceInfo request. +func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -634,12 +740,12 @@ func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { if buf == nil { return nil, nil } - return createContextReply(buf), nil + return getDeviceInfoReply(buf), nil } -// createContextReply reads a byte slice into a CreateContextReply value. -func createContextReply(buf []byte) *CreateContextReply { - v := new(CreateContextReply) +// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value. +func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { + v := new(GetDeviceInfoReply) b := 1 // skip reply determinant b += 1 // padding @@ -650,23 +756,45 @@ func createContextReply(buf []byte) *CreateContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.HwContext = xgb.Get32(buf[b:]) + v.FramebufferHandleLow = xgb.Get32(buf[b:]) b += 4 + 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 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 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] = 5 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -675,219 +803,6 @@ 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 { - *xgb.Cookie -} - -// DestroyContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) - return DestroyContextCookie{cookie} -} - -// DestroyContextChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyContextCookie.Check() -func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) - return DestroyContextCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for DestroyContext -// destroyContextRequest writes a DestroyContext request to a byte slice. -func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Screen) - b += 4 - - xgb.Put32(buf[b:], Context) - b += 4 - - return buf -} - -// CreateDrawableCookie is a cookie used only for CreateDrawable requests. -type CreateDrawableCookie struct { - *xgb.Cookie -} - -// CreateDrawable sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply() -func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) - return CreateDrawableCookie{cookie} -} - -// CreateDrawableUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) - return CreateDrawableCookie{cookie} -} - -// CreateDrawableReply represents the data returned from a CreateDrawable request. -type CreateDrawableReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - HwDrawableHandle uint32 -} - -// Reply blocks and returns the reply data for a CreateDrawable request. -func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return createDrawableReply(buf), nil -} - -// createDrawableReply reads a byte slice into a CreateDrawableReply value. -func createDrawableReply(buf []byte) *CreateDrawableReply { - v := new(CreateDrawableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.HwDrawableHandle = xgb.Get32(buf[b:]) - b += 4 - - return v -} - -// Write request to wire for CreateDrawable -// createDrawableRequest writes a CreateDrawable request to a byte slice. -func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Screen) - b += 4 - - xgb.Put32(buf[b:], Drawable) - b += 4 - - return buf -} - -// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. -type DestroyDrawableCookie struct { - *xgb.Cookie -} - -// DestroyDrawable sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) - return DestroyDrawableCookie{cookie} -} - -// DestroyDrawableChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() -func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) - return DestroyDrawableCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyDrawableCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for DestroyDrawable -// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. -func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Screen) - b += 4 - - xgb.Put32(buf[b:], Drawable) - b += 4 - return buf } @@ -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:]) + v.SareaHandleLow = xgb.Get32(buf[b:]) b += 4 - v.FramebufferHandleHigh = xgb.Get32(buf[b:]) + v.SareaHandleHigh = xgb.Get32(buf[b:]) b += 4 - v.FramebufferOriginOffset = xgb.Get32(buf[b:]) + v.BusIdLen = xgb.Get32(buf[b:]) b += 4 - v.FramebufferSize = xgb.Get32(buf[b:]) - b += 4 + b += 12 // padding - 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 + { + byteString := make([]byte, v.BusIdLen) + copy(byteString[:v.BusIdLen], buf[b:]) + v.BusId = string(byteString) + b += xgb.Pad(int(v.BusIdLen)) } - b = xgb.Pad(b) return v } -// Write request to wire for GetDeviceInfo -// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice. -func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { +// Write request to wire for OpenConnection +// openConnectionRequest writes a OpenConnection request to a byte slice. +func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1130,7 +1036,7 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1142,43 +1048,43 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// AuthConnectionCookie is a cookie used only for AuthConnection requests. -type AuthConnectionCookie struct { +// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. +type QueryDirectRenderingCapableCookie struct { *xgb.Cookie } -// AuthConnection sends a checked request. -// If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply() -func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { +// QueryDirectRenderingCapable sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply() +func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) - return AuthConnectionCookie{cookie} + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} } -// AuthConnectionUnchecked sends an unchecked request. +// QueryDirectRenderingCapableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { +func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) - return AuthConnectionCookie{cookie} + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} } -// AuthConnectionReply represents the data returned from a AuthConnection request. -type AuthConnectionReply struct { +// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. +type QueryDirectRenderingCapableReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Authenticated uint32 + IsCapable bool } -// Reply blocks and returns the reply data for a AuthConnection request. -func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { +// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request. +func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1186,12 +1092,12 @@ func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { if buf == nil { return nil, nil } - return authConnectionReply(buf), nil + return queryDirectRenderingCapableReply(buf), nil } -// authConnectionReply reads a byte slice into a AuthConnectionReply value. -func authConnectionReply(buf []byte) *AuthConnectionReply { - v := new(AuthConnectionReply) +// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. +func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { + v := new(QueryDirectRenderingCapableReply) b := 1 // skip reply determinant b += 1 // padding @@ -1202,23 +1108,27 @@ func authConnectionReply(buf []byte) *AuthConnectionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Authenticated = xgb.Get32(buf[b:]) - b += 4 + if buf[b] == 1 { + v.IsCapable = true + } else { + v.IsCapable = false + } + b += 1 return v } -// Write request to wire for AuthConnection -// authConnectionRequest writes a AuthConnection request to a byte slice. -func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { - size := 12 +// Write request to wire for QueryDirectRenderingCapable +// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice. +func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1227,8 +1137,98 @@ func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Magic) + return buf +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + DriMajorVersion uint16 + DriMinorVersion uint16 + DriMinorPatch uint32 +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 + v.DriMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorPatch = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + return buf } diff --git a/nexgb/xf86vidmode/xf86vidmode.go b/nexgb/xf86vidmode/xf86vidmode.go index 7665cbf..17c3f3c 100644 --- a/nexgb/xf86vidmode/xf86vidmode.go +++ b/nexgb/xf86vidmode/xf86vidmode.go @@ -2,7 +2,7 @@ package xf86vidmode /* - This file was generated by xf86vidmode.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by xf86vidmode.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,193 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -const ( - ModeFlagPositiveHsync = 1 - ModeFlagNegativeHsync = 2 - ModeFlagPositiveVsync = 4 - ModeFlagNegativeVsync = 8 - ModeFlagInterlace = 16 - ModeFlagCompositeSync = 32 - ModeFlagPositiveCsync = 64 - ModeFlagNegativeCsync = 128 - ModeFlagHSkew = 256 - ModeFlagBroadcast = 512 - ModeFlagPixmux = 1024 - ModeFlagDoubleClock = 2048 - ModeFlagHalfClock = 4096 -) - -const ( - ClockFlagProgramable = 1 -) - -const ( - PermissionRead = 1 - PermissionWrite = 2 -) - -type Syncrange uint32 - -type Dotclock uint32 - -type ModeInfo struct { - Dotclock Dotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint32 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 4 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 -} - -// ModeInfoRead reads a byte slice into a ModeInfo value. -func ModeInfoRead(buf []byte, v *ModeInfo) int { - b := 0 - - v.Dotclock = Dotclock(xgb.Get32(buf[b:])) - b += 4 - - v.Hdisplay = xgb.Get16(buf[b:]) - b += 2 - - v.Hsyncstart = xgb.Get16(buf[b:]) - b += 2 - - v.Hsyncend = xgb.Get16(buf[b:]) - b += 2 - - v.Htotal = xgb.Get16(buf[b:]) - b += 2 - - v.Hskew = xgb.Get32(buf[b:]) - b += 4 - - v.Vdisplay = xgb.Get16(buf[b:]) - b += 2 - - v.Vsyncstart = xgb.Get16(buf[b:]) - b += 2 - - v.Vsyncend = xgb.Get16(buf[b:]) - b += 2 - - v.Vtotal = xgb.Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Privsize = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// ModeInfoReadList reads a byte slice into a list of ModeInfo values. -func ModeInfoReadList(buf []byte, dest []ModeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ModeInfo{} - b += ModeInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a ModeInfo value to a byte slice. -func (v ModeInfo) Bytes() []byte { - buf := make([]byte, 48) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Dotclock)) - b += 4 - - xgb.Put16(buf[b:], v.Hdisplay) - b += 2 - - xgb.Put16(buf[b:], v.Hsyncstart) - b += 2 - - xgb.Put16(buf[b:], v.Hsyncend) - b += 2 - - xgb.Put16(buf[b:], v.Htotal) - b += 2 - - xgb.Put32(buf[b:], v.Hskew) - b += 4 - - xgb.Put16(buf[b:], v.Vdisplay) - b += 2 - - xgb.Put16(buf[b:], v.Vsyncstart) - b += 2 - - xgb.Put16(buf[b:], v.Vsyncend) - b += 2 - - xgb.Put16(buf[b:], v.Vtotal) - b += 2 - - b += 4 // padding - - xgb.Put32(buf[b:], v.Flags) - b += 4 - - b += 12 // padding - - xgb.Put32(buf[b:], v.Privsize) - b += 4 - - return buf -} - -// ModeInfoListBytes writes a list of ModeInfo values to a byte slice. -func ModeInfoListBytes(buf []byte, list []ModeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - // BadBadClock is the error number for a BadBadClock. const BadBadClock = 0 @@ -365,18 +178,18 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][2] = BadVTimingsErrorNew } -// BadModeUnsuitable is the error number for a BadModeUnsuitable. -const BadModeUnsuitable = 3 +// BadClientNotLocal is the error number for a BadClientNotLocal. +const BadClientNotLocal = 5 -type ModeUnsuitableError struct { +type ClientNotLocalError struct { Sequence uint16 NiceName string } -// ModeUnsuitableErrorNew constructs a ModeUnsuitableError value that implements xgb.Error from a byte slice. -func ModeUnsuitableErrorNew(buf []byte) xgb.Error { - v := ModeUnsuitableError{} - v.NiceName = "ModeUnsuitable" +// ClientNotLocalErrorNew constructs a ClientNotLocalError value that implements xgb.Error from a byte slice. +func ClientNotLocalErrorNew(buf []byte) xgb.Error { + v := ClientNotLocalError{} + v.NiceName = "ClientNotLocal" b := 1 // skip error determinant b += 1 // don't read error number @@ -387,30 +200,36 @@ func ModeUnsuitableErrorNew(buf []byte) xgb.Error { return v } -// SequenceId returns the sequence id attached to the BadModeUnsuitable error. +// SequenceId returns the sequence id attached to the BadClientNotLocal error. // This is mostly used internally. -func (err ModeUnsuitableError) SequenceId() uint16 { +func (err ClientNotLocalError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadModeUnsuitable error. If no bad value exists, 0 is returned. -func (err ModeUnsuitableError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadClientNotLocal error. If no bad value exists, 0 is returned. +func (err ClientNotLocalError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadModeUnsuitable error. +// Error returns a rudimentary string representation of the BadClientNotLocal error. -func (err ModeUnsuitableError) Error() string { +func (err ClientNotLocalError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadModeUnsuitable {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadClientNotLocal {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][3] = ModeUnsuitableErrorNew + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][5] = ClientNotLocalErrorNew } +const ( + ClockFlagProgramable = 1 +) + +type Dotclock uint32 + // BadExtensionDisabled is the error number for a BadExtensionDisabled. const BadExtensionDisabled = 4 @@ -457,18 +276,168 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][4] = ExtensionDisabledErrorNew } -// BadClientNotLocal is the error number for a BadClientNotLocal. -const BadClientNotLocal = 5 +const ( + ModeFlagPositiveHsync = 1 + ModeFlagNegativeHsync = 2 + ModeFlagPositiveVsync = 4 + ModeFlagNegativeVsync = 8 + ModeFlagInterlace = 16 + ModeFlagCompositeSync = 32 + ModeFlagPositiveCsync = 64 + ModeFlagNegativeCsync = 128 + ModeFlagHSkew = 256 + ModeFlagBroadcast = 512 + ModeFlagPixmux = 1024 + ModeFlagDoubleClock = 2048 + ModeFlagHalfClock = 4096 +) -type ClientNotLocalError struct { +type ModeInfo struct { + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint32 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 4 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 +} + +// ModeInfoRead reads a byte slice into a ModeInfo value. +func ModeInfoRead(buf []byte, v *ModeInfo) int { + b := 0 + + v.Dotclock = Dotclock(xgb.Get32(buf[b:])) + b += 4 + + v.Hdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get32(buf[b:]) + b += 4 + + v.Vdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Privsize = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// ModeInfoReadList reads a byte slice into a list of ModeInfo values. +func ModeInfoReadList(buf []byte, dest []ModeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ModeInfo{} + b += ModeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a ModeInfo value to a byte slice. +func (v ModeInfo) Bytes() []byte { + buf := make([]byte, 48) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Dotclock)) + b += 4 + + xgb.Put16(buf[b:], v.Hdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Htotal) + b += 2 + + xgb.Put32(buf[b:], v.Hskew) + b += 4 + + xgb.Put16(buf[b:], v.Vdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Vtotal) + b += 2 + + b += 4 // padding + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], v.Privsize) + b += 4 + + return buf +} + +// ModeInfoListBytes writes a list of ModeInfo values to a byte slice. +func ModeInfoListBytes(buf []byte, list []ModeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// BadModeUnsuitable is the error number for a BadModeUnsuitable. +const BadModeUnsuitable = 3 + +type ModeUnsuitableError struct { Sequence uint16 NiceName string } -// ClientNotLocalErrorNew constructs a ClientNotLocalError value that implements xgb.Error from a byte slice. -func ClientNotLocalErrorNew(buf []byte) xgb.Error { - v := ClientNotLocalError{} - v.NiceName = "ClientNotLocal" +// ModeUnsuitableErrorNew constructs a ModeUnsuitableError value that implements xgb.Error from a byte slice. +func ModeUnsuitableErrorNew(buf []byte) xgb.Error { + v := ModeUnsuitableError{} + v.NiceName = "ModeUnsuitable" b := 1 // skip error determinant b += 1 // don't read error number @@ -479,30 +448,37 @@ func ClientNotLocalErrorNew(buf []byte) xgb.Error { return v } -// SequenceId returns the sequence id attached to the BadClientNotLocal error. +// SequenceId returns the sequence id attached to the BadModeUnsuitable error. // This is mostly used internally. -func (err ClientNotLocalError) SequenceId() uint16 { +func (err ModeUnsuitableError) SequenceId() uint16 { return err.Sequence } -// BadId returns the 'BadValue' number if one exists for the BadClientNotLocal error. If no bad value exists, 0 is returned. -func (err ClientNotLocalError) BadId() uint32 { +// BadId returns the 'BadValue' number if one exists for the BadModeUnsuitable error. If no bad value exists, 0 is returned. +func (err ModeUnsuitableError) BadId() uint32 { return 0 } -// Error returns a rudimentary string representation of the BadClientNotLocal error. +// Error returns a rudimentary string representation of the BadModeUnsuitable error. -func (err ClientNotLocalError) Error() string { +func (err ModeUnsuitableError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadClientNotLocal {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "BadModeUnsuitable {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][5] = ClientNotLocalErrorNew + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][3] = ModeUnsuitableErrorNew } +const ( + PermissionRead = 1 + PermissionWrite = 2 +) + +type Syncrange uint32 + // BadZoomLocked is the error number for a BadZoomLocked. const BadZoomLocked = 6 @@ -549,689 +525,29 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][6] = ZoomLockedErrorNew } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { - *xgb.Cookie -} +// Skipping definition for base type 'Bool' -// QueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() -func QueryVersion(c *xgb.Conn) QueryVersionCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} -} +// Skipping definition for base type 'Byte' -// QueryVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} -} +// Skipping definition for base type 'Card8' -// 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 -} +// Skipping definition for base type 'Char' -// 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 -} +// Skipping definition for base type 'Void' -// 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 'Double' - b += 1 // padding +// Skipping definition for base type 'Float' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Int32' - v.MajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int8' - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card16' - 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-VIDMODEEXTENSION"] - 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 -} - -// GetModeLineCookie is a cookie used only for GetModeLine requests. -type GetModeLineCookie 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 { - 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.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getModeLineRequest(c, Screen), cookie) - return GetModeLineCookie{cookie} -} - -// GetModeLineUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { - 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.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getModeLineRequest(c, Screen), cookie) - return GetModeLineCookie{cookie} -} - -// GetModeLineReply represents the data returned from a GetModeLine request. -type GetModeLineReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Dotclock Dotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint16 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 2 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 - Private []byte // size: xgb.Pad((int(Privsize) * 1)) -} - -// 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 -} - -// getModeLineReply reads a byte slice into a GetModeLineReply value. -func getModeLineReply(buf []byte) *GetModeLineReply { - v := new(GetModeLineReply) - 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.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.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.Flags = 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)) - - return v -} - -// Write request to wire for GetModeLine -// getModeLineRequest writes a GetModeLine request to a byte slice. -func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// 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:], 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 -} - -// SwitchModeCookie is a cookie used only for SwitchMode requests. -type SwitchModeCookie struct { - *xgb.Cookie -} - -// SwitchMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SwitchMode(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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:], Screen) - b += 2 - - xgb.Put16(buf[b:], Zoom) - b += 2 - - return buf -} - -// GetMonitorCookie is a cookie used only for GetMonitor requests. -type GetMonitorCookie 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 { - 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.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getMonitorRequest(c, Screen), cookie) - return GetMonitorCookie{cookie} -} - -// GetMonitorUnchecked 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 { - 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.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getMonitorRequest(c, Screen), cookie) - return GetMonitorCookie{cookie} -} - -// 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 - 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 GetMonitor request. -func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getMonitorReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - 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 - - b += 20 // 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 - } - 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 - } - b = xgb.Pad(b) - - { - byteString := make([]byte, v.VendorLength) - copy(byteString[:v.VendorLength], buf[b:]) - v.Vendor = string(byteString) - b += xgb.Pad(int(v.VendorLength)) - } - - v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) - copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) - b += xgb.Pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) - - { - byteString := make([]byte, v.ModelLength) - copy(byteString[:v.ModelLength], buf[b:]) - v.Model = string(byteString) - b += xgb.Pad(int(v.ModelLength)) - } - - return v -} - -// Write request to wire for GetMonitor -// getMonitorRequest writes a GetMonitor request to a byte slice. -func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { - 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - 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.Put16(buf[b:], Screen) - b += 2 - - xgb.Put16(buf[b:], Lock) - b += 2 - - 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(getAllModeLinesRequest(c, Screen), cookie) - return GetAllModeLinesCookie{cookie} -} - -// GetAllModeLinesUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetAllModeLines' 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} -} - -// GetAllModeLinesReply represents the data returned from a GetAllModeLines request. -type GetAllModeLinesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Modecount uint32 - // padding: 20 bytes - Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) -} - -// Reply blocks and returns the reply data for a GetAllModeLines request. -func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getAllModeLinesReply(buf), nil -} - -// getAllModeLinesReply reads a byte slice into a GetAllModeLinesReply value. -func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { - v := new(GetAllModeLinesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Modecount = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Modeinfo = make([]ModeInfo, v.Modecount) - b += ModeInfoReadList(buf[b:], v.Modeinfo) - - return v -} - -// Write request to wire for GetAllModeLines -// getAllModeLinesRequest writes a GetAllModeLines request to a byte slice. -func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - 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.Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} +// Skipping definition for base type 'Card32' // AddModeLineCookie is a cookie used only for AddModeLine requests. type AddModeLineCookie struct { @@ -1466,44 +782,45 @@ func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdispl return buf } -// ValidateModeLineCookie is a cookie used only for ValidateModeLine requests. -type ValidateModeLineCookie struct { +// GetAllModeLinesCookie is a cookie used only for GetAllModeLines requests. +type GetAllModeLinesCookie 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 { +// 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 'ValidateModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + panic("Cannot issue request 'GetAllModeLines' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") } cookie := c.NewCookie(true, 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(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} } -// ValidateModeLineUnchecked 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 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 GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { 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 'GetAllModeLines' 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(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} } -// ValidateModeLineReply represents the data returned from a ValidateModeLine request. -type ValidateModeLineReply 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 - Status uint32 + Modecount uint32 // padding: 20 bytes + Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) } -// 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 GetAllModeLines request. +func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1511,12 +828,12 @@ func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { if buf == nil { return nil, nil } - return validateModeLineReply(buf), nil + return getAllModeLinesReply(buf), nil } -// validateModeLineReply reads a byte slice into a ValidateModeLineReply value. -func validateModeLineReply(buf []byte) *ValidateModeLineReply { - v := new(ValidateModeLineReply) +// 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 @@ -1527,253 +844,20 @@ func validateModeLineReply(buf []byte) *ValidateModeLineReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Status = xgb.Get32(buf[b:]) + v.Modecount = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - return v -} - -// 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] = 9 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Screen) - b += 4 - - xgb.Put32(buf[b:], 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 -} - -// SwitchToModeCookie is a cookie used only for SwitchToMode requests. -type SwitchToModeCookie 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 { - 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.") - } - 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} -} - -// 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 'SwitchToMode' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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 - - 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 -} - -// GetViewPortCookie is a cookie used only for GetViewPort requests. -type GetViewPortCookie struct { - *xgb.Cookie -} - -// GetViewPort sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetViewPortCookie.Reply() -func GetViewPort(c *xgb.Conn, Screen uint16) GetViewPortCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getViewPortRequest(c, Screen), cookie) - return GetViewPortCookie{cookie} -} - -// GetViewPortUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetViewPortUnchecked(c *xgb.Conn, Screen uint16) GetViewPortCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'GetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getViewPortRequest(c, Screen), cookie) - return GetViewPortCookie{cookie} -} - -// GetViewPortReply represents the data returned from a GetViewPort request. -type GetViewPortReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - X uint32 - Y uint32 - // padding: 16 bytes -} - -// Reply blocks and returns the reply data for a GetViewPort request. -func (cook GetViewPortCookie) Reply() (*GetViewPortReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getViewPortReply(buf), nil -} - -// getViewPortReply reads a byte slice into a GetViewPortReply value. -func getViewPortReply(buf []byte) *GetViewPortReply { - v := new(GetViewPortReply) - 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 = xgb.Get32(buf[b:]) - b += 4 - - v.Y = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding + v.Modeinfo = make([]ModeInfo, v.Modecount) + b += ModeInfoReadList(buf[b:], v.Modeinfo) return v } -// Write request to wire for GetViewPort -// getViewPortRequest writes a GetViewPort request to a byte slice. -func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { +// 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) @@ -1781,7 +865,7 @@ func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1795,69 +879,6 @@ func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// SetViewPortCookie is a cookie used only for SetViewPort requests. -type SetViewPortCookie struct { - *xgb.Cookie -} - -// SetViewPort 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 { - 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) - return SetViewPortCookie{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 { - 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) - return SetViewPortCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 12 // 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 - - xgb.Put32(buf[b:], X) - b += 4 - - xgb.Put32(buf[b:], Y) - b += 4 - - return buf -} - // GetDotClocksCookie is a cookie used only for GetDotClocks requests. type GetDotClocksCookie struct { *xgb.Cookie @@ -1967,132 +988,6 @@ func getDotClocksRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// SetClientVersionCookie is a cookie used only for SetClientVersion requests. -type SetClientVersionCookie struct { - *xgb.Cookie -} - -// SetClientVersion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetClientVersion(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetClientVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) - return SetClientVersionCookie{cookie} -} - -// SetClientVersionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetClientVersionCookie.Check() -func SetClientVersionChecked(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetClientVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) - return SetClientVersionCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetClientVersionCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetClientVersion -// setClientVersionRequest writes a SetClientVersion request to a byte slice. -func setClientVersionRequest(c *xgb.Conn, Major uint16, Minor uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - 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.Put16(buf[b:], Major) - b += 2 - - xgb.Put16(buf[b:], Minor) - b += 2 - - return buf -} - -// SetGammaCookie is a cookie used only for SetGamma requests. -type SetGammaCookie struct { - *xgb.Cookie -} - -// SetGamma sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetGamma(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) - return SetGammaCookie{cookie} -} - -// SetGammaChecked sends a checked request. -// If an error occurs, it can be retrieved using SetGammaCookie.Check() -func SetGammaChecked(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { - if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { - panic("Cannot issue request 'SetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) - return SetGammaCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetGammaCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetGamma -// setGammaRequest writes a SetGamma request to a byte slice. -func setGammaRequest(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] - 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.Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - xgb.Put32(buf[b:], Red) - b += 4 - - xgb.Put32(buf[b:], Green) - b += 4 - - xgb.Put32(buf[b:], Blue) - b += 4 - - b += 12 // padding - - return buf -} - // GetGammaCookie is a cookie used only for GetGamma requests. type GetGammaCookie struct { *xgb.Cookie @@ -2312,82 +1207,6 @@ func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { return buf } -// SetGammaRampCookie is a cookie used only for SetGammaRamp requests. -type SetGammaRampCookie struct { - *xgb.Cookie -} - -// SetGammaRamp 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 { - 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.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) - return SetGammaRampCookie{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 { - 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) - return SetGammaRampCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 18 // 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 - - 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 -} - // GetGammaRampSizeCookie is a cookie used only for GetGammaRampSize requests. type GetGammaRampSizeCookie struct { *xgb.Cookie @@ -2481,6 +1300,293 @@ func getGammaRampSizeRequest(c *xgb.Conn, Screen uint16) []byte { return buf } +// GetModeLineCookie is a cookie used only for GetModeLine requests. +type GetModeLineCookie 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 { + 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.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{cookie} +} + +// GetModeLineUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { + 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.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{cookie} +} + +// GetModeLineReply represents the data returned from a GetModeLine request. +type GetModeLineReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint16 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 2 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 + Private []byte // size: xgb.Pad((int(Privsize) * 1)) +} + +// 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 +} + +// getModeLineReply reads a byte slice into a GetModeLineReply value. +func getModeLineReply(buf []byte) *GetModeLineReply { + v := new(GetModeLineReply) + 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.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.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.Flags = 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)) + + return v +} + +// Write request to wire for GetModeLine +// getModeLineRequest writes a GetModeLine request to a byte slice. +func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// GetMonitorCookie is a cookie used only for GetMonitor requests. +type GetMonitorCookie 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 { + 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.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} +} + +// GetMonitorUnchecked 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 { + 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.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} +} + +// 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 + 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 GetMonitor request. +func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMonitorReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + 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 + + b += 20 // 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 + } + 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 + } + b = xgb.Pad(b) + + { + byteString := make([]byte, v.VendorLength) + copy(byteString[:v.VendorLength], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLength)) + } + + v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) + copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) + b += xgb.Pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) + + { + byteString := make([]byte, v.ModelLength) + copy(byteString[:v.ModelLength], buf[b:]) + v.Model = string(byteString) + b += xgb.Pad(int(v.ModelLength)) + } + + return v +} + +// Write request to wire for GetMonitor +// getMonitorRequest writes a GetMonitor request to a byte slice. +func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { + 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 +} + // GetPermissionsCookie is a cookie used only for GetPermissions requests. type GetPermissionsCookie struct { *xgb.Cookie @@ -2573,3 +1679,897 @@ func getPermissionsRequest(c *xgb.Conn, Screen uint16) []byte { return buf } + +// GetViewPortCookie is a cookie used only for GetViewPort requests. +type GetViewPortCookie struct { + *xgb.Cookie +} + +// GetViewPort sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetViewPortCookie.Reply() +func GetViewPort(c *xgb.Conn, Screen uint16) GetViewPortCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'GetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getViewPortRequest(c, Screen), cookie) + return GetViewPortCookie{cookie} +} + +// GetViewPortUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetViewPortUnchecked(c *xgb.Conn, Screen uint16) GetViewPortCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'GetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getViewPortRequest(c, Screen), cookie) + return GetViewPortCookie{cookie} +} + +// GetViewPortReply represents the data returned from a GetViewPort request. +type GetViewPortReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + X uint32 + Y uint32 + // padding: 16 bytes +} + +// Reply blocks and returns the reply data for a GetViewPort request. +func (cook GetViewPortCookie) Reply() (*GetViewPortReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getViewPortReply(buf), nil +} + +// getViewPortReply reads a byte slice into a GetViewPortReply value. +func getViewPortReply(buf []byte) *GetViewPortReply { + v := new(GetViewPortReply) + 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 = xgb.Get32(buf[b:]) + b += 4 + + v.Y = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for GetViewPort +// getViewPortRequest writes a GetViewPort request to a byte slice. +func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.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:], 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 +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + 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.Get16(buf[b:]) + b += 2 + + v.MinorVersion = 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) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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 +} + +// SetClientVersionCookie is a cookie used only for SetClientVersion requests. +type SetClientVersionCookie struct { + *xgb.Cookie +} + +// SetClientVersion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetClientVersion(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'SetClientVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) + return SetClientVersionCookie{cookie} +} + +// SetClientVersionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClientVersionCookie.Check() +func SetClientVersionChecked(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'SetClientVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) + return SetClientVersionCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetClientVersionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClientVersion +// setClientVersionRequest writes a SetClientVersion request to a byte slice. +func setClientVersionRequest(c *xgb.Conn, Major uint16, Minor uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.Put16(buf[b:], Major) + b += 2 + + xgb.Put16(buf[b:], Minor) + b += 2 + + return buf +} + +// SetGammaCookie is a cookie used only for SetGamma requests. +type SetGammaCookie struct { + *xgb.Cookie +} + +// SetGamma sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetGamma(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'SetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) + return SetGammaCookie{cookie} +} + +// SetGammaChecked sends a checked request. +// If an error occurs, it can be retrieved using SetGammaCookie.Check() +func SetGammaChecked(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { + if _, ok := c.Extensions["XFREE86-VIDMODEEXTENSION"]; !ok { + panic("Cannot issue request 'SetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) + return SetGammaCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetGammaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetGamma +// setGammaRequest writes a SetGamma request to a byte slice. +func setGammaRequest(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + 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.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Red) + b += 4 + + xgb.Put32(buf[b:], Green) + b += 4 + + xgb.Put32(buf[b:], Blue) + b += 4 + + b += 12 // padding + + return buf +} + +// SetGammaRampCookie is a cookie used only for SetGammaRamp requests. +type SetGammaRampCookie struct { + *xgb.Cookie +} + +// SetGammaRamp 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 { + 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.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{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 { + 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 18 // 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 + + 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 +} + +// SetViewPortCookie is a cookie used only for SetViewPort requests. +type SetViewPortCookie struct { + *xgb.Cookie +} + +// SetViewPort 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 { + 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.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{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 { + 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 12 // 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 + + xgb.Put32(buf[b:], X) + b += 4 + + xgb.Put32(buf[b:], Y) + b += 4 + + return buf +} + +// SwitchModeCookie is a cookie used only for SwitchMode requests. +type SwitchModeCookie struct { + *xgb.Cookie +} + +// SwitchMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SwitchMode(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { + 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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:], Screen) + b += 2 + + xgb.Put16(buf[b:], Zoom) + b += 2 + + return buf +} + +// SwitchToModeCookie is a cookie used only for SwitchToMode requests. +type SwitchToModeCookie 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 { + 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.") + } + 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} +} + +// 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 'SwitchToMode' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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 + + 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 +} + +// ValidateModeLineCookie is a cookie used only for ValidateModeLine requests. +type ValidateModeLineCookie 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 { + 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.") + } + 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} +} + +// ValidateModeLineUnchecked 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 { + 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.") + } + 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} +} + +// 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 + Status uint32 + // padding: 20 bytes +} + +// 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 + } + if buf == nil { + return nil, nil + } + return validateModeLineReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + return v +} + +// 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] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], 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,29 +42,173 @@ 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 ( + CursorNotifyDisplayCursor = 0 +) + +const ( + 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 ( + RegionNone = 0 +) + +const ( + SaveSetMappingMap = 0 + SaveSetMappingUnmap = 1 +) const ( SaveSetModeInsert = 0 @@ -76,11 +220,6 @@ const ( SaveSetTargetRoot = 1 ) -const ( - SaveSetMappingMap = 0 - SaveSetMappingUnmap = 1 -) - const ( SelectionEventSetSelectionOwner = 0 SelectionEventSelectionWindowDestroy = 1 @@ -93,28 +232,6 @@ const ( SelectionEventMaskSelectionClientClose = 4 ) -const ( - CursorNotifyDisplayCursor = 0 -) - -const ( - CursorNotifyMaskDisplayCursor = 1 -) - -const ( - RegionNone = 0 -) - -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,223 +335,66 @@ 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 - - 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 -} - -// BadBadRegion is the error number for a BadBadRegion. -const BadBadRegion = 0 - -type BadRegionError struct { - Sequence uint16 - NiceName string -} - -// BadRegionErrorNew constructs a BadRegionError value that implements xgb.Error from a byte slice. -func BadRegionErrorNew(buf []byte) xgb.Error { - v := BadRegionError{} - v.NiceName = "BadRegion" - - 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 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. - -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, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew -} - -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// ChangeCursorCookie is a cookie used only for ChangeCursor requests. +type ChangeCursorCookie 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. +// ChangeCursor 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 ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { 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 'ChangeCursor' 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} + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err +// 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.") } - if buf == nil { - return nil, nil - } - return queryVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{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 ChangeCursorCookie) 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 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) @@ -442,21 +402,84 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVers buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 0 // 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:], ClientMajorVersion) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - xgb.Put32(buf[b:], ClientMinorVersion) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } +// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests. +type ChangeCursorByNameCookie struct { + *xgb.Cookie +} + +// ChangeCursorByName 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'ChangeCursorByName' 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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(Src)) + b += 4 + + xgb.Put16(buf[b:], Nbytes) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) + + return buf +} + // ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. type ChangeSaveSetCookie struct { *xgb.Cookie @@ -523,103 +546,42 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window return buf } -// SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests. -type SelectSelectionInputCookie struct { +// 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. -type SelectCursorInputCookie struct { - *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 { +// Write request to wire for CopyRegion +// copyRegionRequest writes a CopyRegion request to a byte slice. +func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -627,16 +589,530 @@ func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint3 buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// CreateRegionCookie is a cookie used only for CreateRegion requests. +type CreateRegionCookie struct { + *xgb.Cookie +} + +// 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 { + panic("Cannot issue request 'CreateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) + return CreateRegionCookie{cookie} +} + +// CreateRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionCookie.Check() +func CreateRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) + return CreateRegionCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegion +// createRegionRequest writes a CreateRegion request to a byte slice. +func createRegionRequest(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] = 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 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// CreateRegionFromBitmapCookie is a cookie used only for CreateRegionFromBitmap requests. +type CreateRegionFromBitmapCookie struct { + *xgb.Cookie +} + +// CreateRegionFromBitmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateRegionFromBitmap(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromBitmap' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) + return CreateRegionFromBitmapCookie{cookie} +} + +// CreateRegionFromBitmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromBitmapCookie.Check() +func CreateRegionFromBitmapChecked(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromBitmap' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) + return CreateRegionFromBitmapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateRegionFromBitmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromBitmap +// createRegionFromBitmapRequest writes a CreateRegionFromBitmap request to a byte slice. +func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Bitmap)) + b += 4 + + return buf +} + +// CreateRegionFromGCCookie is a cookie used only for CreateRegionFromGC requests. +type CreateRegionFromGCCookie struct { + *xgb.Cookie +} + +// CreateRegionFromGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateRegionFromGC(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromGC' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) + return CreateRegionFromGCCookie{cookie} +} + +// CreateRegionFromGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromGCCookie.Check() +func CreateRegionFromGCChecked(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromGC' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) + return CreateRegionFromGCCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateRegionFromGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromGC +// createRegionFromGCRequest writes a CreateRegionFromGC request to a byte slice. +func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + return buf +} + +// CreateRegionFromPictureCookie is a cookie used only for CreateRegionFromPicture requests. +type CreateRegionFromPictureCookie struct { + *xgb.Cookie +} + +// CreateRegionFromPicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateRegionFromPicture(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromPicture' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) + return CreateRegionFromPictureCookie{cookie} +} + +// CreateRegionFromPictureChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromPictureCookie.Check() +func CreateRegionFromPictureChecked(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromPicture' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) + return CreateRegionFromPictureCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateRegionFromPictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromPicture +// createRegionFromPictureRequest writes a CreateRegionFromPicture request to a byte slice. +func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.Picture) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + 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 - xgb.Put32(buf[b:], EventMask) + buf[b] = byte(Kind) + b += 1 + + b += 3 // padding + + return buf +} + +// DestroyRegionCookie is a cookie used only for DestroyRegion requests. +type DestroyRegionCookie struct { + *xgb.Cookie +} + +// DestroyRegion 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'DestroyRegion' 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} +} + +// 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 'DestroyRegion' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + +// ExpandRegionCookie is a cookie used only for ExpandRegion requests. +type ExpandRegionCookie struct { + *xgb.Cookie +} + +// ExpandRegion 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'ExpandRegion' 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} +} + +// 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 'ExpandRegion' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + 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 +} + +// FetchRegionCookie is a cookie used only for FetchRegion requests. +type FetchRegionCookie 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'FetchRegion' 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} +} + +// 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 'FetchRegion' 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} +} + +// 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)) +} + +// Reply blocks and returns the reply data for a FetchRegion request. +func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return fetchRegionReply(buf), nil +} + +// fetchRegionReply reads a byte slice into a FetchRegionReply value. +func fetchRegionReply(buf []byte) *FetchRegionReply { + v := new(FetchRegionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Extents = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Extents) + + b += 16 // padding + + v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for FetchRegion +// fetchRegionRequest writes a FetchRegion request to a byte slice. +func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 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(Region)) b += 4 return buf @@ -762,1294 +1238,6 @@ func getCursorImageRequest(c *xgb.Conn) []byte { return buf } -// CreateRegionCookie is a cookie used only for CreateRegion requests. -type CreateRegionCookie struct { - *xgb.Cookie -} - -// 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 { - panic("Cannot issue request 'CreateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) - return CreateRegionCookie{cookie} -} - -// CreateRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRegionCookie.Check() -func CreateRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) - return CreateRegionCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateRegionCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateRegion -// createRegionRequest writes a CreateRegion request to a byte slice. -func createRegionRequest(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] = 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 - - b += xproto.RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// CreateRegionFromBitmapCookie is a cookie used only for CreateRegionFromBitmap requests. -type CreateRegionFromBitmapCookie struct { - *xgb.Cookie -} - -// CreateRegionFromBitmap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateRegionFromBitmap(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromBitmap' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) - return CreateRegionFromBitmapCookie{cookie} -} - -// CreateRegionFromBitmapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRegionFromBitmapCookie.Check() -func CreateRegionFromBitmapChecked(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromBitmap' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) - return CreateRegionFromBitmapCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateRegionFromBitmapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateRegionFromBitmap -// createRegionFromBitmapRequest writes a CreateRegionFromBitmap request to a byte slice. -func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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(Region)) - b += 4 - - xgb.Put32(buf[b:], uint32(Bitmap)) - b += 4 - - 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 -} - -// CreateRegionFromGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateRegionFromGC(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromGC' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) - return CreateRegionFromGCCookie{cookie} -} - -// CreateRegionFromGCChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRegionFromGCCookie.Check() -func CreateRegionFromGCChecked(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromGC' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) - return CreateRegionFromGCCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateRegionFromGCCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateRegionFromGC -// createRegionFromGCRequest writes a CreateRegionFromGC request to a byte slice. -func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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(Region)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - return buf -} - -// CreateRegionFromPictureCookie is a cookie used only for CreateRegionFromPicture requests. -type CreateRegionFromPictureCookie struct { - *xgb.Cookie -} - -// CreateRegionFromPicture sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateRegionFromPicture(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromPicture' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) - return CreateRegionFromPictureCookie{cookie} -} - -// CreateRegionFromPictureChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRegionFromPictureCookie.Check() -func CreateRegionFromPictureChecked(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromPicture' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) - return CreateRegionFromPictureCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateRegionFromPictureCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateRegionFromPicture -// createRegionFromPictureRequest writes a CreateRegionFromPicture request to a byte slice. -func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.Picture) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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(Region)) - b += 4 - - xgb.Put32(buf[b:], uint32(Picture)) - b += 4 - - return buf -} - -// DestroyRegionCookie is a cookie used only for DestroyRegion requests. -type DestroyRegionCookie struct { - *xgb.Cookie -} - -// DestroyRegion 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'DestroyRegion' 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} -} - -// 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 'DestroyRegion' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Region)) - b += 4 - - 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) - return SetRegionCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 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 -} - -// CopyRegionCookie is a cookie used only for CopyRegion requests. -type CopyRegionCookie struct { - *xgb.Cookie -} - -// CopyRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CopyRegion' 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} -} - -// 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 'CopyRegion' 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} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyRegionCookie) Check() error { - return cook.Cookie.Check() -} - -// 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] = 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(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// UnionRegionCookie is a cookie used only for UnionRegion requests. -type UnionRegionCookie 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'UnionRegion' 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} -} - -// 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 'UnionRegion' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Source1)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// IntersectRegionCookie is a cookie used only for IntersectRegion requests. -type IntersectRegionCookie struct { - *xgb.Cookie -} - -// IntersectRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Source1)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// SubtractRegionCookie is a cookie used only for SubtractRegion requests. -type SubtractRegionCookie 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SubtractRegion' 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} -} - -// 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 'SubtractRegion' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Source1)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// InvertRegionCookie is a cookie used only for InvertRegion requests. -type InvertRegionCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - 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 InvertRegionCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for InvertRegion -// invertRegionRequest writes a InvertRegion request to a byte slice. -func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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 - - 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 { - *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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'TranslateRegion' 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} -} - -// 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 'TranslateRegion' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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(Region)) - b += 4 - - xgb.Put16(buf[b:], uint16(Dx)) - b += 2 - - xgb.Put16(buf[b:], uint16(Dy)) - b += 2 - - return buf -} - -// RegionExtentsCookie is a cookie used only for RegionExtents requests. -type RegionExtentsCookie struct { - *xgb.Cookie -} - -// 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.") - } - 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) - return RegionExtentsCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook RegionExtentsCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for RegionExtents -// regionExtentsRequest writes a RegionExtents request to a byte slice. -func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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 - - 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 { - *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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'FetchRegion' 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} -} - -// 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 'FetchRegion' 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} -} - -// 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)) -} - -// Reply blocks and returns the reply data for a FetchRegion request. -func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return fetchRegionReply(buf), nil -} - -// fetchRegionReply reads a byte slice into a FetchRegionReply value. -func fetchRegionReply(buf []byte) *FetchRegionReply { - v := new(FetchRegionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Extents = xproto.Rectangle{} - b += xproto.RectangleRead(buf[b:], &v.Extents) - - b += 16 // padding - - v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) - b += xproto.RectangleReadList(buf[b:], v.Rectangles) - - return v -} - -// Write request to wire for FetchRegion -// fetchRegionRequest writes a FetchRegion request to a byte slice. -func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 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(Region)) - b += 4 - - 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 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put32(buf[b:], uint32(Region)) - b += 4 - - xgb.Put16(buf[b:], uint16(XOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOrigin)) - b += 2 - - return buf -} - -// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests. -type SetWindowShapeRegionCookie struct { - *xgb.Cookie -} - -// SetWindowShapeRegion 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetWindowShapeRegion' 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} -} - -// 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 'SetWindowShapeRegion' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - 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(Dest)) - b += 4 - - buf[b] = byte(DestKind) - b += 1 - - b += 3 // padding - - xgb.Put16(buf[b:], uint16(XOffset)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOffset)) - b += 2 - - xgb.Put32(buf[b:], uint32(Region)) - b += 4 - - 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 - - xgb.Put32(buf[b:], uint32(Region)) - b += 4 - - xgb.Put16(buf[b:], uint16(XOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOrigin)) - b += 2 - - return buf -} - -// 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 - - xgb.Put32(buf[b:], uint32(Cursor)) - 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 { - *xgb.Cookie -} - -// GetCursorName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCursorNameCookie.Reply() -func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCursorNameRequest(c, Cursor), cookie) - return GetCursorNameCookie{cookie} -} - -// GetCursorNameUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getCursorNameRequest(c, Cursor), cookie) - return GetCursorNameCookie{cookie} -} - -// GetCursorNameReply represents the data returned from a GetCursorName request. -type GetCursorNameReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Atom xproto.Atom - Nbytes uint16 - // padding: 18 bytes - Name string // size: xgb.Pad((int(Nbytes) * 1)) -} - -// Reply blocks and returns the reply data for a GetCursorName request. -func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCursorNameReply(buf), nil -} - -// getCursorNameReply reads a byte slice into a GetCursorNameReply value. -func getCursorNameReply(buf []byte) *GetCursorNameReply { - v := new(GetCursorNameReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Atom = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 - - v.Nbytes = xgb.Get16(buf[b:]) - b += 2 - - b += 18 // padding - - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Nbytes)) - } - - return v -} - -// Write request to wire for GetCursorName -// getCursorNameRequest writes a GetCursorName request to a byte slice. -func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 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(Cursor)) - b += 4 - - return buf -} - // GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. type GetCursorImageAndNameCookie struct { *xgb.Cookie @@ -2186,194 +1374,106 @@ func getCursorImageAndNameRequest(c *xgb.Conn) []byte { return buf } -// ChangeCursorCookie is a cookie used only for ChangeCursor requests. -type ChangeCursorCookie struct { +// GetCursorNameCookie is a cookie used only for GetCursorName requests. +type GetCursorNameCookie struct { *xgb.Cookie } -// ChangeCursor sends an unchecked request. +// GetCursorName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCursorNameCookie.Reply() +func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} +} + +// GetCursorNameUnchecked sends an unchecked request. // 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 GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { 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 'GetCursorName' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") +// GetCursorNameReply represents the data returned from a GetCursorName request. +type GetCursorNameReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Atom xproto.Atom + Nbytes uint16 + // padding: 18 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) +} + +// 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) - return ChangeCursorCookie{cookie} + if buf == nil { + return nil, nil + } + return getCursorNameReply(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 ChangeCursorCookie) Check() error { - return cook.Cookie.Check() +// getCursorNameReply reads a byte slice into a GetCursorNameReply value. +func getCursorNameReply(buf []byte) *GetCursorNameReply { + v := new(GetCursorNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + return v } -// Write request to wire for 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 GetCursorName +// getCursorNameRequest writes a GetCursorName request to a byte slice. +func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 26 // 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(Source)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests. -type ChangeCursorByNameCookie struct { - *xgb.Cookie -} - -// ChangeCursorByName 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursorByName' 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) - return ChangeCursorByNameCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 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(Src)) - 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 { - *xgb.Cookie -} - -// ExpandRegion 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 { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ExpandRegion' 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} -} - -// 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 'ExpandRegion' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Source)) - b += 4 - - 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 } @@ -2432,6 +1532,723 @@ func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } +// IntersectRegionCookie is a cookie used only for IntersectRegion requests. +type IntersectRegionCookie struct { + *xgb.Cookie +} + +// IntersectRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { + 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// InvertRegionCookie is a cookie used only for InvertRegion requests. +type InvertRegionCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + 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 InvertRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for InvertRegion +// invertRegionRequest writes a InvertRegion request to a byte slice. +func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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 + + 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 +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["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. +// 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["XFIXES"]; !ok { + panic("Cannot issue request 'QueryVersion' 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 +} + +// 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["XFIXES"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 + + return buf +} + +// RegionExtentsCookie is a cookie used only for RegionExtents requests. +type RegionExtentsCookie struct { + *xgb.Cookie +} + +// 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.") + } + 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook RegionExtentsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RegionExtents +// regionExtentsRequest writes a RegionExtents request to a byte slice. +func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + 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 + + 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 + + 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 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put16(buf[b:], Nbytes) + b += 2 + + 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 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + + return buf +} + +// 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 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + + return buf +} + +// 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 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 +} + +// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests. +type SetWindowShapeRegionCookie struct { + *xgb.Cookie +} + +// SetWindowShapeRegion 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetWindowShapeRegion' 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} +} + +// 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 'SetWindowShapeRegion' 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} +} + +// Check returns an error if one occurred 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 { + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + 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(Dest)) + b += 4 + + buf[b] = byte(DestKind) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + // ShowCursorCookie is a cookie used only for ShowCursor requests. type ShowCursorCookie struct { *xgb.Cookie @@ -2486,3 +2303,186 @@ func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } + +// SubtractRegionCookie is a cookie used only for SubtractRegion requests. +type SubtractRegionCookie 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SubtractRegion' 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} +} + +// 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 'SubtractRegion' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// TranslateRegionCookie is a cookie used only for TranslateRegion requests. +type TranslateRegionCookie 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'TranslateRegion' 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} +} + +// 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 'TranslateRegion' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(Dx)) + b += 2 + + xgb.Put16(buf[b:], uint16(Dy)) + b += 2 + + return buf +} + +// UnionRegionCookie is a cookie used only for UnionRegion requests. +type UnionRegionCookie 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 { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'UnionRegion' 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} +} + +// 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 'UnionRegion' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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(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 -} +// Skipping definition for base type 'Bool' -// 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} -} +// Skipping definition for base type 'Byte' -// 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} -} +// Skipping definition for base type 'Card8' -// 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 -} +// Skipping definition for base type 'Char' -// 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 -} +// Skipping definition for base type 'Void' -// 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 'Double' - b += 1 // padding +// Skipping definition for base type 'Float' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Int32' - v.Major = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int8' - v.Minor = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card16' - 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 - - 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 -} +// 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,348 +40,6 @@ 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 -} - -// DeviceInfoRead reads a byte slice into a DeviceInfo value. -func DeviceInfoRead(buf []byte, v *DeviceInfo) int { - b := 0 - - v.DeviceType = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 - - v.DeviceId = buf[b] - b += 1 - - v.NumClassInfo = buf[b] - b += 1 - - v.DeviceUse = buf[b] - b += 1 - - b += 1 // padding - - return b -} - -// 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] = DeviceInfo{} - b += DeviceInfoRead(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) - b := 0 - - xgb.Put32(buf[b:], uint32(v.DeviceType)) - b += 4 - - buf[b] = v.DeviceId - b += 1 - - buf[b] = v.NumClassInfo - b += 1 - - buf[b] = v.DeviceUse - b += 1 - - b += 1 // padding - - return buf -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type InputInfo struct { - ClassId byte - Len byte -} - -// InputInfoRead reads a byte slice into a InputInfo value. -func InputInfoRead(buf []byte, v *InputInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - return b -} - -// 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] = InputInfo{} - b += InputInfoRead(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) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - return buf -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type KeyInfo struct { - ClassId byte - Len byte - MinKeycode KeyCode - MaxKeycode KeyCode - NumKeys uint16 - // padding: 2 bytes -} - -// KeyInfoRead reads a byte slice into a KeyInfo value. -func KeyInfoRead(buf []byte, v *KeyInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.MinKeycode = KeyCode(buf[b]) - b += 1 - - v.MaxKeycode = KeyCode(buf[b]) - b += 1 - - v.NumKeys = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return b -} - -// 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) -} - -// Bytes writes a KeyInfo value to a byte slice. -func (v KeyInfo) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = byte(v.MinKeycode) - b += 1 - - buf[b] = byte(v.MaxKeycode) - b += 1 - - xgb.Put16(buf[b:], v.NumKeys) - b += 2 - - b += 2 // padding - - return buf -} - -// 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 -} - -type ButtonInfo struct { - ClassId byte - Len byte - NumButtons uint16 -} - -// ButtonInfoRead reads a byte slice into a ButtonInfo value. -func ButtonInfoRead(buf []byte, v *ButtonInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumButtons = xgb.Get16(buf[b:]) - b += 2 - - return b -} - -// ButtonInfoReadList reads a byte slice into a list of ButtonInfo values. -func ButtonInfoReadList(buf []byte, dest []ButtonInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ButtonInfo{} - b += ButtonInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a ButtonInfo value to a byte slice. -func (v ButtonInfo) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - xgb.Put16(buf[b:], v.NumButtons) - b += 2 - - return buf -} - -// ButtonInfoListBytes writes a list of ButtonInfo values to a byte slice. -func ButtonInfoListBytes(buf []byte, list []ButtonInfo) 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 AxisInfo struct { Resolution uint32 Minimum int32 @@ -443,1256 +101,6 @@ func AxisInfoListBytes(buf []byte, list []AxisInfo) int { return b } -type ValuatorInfo struct { - ClassId byte - Len byte - AxesLen byte - Mode byte - MotionSize uint32 - Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) -} - -// ValuatorInfoRead reads a byte slice into a ValuatorInfo value. -func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.AxesLen = buf[b] - b += 1 - - v.Mode = buf[b] - b += 1 - - v.MotionSize = xgb.Get32(buf[b:]) - b += 4 - - v.Axes = make([]AxisInfo, v.AxesLen) - b += AxisInfoReadList(buf[b:], v.Axes) - - return b -} - -// 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) -} - -// 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 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.AxesLen - b += 1 - - buf[b] = v.Mode - b += 1 - - xgb.Put32(buf[b:], v.MotionSize) - b += 4 - - b += AxisInfoListBytes(buf[b:], v.Axes) - - return buf -} - -// 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 -} - -// 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 -} - -type InputClassInfo struct { - ClassId byte - EventTypeBase byte -} - -// InputClassInfoRead reads a byte slice into a InputClassInfo value. -func InputClassInfoRead(buf []byte, v *InputClassInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.EventTypeBase = buf[b] - b += 1 - - return b -} - -// 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) -} - -// Bytes writes a InputClassInfo value to a byte slice. -func (v InputClassInfo) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.EventTypeBase - b += 1 - - return buf -} - -// InputClassInfoListBytes writes a list of InputClassInfo values to a byte slice. -func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type DeviceTimeCoord struct { - Time xproto.Timestamp -} - -// DeviceTimeCoordRead reads a byte slice into a DeviceTimeCoord value. -func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { - b := 0 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// 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) -} - -// Bytes writes a DeviceTimeCoord value to a byte slice. -func (v DeviceTimeCoord) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - return buf -} - -// 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 -} - -type FeedbackState struct { - ClassId byte - Id byte - Len uint16 -} - -// FeedbackStateRead reads a byte slice into a FeedbackState value. -func FeedbackStateRead(buf []byte, v *FeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - return b -} - -// 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) -} - -// Bytes writes a FeedbackState value to a byte slice. -func (v FeedbackState) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// 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 -} - -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 -} - -// KbdFeedbackStateRead reads a byte slice into a KbdFeedbackState value. -func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.Pitch = xgb.Get16(buf[b:]) - b += 2 - - v.Duration = xgb.Get16(buf[b:]) - b += 2 - - v.LedMask = xgb.Get32(buf[b:]) - b += 4 - - v.LedValues = 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.Percent = buf[b] - b += 1 - - b += 1 // padding - - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += xgb.Pad(int(32)) - - return b -} - -// 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 KbdFeedbackState value to a byte slice. -func (v KbdFeedbackState) Bytes() []byte { - buf := make([]byte, 52) - 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) - b += 2 - - xgb.Put16(buf[b:], v.Duration) - b += 2 - - xgb.Put32(buf[b:], v.LedMask) - b += 4 - - xgb.Put32(buf[b:], v.LedValues) - b += 4 - - if v.GlobalAutoRepeat { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.Click - b += 1 - - buf[b] = v.Percent - b += 1 - - b += 1 // padding - - copy(buf[b:], v.AutoRepeats[:32]) - b += xgb.Pad(int(32)) - - return buf -} - -// 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 -} - -// KbdFeedbackStateListSize computes the size (bytes) of a list of KbdFeedbackState values. -func KbdFeedbackStateListSize(list []KbdFeedbackState) int { - size := 0 - for _ = range list { - size += 52 - } - return size -} - -type PtrFeedbackState struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - AccelNum uint16 - AccelDenom uint16 - Threshold uint16 -} - -// 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 -} - -// 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) -} - -// Bytes writes a PtrFeedbackState value to a byte slice. -func (v PtrFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - xgb.Put16(buf[b:], v.AccelNum) - b += 2 - - xgb.Put16(buf[b:], v.AccelDenom) - b += 2 - - xgb.Put16(buf[b:], v.Threshold) - b += 2 - - return buf -} - -// 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 -} - -type IntegerFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Resolution uint32 - MinValue int32 - MaxValue int32 -} - -// IntegerFeedbackStateRead reads a byte slice into a IntegerFeedbackState value. -func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.Resolution = xgb.Get32(buf[b:]) - b += 4 - - v.MinValue = int32(xgb.Get32(buf[b:])) - b += 4 - - v.MaxValue = int32(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 { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = IntegerFeedbackState{} - b += IntegerFeedbackStateRead(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) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - xgb.Put32(buf[b:], v.Resolution) - b += 4 - - xgb.Put32(buf[b:], uint32(v.MinValue)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.MaxValue)) - b += 4 - - return buf -} - -// 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 -} - -type StringFeedbackState struct { - ClassId byte - Id byte - Len uint16 - MaxSymbols uint16 - NumKeysyms uint16 - Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) -} - -// StringFeedbackStateRead reads a byte slice into a StringFeedbackState value. -func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.MaxSymbols = xgb.Get16(buf[b:]) - b += 2 - - v.NumKeysyms = xgb.Get16(buf[b:]) - b += 2 - - v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) - for i := 0; i < int(v.NumKeysyms); i++ { - v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return b -} - -// 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) -} - -// 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 -} - -// 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 -} - -// 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 -} - -type BellFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Percent byte - // padding: 3 bytes - Pitch uint16 - Duration uint16 -} - -// 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.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.Percent = buf[b] - b += 1 - - b += 3 // padding - - v.Pitch = xgb.Get16(buf[b:]) - b += 2 - - v.Duration = xgb.Get16(buf[b:]) - b += 2 - - return b -} - -// 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) -} - -// 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.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Percent - b += 1 - - b += 3 // padding - - xgb.Put16(buf[b:], v.Pitch) - b += 2 - - xgb.Put16(buf[b:], v.Duration) - b += 2 - - return buf -} - -// 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 -} - -type LedFeedbackState struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 -} - -// LedFeedbackStateRead reads a byte slice into a LedFeedbackState value. -func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 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 -} - -// 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) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - xgb.Put32(buf[b:], v.LedMask) - b += 4 - - xgb.Put32(buf[b:], v.LedValues) - b += 4 - - 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 -} - -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 -} - -// 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] = FeedbackCtl{} - b += FeedbackCtlRead(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) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - 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 -} - -// KbdFeedbackCtlRead reads a byte slice into a KbdFeedbackCtl value. -func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - 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]) - b += 1 - - v.BellPercent = int8(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 - - return b -} - -// 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 KbdFeedbackCtl value to a byte slice. -func (v KbdFeedbackCtl) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - 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) - b += 1 - - 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 -} - -// 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 -} - -type PtrFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - Num int16 - Denom int16 - Threshold int16 -} - -// PtrFeedbackCtlRead reads a byte slice into a PtrFeedbackCtl value. -func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) 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:])) - b += 2 - - v.Threshold = int16(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 { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = PtrFeedbackCtl{} - b += PtrFeedbackCtlRead(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) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - xgb.Put16(buf[b:], uint16(v.Num)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Denom)) - 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 { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type IntegerFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - IntToDisplay int32 -} - -// IntegerFeedbackCtlRead reads a byte slice into a IntegerFeedbackCtl value. -func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.IntToDisplay = int32(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// 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]) - } - return xgb.Pad(b) -} - -// Bytes writes a IntegerFeedbackCtl value to a byte slice. -func (v IntegerFeedbackCtl) 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.Len) - b += 2 - - xgb.Put32(buf[b:], uint32(v.IntToDisplay)) - b += 4 - - return buf -} - -// IntegerFeedbackCtlListBytes writes a list of IntegerFeedbackCtl values to a byte slice. -func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type StringFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - NumKeysyms uint16 - Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) -} - -// 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 -} - -// 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) -} - -// 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 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - xgb.Put16(buf[b:], 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 -} - -// 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 -} - -// 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 @@ -1780,16 +188,18 @@ func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { return b } -type LedFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 +type BellFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Percent byte + // padding: 3 bytes + Pitch uint16 + Duration uint16 } -// LedFeedbackCtlRead reads a byte slice into a LedFeedbackCtl value. -func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { +// BellFeedbackStateRead reads a byte slice into a BellFeedbackState value. +func BellFeedbackStateRead(buf []byte, v *BellFeedbackState) int { b := 0 v.ClassId = buf[b] @@ -1801,27 +211,32 @@ func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { v.Len = xgb.Get16(buf[b:]) b += 2 - v.LedMask = xgb.Get32(buf[b:]) - b += 4 + v.Percent = buf[b] + b += 1 - v.LedValues = xgb.Get32(buf[b:]) - b += 4 + b += 3 // padding + + v.Pitch = xgb.Get16(buf[b:]) + b += 2 + + v.Duration = xgb.Get16(buf[b:]) + b += 2 return b } -// LedFeedbackCtlReadList reads a byte slice into a list of LedFeedbackCtl values. -func LedFeedbackCtlReadList(buf []byte, dest []LedFeedbackCtl) 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] = LedFeedbackCtl{} - b += LedFeedbackCtlRead(buf[b:], &dest[i]) + dest[i] = BellFeedbackState{} + b += BellFeedbackStateRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a LedFeedbackCtl value to a byte slice. -func (v LedFeedbackCtl) Bytes() []byte { +// Bytes writes a BellFeedbackState value to a byte slice. +func (v BellFeedbackState) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1834,17 +249,22 @@ func (v LedFeedbackCtl) Bytes() []byte { xgb.Put16(buf[b:], v.Len) b += 2 - xgb.Put32(buf[b:], v.LedMask) - b += 4 + buf[b] = v.Percent + b += 1 - xgb.Put32(buf[b:], v.LedValues) - b += 4 + b += 3 // padding + + xgb.Put16(buf[b:], v.Pitch) + b += 2 + + xgb.Put16(buf[b:], v.Duration) + b += 2 return buf } -// LedFeedbackCtlListBytes writes a list of LedFeedbackCtl values to a byte slice. -func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) 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 { @@ -1855,14 +275,14 @@ func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) int { return b } -type InputState struct { - ClassId byte - Len byte - NumItems byte +type ButtonInfo struct { + ClassId byte + Len byte + NumButtons uint16 } -// InputStateRead reads a byte slice into a InputState value. -func InputStateRead(buf []byte, v *InputState) int { +// ButtonInfoRead reads a byte slice into a ButtonInfo value. +func ButtonInfoRead(buf []byte, v *ButtonInfo) int { b := 0 v.ClassId = buf[b] @@ -1871,25 +291,25 @@ func InputStateRead(buf []byte, v *InputState) int { v.Len = buf[b] b += 1 - v.NumItems = buf[b] - b += 1 + v.NumButtons = xgb.Get16(buf[b:]) + b += 2 return b } -// InputStateReadList reads a byte slice into a list of InputState values. -func InputStateReadList(buf []byte, dest []InputState) int { +// ButtonInfoReadList reads a byte slice into a list of ButtonInfo values. +func ButtonInfoReadList(buf []byte, dest []ButtonInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = InputState{} - b += InputStateRead(buf[b:], &dest[i]) + dest[i] = ButtonInfo{} + b += ButtonInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a InputState value to a byte slice. -func (v InputState) Bytes() []byte { - buf := make([]byte, 3) +// Bytes writes a ButtonInfo value to a byte slice. +func (v ButtonInfo) Bytes() []byte { + buf := make([]byte, 4) b := 0 buf[b] = v.ClassId @@ -1898,14 +318,14 @@ func (v InputState) Bytes() []byte { buf[b] = v.Len b += 1 - buf[b] = v.NumItems - b += 1 + xgb.Put16(buf[b:], v.NumButtons) + b += 2 return buf } -// InputStateListBytes writes a list of InputState values to a byte slice. -func InputStateListBytes(buf []byte, list []InputState) int { +// ButtonInfoListBytes writes a list of ButtonInfo values to a byte slice. +func ButtonInfoListBytes(buf []byte, list []ButtonInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -1916,89 +336,6 @@ func InputStateListBytes(buf []byte, list []InputState) int { return b } -type KeyState struct { - ClassId byte - Len byte - NumKeys byte - // padding: 1 bytes - Keys []byte // size: 32 -} - -// KeyStateRead reads a byte slice into a KeyState value. -func KeyStateRead(buf []byte, v *KeyState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumKeys = buf[b] - b += 1 - - b += 1 // padding - - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += xgb.Pad(int(32)) - - return b -} - -// 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 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 - 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 -} - -// 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 -} - type ButtonState struct { ClassId byte Len byte @@ -2082,104 +419,190 @@ func ButtonStateListSize(list []ButtonState) int { return size } -type ValuatorState struct { - ClassId byte - Len byte - NumValuators byte - Mode byte - Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +// 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 } -// ValuatorStateRead reads a byte slice into a ValuatorState value. -func ValuatorStateRead(buf []byte, v *ValuatorState) 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.Len = 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 - v.NumValuators = buf[b] - b += 1 + b += 23 // padding - v.Mode = buf[b] - b += 1 - - v.Valuators = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.Valuators[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return b + return v } -// 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) -} - -// 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 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.Len + buf[b] = v.DeviceId b += 1 - buf[b] = v.NumValuators + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.Request b += 1 - buf[b] = v.Mode - b += 1 - - for i := 0; i < int(v.NumValuators); i++ { - xgb.Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = xgb.Pad(b) + b += 23 // 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 ChangeDeviceNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ChangeDeviceNotifyEvent) 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 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, ", ") + "}" } -type DeviceState struct { +func init() { + xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew +} + +// BadClass is the error number for a BadClass. +const BadClass = 4 + +type ClassError struct { + Sequence uint16 + NiceName string +} + +// ClassErrorNew constructs a ClassError value that implements xgb.Error from a byte slice. +func ClassErrorNew(buf []byte) xgb.Error { + v := ClassError{} + v.NiceName = "Class" + + 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 BadClass error. +// This is mostly used internally. +func (err ClassError) SequenceId() uint16 { + return err.Sequence +} + +// 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew +} + +// BadDevice is the error number for a BadDevice. +const BadDevice = 0 + +type DeviceError struct { + Sequence uint16 + NiceName string +} + +// DeviceErrorNew constructs a DeviceError value that implements xgb.Error from a byte slice. +func DeviceErrorNew(buf []byte) xgb.Error { + v := DeviceError{} + v.NiceName = "Device" + + 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 BadDevice error. +// This is mostly used internally. +func (err DeviceError) SequenceId() uint16 { + return err.Sequence +} + +// 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 +} + +// Error returns a rudimentary string representation of the BadDevice error. + +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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew +} + +type DeviceAbsAreaCtrl struct { ControlId uint16 Len uint16 + OffsetX uint32 + OffsetY uint32 + Width int32 + Height int32 + Screen int32 + Following uint32 } -// DeviceStateRead reads a byte slice into a DeviceState value. -func DeviceStateRead(buf []byte, v *DeviceState) int { +// DeviceAbsAreaCtrlRead reads a byte slice into a DeviceAbsAreaCtrl value. +func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { b := 0 v.ControlId = xgb.Get16(buf[b:]) @@ -2188,22 +611,40 @@ func DeviceStateRead(buf []byte, v *DeviceState) int { v.Len = xgb.Get16(buf[b:]) b += 2 + v.OffsetX = xgb.Get32(buf[b:]) + b += 4 + + v.OffsetY = xgb.Get32(buf[b:]) + b += 4 + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Screen = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Following = xgb.Get32(buf[b:]) + b += 4 + return b } -// DeviceStateReadList reads a byte slice into a list of DeviceState values. -func DeviceStateReadList(buf []byte, dest []DeviceState) 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] = DeviceState{} - b += DeviceStateRead(buf[b:], &dest[i]) + dest[i] = DeviceAbsAreaCtrl{} + b += DeviceAbsAreaCtrlRead(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 DeviceAbsAreaCtrl value to a byte slice. +func (v DeviceAbsAreaCtrl) Bytes() []byte { + buf := make([]byte, 28) b := 0 xgb.Put16(buf[b:], v.ControlId) @@ -2212,233 +653,29 @@ func (v DeviceState) Bytes() []byte { xgb.Put16(buf[b:], v.Len) b += 2 - return buf -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type DeviceResolutionState struct { - ControlId uint16 - Len uint16 - NumValuators uint32 - ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) - ResolutionMin []uint32 // size: xgb.Pad((int(NumValuators) * 4)) - ResolutionMax []uint32 // size: xgb.Pad((int(NumValuators) * 4)) -} - -// DeviceResolutionStateRead reads a byte slice into a DeviceResolutionState value. -func DeviceResolutionStateRead(buf []byte, v *DeviceResolutionState) int { - b := 0 - - v.ControlId = xgb.Get16(buf[b:]) - b += 2 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.NumValuators = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], v.OffsetX) b += 4 - 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.ResolutionMin = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionMin[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - v.ResolutionMax = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionMax[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return b -} - -// DeviceResolutionStateReadList reads a byte slice into a list of DeviceResolutionState values. -func DeviceResolutionStateReadList(buf []byte, dest []DeviceResolutionState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DeviceResolutionState{} - b += DeviceResolutionStateRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a DeviceResolutionState value to a byte slice. -func (v DeviceResolutionState) Bytes() []byte { - buf := make([]byte, (((8 + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4)))) - b := 0 - - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - xgb.Put32(buf[b:], v.NumValuators) + xgb.Put32(buf[b:], v.OffsetY) b += 4 - for i := 0; i < int(v.NumValuators); i++ { - xgb.Put32(buf[b:], v.ResolutionValues[i]) - b += 4 - } - b = xgb.Pad(b) - - for i := 0; i < int(v.NumValuators); i++ { - xgb.Put32(buf[b:], v.ResolutionMin[i]) - b += 4 - } - b = xgb.Pad(b) - - for i := 0; i < int(v.NumValuators); i++ { - xgb.Put32(buf[b:], v.ResolutionMax[i]) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// DeviceResolutionStateListBytes writes a list of DeviceResolutionState values to a byte slice. -func DeviceResolutionStateListBytes(buf []byte, list []DeviceResolutionState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// DeviceResolutionStateListSize computes the size (bytes) of a list of DeviceResolutionState values. -func DeviceResolutionStateListSize(list []DeviceResolutionState) int { - size := 0 - for _, item := range list { - size += (((8 + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) - } - 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 -} - -// DeviceAbsCalibStateRead reads a byte slice into a DeviceAbsCalibState value. -func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { - b := 0 - - v.ControlId = xgb.Get16(buf[b:]) - b += 2 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.MinX = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(v.Width)) b += 4 - v.MaxX = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(v.Height)) b += 4 - v.MinY = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(v.Screen)) 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 { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DeviceAbsCalibState{} - b += DeviceAbsCalibStateRead(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) - b := 0 - - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - 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) + xgb.Put32(buf[b:], v.Following) b += 4 return buf } -// DeviceAbsCalibStateListBytes writes a list of DeviceAbsCalibState values to a byte slice. -func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) 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 { @@ -2545,290 +782,6 @@ func DeviceAbsAreaStateListBytes(buf []byte, list []DeviceAbsAreaState) int { return b } -type DeviceCoreState struct { - ControlId uint16 - Len uint16 - Status byte - Iscore byte - // padding: 2 bytes -} - -// DeviceCoreStateRead reads a byte slice into a DeviceCoreState value. -func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) 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 - - v.Iscore = buf[b] - b += 1 - - b += 2 // padding - - return b -} - -// 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] = DeviceCoreState{} - b += DeviceCoreStateRead(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) - 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 - - return buf -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - 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 - - v.ControlId = xgb.Get16(buf[b:]) - b += 2 - - v.Len = xgb.Get16(buf[b:]) - b += 2 - - v.Enable = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// 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]) - } - return xgb.Pad(b) -} - -// Bytes writes a DeviceEnableState value to a byte slice. -func (v DeviceEnableState) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Enable - b += 1 - - b += 3 // padding - - 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 -} - -type DeviceCtl struct { - ControlId uint16 - Len uint16 -} - -// DeviceCtlRead reads a byte slice into a DeviceCtl value. -func DeviceCtlRead(buf []byte, v *DeviceCtl) int { - b := 0 - - v.ControlId = xgb.Get16(buf[b:]) - b += 2 - - 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 { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DeviceCtl{} - b += DeviceCtlRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a DeviceCtl value to a byte slice. -func (v DeviceCtl) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - xgb.Put16(buf[b:], v.ControlId) - b += 2 - - xgb.Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -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:]) - b += 2 - - 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 -} - -// 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] = DeviceResolutionCtl{} - b += DeviceResolutionCtlRead(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 - - 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 -} - -// 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 { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - 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 DeviceAbsCalibCtl struct { ControlId uint16 Len uint16 @@ -2939,19 +892,21 @@ func DeviceAbsCalibCtlListBytes(buf []byte, list []DeviceAbsCalibCtl) int { return b } -type DeviceAbsAreaCtrl struct { - ControlId uint16 - Len uint16 - OffsetX uint32 - OffsetY uint32 - Width int32 - Height int32 - Screen int32 - Following uint32 +type DeviceAbsCalibState struct { + ControlId uint16 + Len uint16 + MinX int32 + MaxX int32 + MinY int32 + MaxY int32 + FlipX uint32 + FlipY uint32 + Rotation uint32 + ButtonThreshold uint32 } -// DeviceAbsAreaCtrlRead reads a byte slice into a DeviceAbsAreaCtrl value. -func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { +// DeviceAbsCalibStateRead reads a byte slice into a DeviceAbsCalibState value. +func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { b := 0 v.ControlId = xgb.Get16(buf[b:]) @@ -2960,40 +915,46 @@ func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { v.Len = xgb.Get16(buf[b:]) b += 2 - v.OffsetX = xgb.Get32(buf[b:]) + v.MinX = int32(xgb.Get32(buf[b:])) b += 4 - v.OffsetY = xgb.Get32(buf[b:]) + v.MaxX = int32(xgb.Get32(buf[b:])) b += 4 - v.Width = int32(xgb.Get32(buf[b:])) + v.MinY = int32(xgb.Get32(buf[b:])) b += 4 - v.Height = int32(xgb.Get32(buf[b:])) + v.MaxY = int32(xgb.Get32(buf[b:])) b += 4 - v.Screen = int32(xgb.Get32(buf[b:])) + v.FlipX = xgb.Get32(buf[b:]) b += 4 - v.Following = xgb.Get32(buf[b:]) + 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 } -// DeviceAbsAreaCtrlReadList reads a byte slice into a list of DeviceAbsAreaCtrl values. -func DeviceAbsAreaCtrlReadList(buf []byte, dest []DeviceAbsAreaCtrl) 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] = DeviceAbsAreaCtrl{} - b += DeviceAbsAreaCtrlRead(buf[b:], &dest[i]) + dest[i] = DeviceAbsCalibState{} + b += DeviceAbsCalibStateRead(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 DeviceAbsCalibState value to a byte slice. +func (v DeviceAbsCalibState) Bytes() []byte { + buf := make([]byte, 36) b := 0 xgb.Put16(buf[b:], v.ControlId) @@ -3002,29 +963,35 @@ func (v DeviceAbsAreaCtrl) Bytes() []byte { xgb.Put16(buf[b:], v.Len) b += 2 - xgb.Put32(buf[b:], v.OffsetX) + xgb.Put32(buf[b:], uint32(v.MinX)) b += 4 - xgb.Put32(buf[b:], v.OffsetY) + xgb.Put32(buf[b:], uint32(v.MaxX)) b += 4 - xgb.Put32(buf[b:], uint32(v.Width)) + xgb.Put32(buf[b:], uint32(v.MinY)) b += 4 - xgb.Put32(buf[b:], uint32(v.Height)) + xgb.Put32(buf[b:], uint32(v.MaxY)) b += 4 - xgb.Put32(buf[b:], uint32(v.Screen)) + xgb.Put32(buf[b:], v.FlipX) b += 4 - xgb.Put32(buf[b:], v.Following) + 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 } -// DeviceAbsAreaCtrlListBytes writes a list of DeviceAbsAreaCtrl values to a byte slice. -func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) 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 { @@ -3035,6 +1002,206 @@ func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { return b } +// BadDeviceBusy is the error number for a BadDeviceBusy. +const BadDeviceBusy = 3 + +type DeviceBusyError struct { + Sequence uint16 + NiceName string +} + +// DeviceBusyErrorNew constructs a DeviceBusyError value that implements xgb.Error from a byte slice. +func DeviceBusyErrorNew(buf []byte) xgb.Error { + v := DeviceBusyError{} + v.NiceName = "DeviceBusy" + + 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 BadDeviceBusy error. +// This is mostly used internally. +func (err DeviceBusyError) SequenceId() uint16 { + return err.Sequence +} + +// 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew +} + +// DeviceButtonPress is the event number for a DeviceButtonPressEvent. +const DeviceButtonPress = 3 + +type DeviceButtonPressEvent DeviceKeyPressEvent + +// DeviceButtonPressEventNew constructs a DeviceButtonPressEvent value that implements xgb.Event from a byte slice. +func DeviceButtonPressEventNew(buf []byte) xgb.Event { + return DeviceButtonPressEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +// Bytes writes a DeviceButtonPressEvent value to a byte slice. +func (v DeviceButtonPressEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +// 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 +} + +func (v DeviceButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew +} + +// DeviceButtonRelease is the event number for a DeviceButtonReleaseEvent. +const DeviceButtonRelease = 4 + +type DeviceButtonReleaseEvent DeviceKeyPressEvent + +// DeviceButtonReleaseEventNew constructs a DeviceButtonReleaseEvent value that implements xgb.Event from a byte slice. +func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { + return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +// Bytes writes a DeviceButtonReleaseEvent value to a byte slice. +func (v DeviceButtonReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +// 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 +} + +func (v DeviceButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew +} + +// 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.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Buttons = make([]byte, 28) + copy(v.Buttons[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v +} + +// Bytes writes a DeviceButtonStateNotifyEvent value to a byte slice. +func (v DeviceButtonStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + copy(buf[b:], v.Buttons[:28]) + b += xgb.Pad(int(28)) + + return buf +} + +// 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][14] = DeviceButtonStateNotifyEventNew +} + type DeviceCoreCtrl struct { ControlId uint16 Len uint16 @@ -3101,6 +1268,133 @@ func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { return b } +type DeviceCoreState struct { + ControlId uint16 + Len uint16 + Status byte + Iscore byte + // padding: 2 bytes +} + +// DeviceCoreStateRead reads a byte slice into a DeviceCoreState value. +func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) 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 + + v.Iscore = buf[b] + b += 1 + + b += 2 // padding + + return b +} + +// 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] = DeviceCoreState{} + b += DeviceCoreStateRead(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) + 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 + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type DeviceCtl struct { + ControlId uint16 + Len uint16 +} + +// DeviceCtlRead reads a byte slice into a DeviceCtl value. +func DeviceCtlRead(buf []byte, v *DeviceCtl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + 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 { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceCtl{} + b += DeviceCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a DeviceCtl value to a byte slice. +func (v DeviceCtl) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + type DeviceEnableCtrl struct { ControlId uint16 Len uint16 @@ -3167,102 +1461,154 @@ 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 DeviceEnableState struct { + ControlId uint16 + Len uint16 + Enable byte + // padding: 3 bytes } -// 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.DeviceState = xgb.Get16(buf[b:]) - b += 2 - - v.NumValuators = buf[b] - b += 1 - - v.FirstValuator = buf[b] - b += 1 - - v.Valuators = make([]int32, 6) - for i := 0; i < int(6); i++ { - v.Valuators[i] = int32(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Bytes writes a DeviceValuatorEvent value to a byte slice. -func (v DeviceValuatorEvent) Bytes() []byte { - buf := make([]byte, 32) +// DeviceEnableStateRead reads a byte slice into a DeviceEnableState value. +func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { b := 0 - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - xgb.Put16(buf[b:], v.DeviceState) + v.ControlId = xgb.Get16(buf[b:]) b += 2 - buf[b] = v.NumValuators + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Enable = buf[b] b += 1 - buf[b] = v.FirstValuator - b += 1 + b += 3 // padding - for i := 0; i < int(6); i++ { - xgb.Put32(buf[b:], uint32(v.Valuators[i])) - b += 4 + return b +} + +// 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]) } - b = xgb.Pad(b) + return xgb.Pad(b) +} + +// Bytes writes a DeviceEnableState value to a byte slice. +func (v DeviceEnableState) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Enable + b += 1 + + b += 3 // padding return buf } -// SequenceId returns the sequence id attached to the DeviceValuator event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceValuatorEvent) SequenceId() uint16 { - return v.Sequence +// 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 } -// 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, ", ") + "}" +type DeviceInfo struct { + DeviceType xproto.Atom + DeviceId byte + NumClassInfo byte + DeviceUse byte + // padding: 1 bytes } -func init() { - xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew +// DeviceInfoRead reads a byte slice into a DeviceInfo value. +func DeviceInfoRead(buf []byte, v *DeviceInfo) int { + b := 0 + + v.DeviceType = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.DeviceId = buf[b] + b += 1 + + v.NumClassInfo = buf[b] + b += 1 + + v.DeviceUse = buf[b] + b += 1 + + b += 1 // padding + + return b } +// 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] = DeviceInfo{} + b += DeviceInfoRead(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) + b := 0 + + xgb.Put32(buf[b:], uint32(v.DeviceType)) + b += 4 + + buf[b] = v.DeviceId + b += 1 + + buf[b] = v.NumClassInfo + b += 1 + + buf[b] = v.DeviceUse + b += 1 + + b += 1 // padding + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + DeviceInputModeAsyncThisDevice = 0 + DeviceInputModeSyncThisDevice = 1 + DeviceInputModeReplayThisDevice = 2 + DeviceInputModeAsyncOtherDevices = 3 + DeviceInputModeAsyncAll = 4 + DeviceInputModeSyncAll = 5 +) + // DeviceKeyPress is the event number for a DeviceKeyPressEvent. const DeviceKeyPress = 1 @@ -3417,99 +1763,607 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][1] = DeviceKeyPressEventNew } -// FocusIn is the event number for a FocusInEvent. -const FocusIn = 6 +// DeviceKeyRelease is the event number for a DeviceKeyReleaseEvent. +const DeviceKeyRelease = 2 -type FocusInEvent struct { - Sequence uint16 - Detail byte - Time xproto.Timestamp - Window xproto.Window - Mode byte - DeviceId byte - // padding: 18 bytes +type DeviceKeyReleaseEvent 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)) } -// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. -func FocusInEventNew(buf []byte) xgb.Event { - v := FocusInEvent{} +// Bytes writes a DeviceKeyReleaseEvent value to a byte slice. +func (v DeviceKeyReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +// 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 +} + +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, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew +} + +// DeviceKeyStateNotify is the event number for a DeviceKeyStateNotifyEvent. +const DeviceKeyStateNotify = 13 + +type DeviceKeyStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Keys []byte // size: 28 +} + +// 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.Detail = buf[b] + v.DeviceId = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 + v.Keys = make([]byte, 28) + copy(v.Keys[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v +} + +// Bytes writes a DeviceKeyStateNotifyEvent value to a byte slice. +func (v DeviceKeyStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 13 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + copy(buf[b:], v.Keys[:28]) + b += xgb.Pad(int(28)) + + 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, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew +} + +// DeviceMappingNotify is the event number for a DeviceMappingNotifyEvent. +const DeviceMappingNotify = 11 + +type DeviceMappingNotifyEvent struct { + Sequence uint16 + DeviceId byte + Request byte + FirstKeycode KeyCode + Count byte + // padding: 1 bytes + 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.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Request = buf[b] + b += 1 + + v.FirstKeycode = KeyCode(buf[b]) + b += 1 + + v.Count = buf[b] + b += 1 + + b += 1 // padding + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Bytes writes a DeviceMappingNotifyEvent value to a byte slice. +func (v DeviceMappingNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 11 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + b += 20 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the DeviceMappingNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DeviceMappingNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of DeviceMappingNotifyEvent. +func (v DeviceMappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + return "DeviceMappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew +} + +// 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.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - v.Mode = buf[b] + v.Devchange = buf[b] b += 1 v.DeviceId = buf[b] b += 1 - b += 18 // padding + v.Control = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding return v } -// Bytes writes a FocusInEvent value to a byte slice. -func (v FocusInEvent) Bytes() []byte { +// 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] = 6 + buf[b] = 15 b += 1 - buf[b] = v.Detail - b += 1 + b += 1 // padding b += 2 // skip sequence number xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - buf[b] = v.Mode + buf[b] = v.Devchange b += 1 buf[b] = v.DeviceId b += 1 - b += 18 // padding + xgb.Put16(buf[b:], v.Control) + b += 2 + + b += 20 // padding return buf } -// SequenceId returns the sequence id attached to the FocusIn event. +// 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 FocusInEvent) SequenceId() uint16 { +func (v DevicePresenceNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of FocusInEvent. -func (v FocusInEvent) String() string { +// 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("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("Devchange: %d", v.Devchange)) fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Control: %d", v.Control)) + return "DevicePresenceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtEventFuncs["XInputExtension"][6] = FocusInEventNew + 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:]) + b += 2 + + 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 +} + +// 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] = DeviceResolutionCtl{} + b += DeviceResolutionCtlRead(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 + + 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 +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + 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 + NumValuators uint32 + ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) + ResolutionMin []uint32 // size: xgb.Pad((int(NumValuators) * 4)) + ResolutionMax []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// DeviceResolutionStateRead reads a byte slice into a DeviceResolutionState value. +func DeviceResolutionStateRead(buf []byte, v *DeviceResolutionState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.NumValuators = xgb.Get32(buf[b:]) + b += 4 + + 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.ResolutionMin = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionMin[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.ResolutionMax = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionMax[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// DeviceResolutionStateReadList reads a byte slice into a list of DeviceResolutionState values. +func DeviceResolutionStateReadList(buf []byte, dest []DeviceResolutionState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceResolutionState{} + b += DeviceResolutionStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a DeviceResolutionState value to a byte slice. +func (v DeviceResolutionState) Bytes() []byte { + buf := make([]byte, (((8 + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.NumValuators) + b += 4 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionValues[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionMin[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionMax[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// DeviceResolutionStateListBytes writes a list of DeviceResolutionState values to a byte slice. +func DeviceResolutionStateListBytes(buf []byte, list []DeviceResolutionState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// DeviceResolutionStateListSize computes the size (bytes) of a list of DeviceResolutionState values. +func DeviceResolutionStateListSize(list []DeviceResolutionState) int { + size := 0 + for _, item := range list { + size += (((8 + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +type DeviceState struct { + ControlId uint16 + Len uint16 +} + +// DeviceStateRead reads a byte slice into a DeviceState value. +func DeviceStateRead(buf []byte, v *DeviceState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// 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] = DeviceState{} + b += DeviceStateRead(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) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } // DeviceStateNotify is the event number for a DeviceStateNotifyEvent. @@ -3640,23 +2494,76 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][10] = DeviceStateNotifyEventNew } -// DeviceMappingNotify is the event number for a DeviceMappingNotifyEvent. -const DeviceMappingNotify = 11 - -type DeviceMappingNotifyEvent struct { - Sequence uint16 - DeviceId byte - Request byte - FirstKeycode KeyCode - Count byte - // padding: 1 bytes +type DeviceTimeCoord struct { 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{} +// DeviceTimeCoordRead reads a byte slice into a DeviceTimeCoord value. +func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { + b := 0 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// 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) +} + +// Bytes writes a DeviceTimeCoord value to a byte slice. +func (v DeviceTimeCoord) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + return buf +} + +// 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 +} + +const ( + DeviceUseIsXPointer = 0 + DeviceUseIsXKeyboard = 1 + DeviceUseIsXExtensionDevice = 2 + DeviceUseIsXExtensionKeyboard = 3 + DeviceUseIsXExtensionPointer = 4 +) + +// DeviceValuator is the event number for a DeviceValuatorEvent. +const DeviceValuator = 0 + +type DeviceValuatorEvent struct { + Sequence uint16 + DeviceId byte + DeviceState uint16 + NumValuators byte + FirstValuator byte + Valuators []int32 // size: 24 +} + +// 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] @@ -3665,32 +2572,32 @@ func DeviceMappingNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Request = buf[b] + v.DeviceState = xgb.Get16(buf[b:]) + b += 2 + + v.NumValuators = buf[b] b += 1 - v.FirstKeycode = KeyCode(buf[b]) + v.FirstValuator = buf[b] b += 1 - v.Count = buf[b] - b += 1 - - b += 1 // padding - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - b += 20 // padding + v.Valuators = make([]int32, 6) + for i := 0; i < int(6); i++ { + v.Valuators[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) return v } -// Bytes writes a DeviceMappingNotifyEvent value to a byte slice. -func (v DeviceMappingNotifyEvent) Bytes() []byte { +// Bytes writes a DeviceValuatorEvent value to a byte slice. +func (v DeviceValuatorEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 11 + buf[b] = 0 b += 1 buf[b] = v.DeviceId @@ -3698,65 +2605,244 @@ func (v DeviceMappingNotifyEvent) Bytes() []byte { b += 2 // skip sequence number - buf[b] = v.Request + xgb.Put16(buf[b:], v.DeviceState) + b += 2 + + buf[b] = v.NumValuators b += 1 - buf[b] = byte(v.FirstKeycode) + buf[b] = v.FirstValuator b += 1 - buf[b] = v.Count - b += 1 - - b += 1 // padding - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - b += 20 // padding + for i := 0; i < int(6); i++ { + xgb.Put32(buf[b:], uint32(v.Valuators[i])) + b += 4 + } + b = xgb.Pad(b) return buf } -// SequenceId returns the sequence id attached to the DeviceMappingNotify event. +// 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 DeviceMappingNotifyEvent) SequenceId() uint16 { +func (v DeviceValuatorEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of DeviceMappingNotifyEvent. -func (v DeviceMappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) +// 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("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, ", ") + "}" + 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"][11] = DeviceMappingNotifyEventNew + xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew } -// ChangeDeviceNotify is the event number for a ChangeDeviceNotifyEvent. -const ChangeDeviceNotify = 12 +// BadEvent is the error number for a BadEvent. +const BadEvent = 1 -type ChangeDeviceNotifyEvent struct { +type EventError struct { Sequence uint16 - DeviceId byte + 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 +} + +// 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] = FeedbackCtl{} + b += FeedbackCtlRead(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) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type FeedbackState struct { + ClassId byte + Id byte + Len uint16 +} + +// FeedbackStateRead reads a byte slice into a FeedbackState value. +func FeedbackStateRead(buf []byte, v *FeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// 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) +} + +// Bytes writes a FeedbackState value to a byte slice. +func (v FeedbackState) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// 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 +} + +// FocusIn is the event number for a FocusInEvent. +const FocusIn = 6 + +type FocusInEvent struct { + Sequence uint16 + Detail byte Time xproto.Timestamp - Request byte - // padding: 23 bytes + Window xproto.Window + Mode byte + DeviceId byte + // padding: 18 bytes } -// ChangeDeviceNotifyEventNew constructs a ChangeDeviceNotifyEvent value that implements xgb.Event from a byte slice. -func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { - v := ChangeDeviceNotifyEvent{} +// 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.DeviceId = buf[b] + v.Detail = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -3765,24 +2851,30 @@ func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.Request = buf[b] + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = buf[b] b += 1 - b += 23 // padding + v.DeviceId = buf[b] + b += 1 + + b += 18 // padding return v } -// Bytes writes a ChangeDeviceNotifyEvent value to a byte slice. -func (v ChangeDeviceNotifyEvent) Bytes() []byte { +// Bytes writes a FocusInEvent value to a byte slice. +func (v FocusInEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 12 + buf[b] = 6 b += 1 - buf[b] = v.DeviceId + buf[b] = v.Detail b += 1 b += 2 // skip sequence number @@ -3790,434 +2882,1031 @@ func (v ChangeDeviceNotifyEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - buf[b] = v.Request - b += 1 - - b += 23 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the ChangeDeviceNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ChangeDeviceNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew -} - -// DeviceKeyStateNotify is the event number for a DeviceKeyStateNotifyEvent. -const DeviceKeyStateNotify = 13 - -type DeviceKeyStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Keys []byte // size: 28 -} - -// 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.DeviceId = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Keys = make([]byte, 28) - copy(v.Keys[:28], buf[b:]) - b += xgb.Pad(int(28)) - - return v -} - -// Bytes writes a DeviceKeyStateNotifyEvent value to a byte slice. -func (v DeviceKeyStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 13 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - copy(buf[b:], v.Keys[:28]) - b += xgb.Pad(int(28)) - - 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, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew -} - -// 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.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Buttons = make([]byte, 28) - copy(v.Buttons[:28], buf[b:]) - b += xgb.Pad(int(28)) - - return v -} - -// Bytes writes a DeviceButtonStateNotifyEvent value to a byte slice. -func (v DeviceButtonStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 14 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - copy(buf[b:], v.Buttons[:28]) - b += xgb.Pad(int(28)) - - return buf -} - -// 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 -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][14] = DeviceButtonStateNotifyEventNew -} - -// 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:])) + xgb.Put32(buf[b:], uint32(v.Window)) 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 + buf[b] = v.Mode b += 1 buf[b] = v.DeviceId b += 1 - xgb.Put16(buf[b:], v.Control) - b += 2 - - b += 20 // padding + b += 18 // padding return buf } -// SequenceId returns the sequence id attached to the DevicePresenceNotify event. +// 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 DevicePresenceNotifyEvent) SequenceId() uint16 { +func (v FocusInEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of DevicePresenceNotifyEvent. -func (v DevicePresenceNotifyEvent) String() string { +// 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("Devchange: %d", v.Devchange)) + 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)) - fieldVals = append(fieldVals, xgb.Sprintf("Control: %d", v.Control)) - return "DevicePresenceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtEventFuncs["XInputExtension"][15] = DevicePresenceNotifyEventNew + xgb.NewExtEventFuncs["XInputExtension"][6] = FocusInEventNew } -// DeviceKeyRelease is the event number for a DeviceKeyReleaseEvent. -const DeviceKeyRelease = 2 +// FocusOut is the event number for a FocusOutEvent. +const FocusOut = 7 -type DeviceKeyReleaseEvent DeviceKeyPressEvent +type FocusOutEvent FocusInEvent -// DeviceKeyReleaseEventNew constructs a DeviceKeyReleaseEvent value that implements xgb.Event from a byte slice. -func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { - return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) } -// Bytes writes a DeviceKeyReleaseEvent value to a byte slice. -func (v DeviceKeyReleaseEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() +// Bytes writes a FocusOutEvent value to a byte slice. +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() } -// SequenceId returns the sequence id attached to the DeviceKeyRelease event. +// 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 DeviceKeyReleaseEvent) SequenceId() uint16 { +func (v FocusOutEvent) SequenceId() uint16 { return v.Sequence } -func (v DeviceKeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) +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("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("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceKeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew + xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew } -// DeviceButtonPress is the event number for a DeviceButtonPressEvent. -const DeviceButtonPress = 3 +const ( + InputClassKey = 0 + InputClassButton = 1 + InputClassValuator = 2 + InputClassFeedback = 3 + InputClassProximity = 4 + InputClassFocus = 5 + InputClassOther = 6 +) -type DeviceButtonPressEvent DeviceKeyPressEvent - -// DeviceButtonPressEventNew constructs a DeviceButtonPressEvent value that implements xgb.Event from a byte slice. -func DeviceButtonPressEventNew(buf []byte) xgb.Event { - return DeviceButtonPressEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +type InputClassInfo struct { + ClassId byte + EventTypeBase byte } -// Bytes writes a DeviceButtonPressEvent value to a byte slice. -func (v DeviceButtonPressEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() +// InputClassInfoRead reads a byte slice into a InputClassInfo value. +func InputClassInfoRead(buf []byte, v *InputClassInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.EventTypeBase = buf[b] + b += 1 + + return b } -// SequenceId returns the sequence id attached to the DeviceButtonPress event. -// Events without a sequence number (KeymapNotify) return 0. +// 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) +} + +// Bytes writes a InputClassInfo value to a byte slice. +func (v InputClassInfo) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.EventTypeBase + b += 1 + + return buf +} + +// InputClassInfoListBytes writes a list of InputClassInfo values to a byte slice. +func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type InputInfo struct { + ClassId byte + Len byte +} + +// InputInfoRead reads a byte slice into a InputInfo value. +func InputInfoRead(buf []byte, v *InputInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + return b +} + +// 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] = InputInfo{} + b += InputInfoRead(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) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + return buf +} + +// 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 { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type InputState struct { + ClassId byte + Len byte + NumItems byte +} + +// InputStateRead reads a byte slice into a InputState value. +func InputStateRead(buf []byte, v *InputState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumItems = buf[b] + b += 1 + + return b +} + +// 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) +} + +// Bytes writes a InputState value to a byte slice. +func (v InputState) Bytes() []byte { + buf := make([]byte, 3) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumItems + b += 1 + + return buf +} + +// 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 +} + +type IntegerFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + IntToDisplay int32 +} + +// IntegerFeedbackCtlRead reads a byte slice into a IntegerFeedbackCtl value. +func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.IntToDisplay = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// 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]) + } + return xgb.Pad(b) +} + +// Bytes writes a IntegerFeedbackCtl value to a byte slice. +func (v IntegerFeedbackCtl) 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.Len) + b += 2 + + xgb.Put32(buf[b:], uint32(v.IntToDisplay)) + b += 4 + + return buf +} + +// IntegerFeedbackCtlListBytes writes a list of IntegerFeedbackCtl values to a byte slice. +func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type IntegerFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Resolution uint32 + MinValue int32 + MaxValue int32 +} + +// IntegerFeedbackStateRead reads a byte slice into a IntegerFeedbackState value. +func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Resolution = xgb.Get32(buf[b:]) + b += 4 + + v.MinValue = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxValue = int32(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 { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = IntegerFeedbackState{} + b += IntegerFeedbackStateRead(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) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.Resolution) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MinValue)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxValue)) + b += 4 + + return buf +} + +// 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 +} + +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 +} + +// KbdFeedbackCtlRead reads a byte slice into a KbdFeedbackCtl value. +func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + 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]) + b += 1 + + v.BellPercent = int8(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 + + return b +} + +// 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 KbdFeedbackCtl value to a byte slice. +func (v KbdFeedbackCtl) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + 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) + b += 1 + + 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 +} + +// 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 +} + +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 +} + +// KbdFeedbackStateRead reads a byte slice into a KbdFeedbackState value. +func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Pitch = xgb.Get16(buf[b:]) + b += 2 + + v.Duration = xgb.Get16(buf[b:]) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = 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.Percent = buf[b] + b += 1 + + b += 1 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// 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 KbdFeedbackState value to a byte slice. +func (v KbdFeedbackState) Bytes() []byte { + buf := make([]byte, 52) + 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) + b += 2 + + xgb.Put16(buf[b:], v.Duration) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + if v.GlobalAutoRepeat { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.Click + b += 1 + + buf[b] = v.Percent + b += 1 + + b += 1 // padding + + copy(buf[b:], v.AutoRepeats[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// 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 +} + +// 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 KeyCode byte + +type KeyInfo struct { + ClassId byte + Len byte + MinKeycode KeyCode + MaxKeycode KeyCode + NumKeys uint16 + // padding: 2 bytes +} + +// KeyInfoRead reads a byte slice into a KeyInfo value. +func KeyInfoRead(buf []byte, v *KeyInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.MinKeycode = KeyCode(buf[b]) + b += 1 + + v.MaxKeycode = KeyCode(buf[b]) + b += 1 + + v.NumKeys = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b +} + +// 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) +} + +// Bytes writes a KeyInfo value to a byte slice. +func (v KeyInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + xgb.Put16(buf[b:], v.NumKeys) + b += 2 + + b += 2 // padding + + return buf +} + +// 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 +} + +type KeyState struct { + ClassId byte + Len byte + NumKeys byte + // padding: 1 bytes + Keys []byte // size: 32 +} + +// KeyStateRead reads a byte slice into a KeyState value. +func KeyStateRead(buf []byte, v *KeyState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumKeys = buf[b] + b += 1 + + b += 1 // padding + + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// 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 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 + 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 +} + +// 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 +} + +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 + + v.Id = buf[b] + b += 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) +} + +// 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.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + return buf +} + +// 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 +} + +type LedFeedbackState struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 +} + +// LedFeedbackStateRead reads a byte slice into a LedFeedbackState value. +func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 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 +} + +// 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) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + 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 +} + +// BadMode is the error number for a BadMode. +const BadMode = 2 + +type ModeError struct { + Sequence uint16 + NiceName string +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadMode error. // This is mostly used internally. -func (v DeviceButtonPressEvent) SequenceId() uint16 { - return v.Sequence +func (err ModeError) SequenceId() uint16 { + return err.Sequence } -func (v DeviceButtonPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// 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 +} + +// Error returns a rudimentary string representation of the BadMode error. + +func (err ModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew + xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew } -// DeviceButtonRelease is the event number for a DeviceButtonReleaseEvent. -const DeviceButtonRelease = 4 - -type DeviceButtonReleaseEvent DeviceKeyPressEvent - -// DeviceButtonReleaseEventNew constructs a DeviceButtonReleaseEvent value that implements xgb.Event from a byte slice. -func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { - return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) -} - -// Bytes writes a DeviceButtonReleaseEvent value to a byte slice. -func (v DeviceButtonReleaseEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() -} - -// 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 -} - -func (v DeviceButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew -} - -// DeviceMotionNotify is the event number for a DeviceMotionNotifyEvent. -const DeviceMotionNotify = 5 - -type DeviceMotionNotifyEvent DeviceKeyPressEvent - -// DeviceMotionNotifyEventNew constructs a DeviceMotionNotifyEvent value that implements xgb.Event from a byte slice. -func DeviceMotionNotifyEventNew(buf []byte) xgb.Event { - return DeviceMotionNotifyEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) -} - -// Bytes writes a DeviceMotionNotifyEvent value to a byte slice. -func (v DeviceMotionNotifyEvent) Bytes() []byte { - return DeviceKeyPressEvent(v).Bytes() -} - -// SequenceId returns the sequence id attached to the DeviceMotionNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DeviceMotionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v DeviceMotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) - return "DeviceMotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][5] = DeviceMotionNotifyEventNew -} +const ( + PropagateModeAddToList = 0 + PropagateModeDeleteFromList = 1 +) // ProximityIn is the event number for a ProximityInEvent. const ProximityIn = 8 @@ -4307,897 +3996,642 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][9] = ProximityOutEventNew } -// 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)) +type PtrFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + Num int16 + Denom int16 + Threshold int16 } -// Bytes writes a FocusOutEvent value to a byte slice. -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() -} - -// 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 -} - -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, ", ") + "}" -} - -func init() { - xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew -} - -// BadDevice is the error number for a BadDevice. -const BadDevice = 0 - -type DeviceError struct { - Sequence uint16 - NiceName string -} - -// DeviceErrorNew constructs a DeviceError value that implements xgb.Error from a byte slice. -func DeviceErrorNew(buf []byte) xgb.Error { - v := DeviceError{} - v.NiceName = "Device" - - 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 BadDevice error. -// This is mostly used internally. -func (err DeviceError) SequenceId() uint16 { - return err.Sequence -} - -// 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 -} - -// Error returns a rudimentary string representation of the BadDevice error. - -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, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew -} - -// 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 -} - -// BadMode is the error number for a BadMode. -const BadMode = 2 - -type ModeError struct { - Sequence uint16 - NiceName string -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// SequenceId returns the sequence id attached to the BadMode error. -// This is mostly used internally. -func (err ModeError) SequenceId() uint16 { - return err.Sequence -} - -// 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 -} - -// Error returns a rudimentary string representation of the BadMode error. - -func (err ModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew -} - -// BadDeviceBusy is the error number for a BadDeviceBusy. -const BadDeviceBusy = 3 - -type DeviceBusyError struct { - Sequence uint16 - NiceName string -} - -// DeviceBusyErrorNew constructs a DeviceBusyError value that implements xgb.Error from a byte slice. -func DeviceBusyErrorNew(buf []byte) xgb.Error { - v := DeviceBusyError{} - v.NiceName = "DeviceBusy" - - 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 BadDeviceBusy error. -// This is mostly used internally. -func (err DeviceBusyError) SequenceId() uint16 { - return err.Sequence -} - -// 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 -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew -} - -// BadClass is the error number for a BadClass. -const BadClass = 4 - -type ClassError struct { - Sequence uint16 - NiceName string -} - -// ClassErrorNew constructs a ClassError value that implements xgb.Error from a byte slice. -func ClassErrorNew(buf []byte) xgb.Error { - v := ClassError{} - v.NiceName = "Class" - - 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 BadClass error. -// This is mostly used internally. -func (err ClassError) SequenceId() uint16 { - return err.Sequence -} - -// 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 -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew -} - -// GetExtensionVersionCookie is a cookie used only for GetExtensionVersion requests. -type GetExtensionVersionCookie 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. -// 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 'GetExtensionVersion' 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 -} - -// 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 - } - return getExtensionVersionReply(buf), nil -} - -// 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 -} - -// 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)))) +// PtrFeedbackCtlRead reads a byte slice into a PtrFeedbackCtl value. +func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { b := 0 - buf := make([]byte, size) - buf[b] = c.Extensions["XINPUTEXTENSION"] + v.ClassId = buf[b] b += 1 - buf[b] = 1 // request opcode + v.Id = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], NameLen) + v.Len = xgb.Get16(buf[b:]) b += 2 b += 2 // padding - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + v.Num = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Denom = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Threshold = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// 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) +} + +// Bytes writes a PtrFeedbackCtl value to a byte slice. +func (v PtrFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], uint16(v.Num)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Denom)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Threshold)) + b += 2 return buf } -// ListInputDevicesCookie is a cookie used only for ListInputDevices requests. -type ListInputDevicesCookie 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") +// 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)) } - cookie := c.NewCookie(true, true) - c.NewRequest(listInputDevicesRequest(c), cookie) - return ListInputDevicesCookie{cookie} + return b } -// ListInputDevicesUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'ListInputDevices' 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} +type PtrFeedbackState struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + AccelNum uint16 + AccelDenom uint16 + Threshold uint16 } -// 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)) -} +// PtrFeedbackStateRead reads a byte slice into a PtrFeedbackState value. +func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) int { + b := 0 -// 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 -} + v.ClassId = buf[b] + b += 1 -// listInputDevicesReply reads a byte slice into a ListInputDevicesReply value. -func listInputDevicesReply(buf []byte) *ListInputDevicesReply { - v := new(ListInputDevicesReply) - b := 1 // skip reply determinant + v.Id = buf[b] + b += 1 - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) + v.Len = xgb.Get16(buf[b:]) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + 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 +} + +// 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) +} + +// Bytes writes a PtrFeedbackState value to a byte slice. +func (v PtrFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], v.AccelNum) + b += 2 + + xgb.Put16(buf[b:], v.AccelDenom) + b += 2 + + xgb.Put16(buf[b:], v.Threshold) + b += 2 + + return buf +} + +// 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 +} + +type StringFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +} + +// 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 +} + +// 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) +} + +// 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 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], 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 +} + +// 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 +} + +// 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 StringFeedbackState struct { + ClassId byte + Id byte + Len uint16 + MaxSymbols uint16 + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +} + +// StringFeedbackStateRead reads a byte slice into a StringFeedbackState value. +func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MaxSymbols = xgb.Get16(buf[b:]) + b += 2 + + v.NumKeysyms = xgb.Get16(buf[b:]) + b += 2 + + v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) + for i := 0; i < int(v.NumKeysyms); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// 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) +} + +// 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 +} + +// 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 +} + +// 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 +} + +type ValuatorInfo struct { + ClassId byte + Len byte + AxesLen byte + Mode byte + MotionSize uint32 + Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) +} + +// ValuatorInfoRead reads a byte slice into a ValuatorInfo value. +func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.AxesLen = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.MotionSize = xgb.Get32(buf[b:]) b += 4 - v.DevicesLen = buf[b] - b += 1 + v.Axes = make([]AxisInfo, v.AxesLen) + b += AxisInfoReadList(buf[b:], v.Axes) - b += 23 // padding - - v.Devices = make([]DeviceInfo, v.DevicesLen) - b += DeviceInfoReadList(buf[b:], v.Devices) - - return v + return b } -// Write request to wire for ListInputDevices -// listInputDevicesRequest writes a ListInputDevices request to a byte slice. -func listInputDevicesRequest(c *xgb.Conn) []byte { - size := 4 +// ValuatorInfoReadList reads a byte slice into a list of ValuatorInfo values. +func ValuatorInfoReadList(buf []byte, dest []ValuatorInfo) int { b := 0 - buf := make([]byte, size) + for i := 0; i < len(dest); i++ { + dest[i] = ValuatorInfo{} + b += ValuatorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - buf[b] = c.Extensions["XINPUTEXTENSION"] +// 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 + + buf[b] = v.ClassId b += 1 - buf[b] = 2 // request opcode + buf[b] = v.Len b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + buf[b] = v.AxesLen + b += 1 - return buf -} + buf[b] = v.Mode + b += 1 -// OpenDeviceCookie is a cookie used only for OpenDevice requests. -type OpenDeviceCookie 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'OpenDevice' 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} -} - -// OpenDeviceUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'OpenDevice' 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} -} - -// OpenDeviceReply represents the data returned from a OpenDevice request. -type OpenDeviceReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumClasses byte - // padding: 23 bytes - ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) -} - -// Reply blocks and returns the reply data for a OpenDevice request. -func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return openDeviceReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], v.MotionSize) b += 4 - v.NumClasses = 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 + b += AxisInfoListBytes(buf[b:], v.Axes) return buf } -// CloseDeviceCookie is a cookie used only for CloseDevice requests. -type CloseDeviceCookie struct { +// 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 +} + +// 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 +} + +const ( + ValuatorModeRelative = 0 + ValuatorModeAbsolute = 1 +) + +type ValuatorState struct { + ClassId byte + Len byte + NumValuators byte + Mode byte + Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// ValuatorStateRead reads a byte slice into a ValuatorState value. +func ValuatorStateRead(buf []byte, v *ValuatorState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.Valuators = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.Valuators[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// 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) +} + +// 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 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.Mode + b += 1 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// 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 +} + +// ValuatorStateListSize computes the size (bytes) of a list of ValuatorState values. +func ValuatorStateListSize(list []ValuatorState) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// AllowDeviceEventsCookie is a cookie used only for AllowDeviceEvents requests. +type AllowDeviceEventsCookie struct { *xgb.Cookie } -// CloseDevice 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 CloseDevice(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { +func AllowDeviceEvents(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'CloseDevice' 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, false) - c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) - return CloseDeviceCookie{cookie} + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{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 { +// 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 'CloseDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'AllowDeviceEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) - return CloseDeviceCookie{cookie} + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} } // Check returns an error if one occurred 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 { +func (cook AllowDeviceEventsCookie) 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 +// 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] = 4 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - 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(setDeviceModeRequest(c, DeviceId, Mode), cookie) - return SetDeviceModeCookie{cookie} -} - -// SetDeviceModeUnchecked 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 { - 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(false, true) - c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) - return SetDeviceModeCookie{cookie} -} - -// 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 - Status byte - // padding: 23 bytes -} - -// 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 - } - if buf == nil { - return nil, nil - } - return setDeviceModeReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Time)) b += 4 - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -// Write request to wire for SetDeviceMode -// setDeviceModeRequest writes a SetDeviceMode request to a byte slice. -func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - 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 - - buf[b] = DeviceId - b += 1 - buf[b] = Mode b += 1 - b += 2 // padding - - return buf -} - -// SelectExtensionEventCookie is a cookie used only for SelectExtensionEvent requests. -type SelectExtensionEventCookie struct { - *xgb.Cookie -} - -// SelectExtensionEvent sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectExtensionEvent(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SelectExtensionEvent' 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} -} - -// 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 'SelectExtensionEvent' 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for SelectExtensionEvent -// selectExtensionEventRequest writes a SelectExtensionEvent request to a byte slice. -func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] + buf[b] = DeviceId 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(Window)) - b += 4 - - xgb.Put16(buf[b:], NumClasses) - b += 2 - - 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 -} - -// GetSelectedExtensionEventsCookie is a cookie used only for GetSelectedExtensionEvents requests. -type GetSelectedExtensionEventsCookie struct { - *xgb.Cookie -} - -// GetSelectedExtensionEvents sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectedExtensionEventsCookie.Reply() -func GetSelectedExtensionEvents(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) - return GetSelectedExtensionEventsCookie{cookie} -} - -// GetSelectedExtensionEventsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) - return GetSelectedExtensionEventsCookie{cookie} -} - -// GetSelectedExtensionEventsReply represents the data returned from a GetSelectedExtensionEvents request. -type GetSelectedExtensionEventsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumThisClasses uint16 - NumAllClasses uint16 - // padding: 20 bytes - ThisClasses []EventClass // size: xgb.Pad((int(NumThisClasses) * 4)) - AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) -} - -// Reply blocks and returns the reply data for a GetSelectedExtensionEvents request. -func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEventsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectedExtensionEventsReply(buf), nil -} - -// getSelectedExtensionEventsReply reads a byte slice into a GetSelectedExtensionEventsReply value. -func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { - v := new(GetSelectedExtensionEventsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumThisClasses = xgb.Get16(buf[b:]) - b += 2 - - v.NumAllClasses = xgb.Get16(buf[b:]) - b += 2 - - b += 20 // padding - - v.ThisClasses = make([]EventClass, v.NumThisClasses) - for i := 0; i < int(v.NumThisClasses); i++ { - v.ThisClasses[i] = EventClass(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - v.AllClasses = make([]EventClass, v.NumAllClasses) - for i := 0; i < int(v.NumAllClasses); i++ { - v.AllClasses[i] = EventClass(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetSelectedExtensionEvents -// getSelectedExtensionEventsRequest writes a GetSelectedExtensionEvents request to a byte slice. -func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - return buf } @@ -5270,207 +4704,73 @@ func changeDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window, Num return buf } -// GetDeviceDontPropagateListCookie is a cookie used only for GetDeviceDontPropagateList requests. -type GetDeviceDontPropagateListCookie struct { +// ChangeDeviceKeyMappingCookie is a cookie used only for ChangeDeviceKeyMapping requests. +type ChangeDeviceKeyMappingCookie struct { *xgb.Cookie } -// GetDeviceDontPropagateList sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceDontPropagateListCookie.Reply() -func GetDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) - return GetDeviceDontPropagateListCookie{cookie} -} - -// GetDeviceDontPropagateListUnchecked sends an unchecked request. +// ChangeDeviceKeyMapping sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceDontPropagateListUnchecked(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { +func 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 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) - return GetDeviceDontPropagateListCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) + return ChangeDeviceKeyMappingCookie{cookie} } -// GetDeviceDontPropagateListReply represents the data returned from a GetDeviceDontPropagateList request. -type GetDeviceDontPropagateListReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumClasses uint16 - // padding: 22 bytes - Classes []EventClass // size: xgb.Pad((int(NumClasses) * 4)) +// 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} } -// Reply blocks and returns the reply data for a GetDeviceDontPropagateList request. -func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateListReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDeviceDontPropagateListReply(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 ChangeDeviceKeyMappingCookie) Check() error { + return cook.Cookie.Check() } -// getDeviceDontPropagateListReply reads a byte slice into a GetDeviceDontPropagateListReply value. -func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListReply { - v := new(GetDeviceDontPropagateListReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumClasses = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Classes = make([]EventClass, v.NumClasses) - for i := 0; i < int(v.NumClasses); i++ { - v.Classes[i] = EventClass(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetDeviceDontPropagateList -// getDeviceDontPropagateListRequest writes a GetDeviceDontPropagateList request to a byte slice. -func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// 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] = 9 // 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(Window)) - b += 4 - - return buf -} - -// GetDeviceMotionEventsCookie is a cookie used only for GetDeviceMotionEvents requests. -type GetDeviceMotionEventsCookie 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceMotionEvents' 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} -} - -// GetDeviceMotionEventsUnchecked 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceMotionEvents' 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} -} - -// 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 - NumCoords uint32 - NumAxes byte - DeviceMode byte - // padding: 18 bytes -} - -// 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 - } - if buf == nil { - return nil, nil - } - return getDeviceMotionEventsReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumCoords = xgb.Get32(buf[b:]) - b += 4 - - v.NumAxes = buf[b] - b += 1 - - v.DeviceMode = buf[b] - b += 1 - - b += 18 // 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Start)) - b += 4 - - xgb.Put32(buf[b:], uint32(Stop)) - b += 4 - 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 } @@ -5666,6 +4966,1141 @@ func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId by 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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// DeviceBellCookie is a cookie used only for DeviceBell requests. +type DeviceBellCookie struct { + *xgb.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} +} + +// DeviceBellChecked sends a checked request. +// If an error occurs, it can be retrieved using DeviceBellCookie.Check() +func DeviceBellChecked(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'DeviceBell' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DeviceBellCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeviceBell +// deviceBellRequest writes a DeviceBell request to a byte slice. +func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 32 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = FeedbackId + b += 1 + + buf[b] = FeedbackClass + b += 1 + + buf[b] = byte(Percent) + b += 1 + + return buf +} + +// GetDeviceButtonMappingCookie is a cookie used only for GetDeviceButtonMapping requests. +type GetDeviceButtonMappingCookie struct { + *xgb.Cookie +} + +// GetDeviceButtonMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceButtonMappingCookie.Reply() +func GetDeviceButtonMapping(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} +} + +// GetDeviceButtonMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} +} + +// GetDeviceButtonMappingReply represents the data returned from a GetDeviceButtonMapping request. +type GetDeviceButtonMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MapSize byte + // padding: 23 bytes + Map []byte // size: xgb.Pad((int(MapSize) * 1)) +} + +// Reply blocks and returns the reply data for a GetDeviceButtonMapping request. +func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceButtonMappingReply(buf), nil +} + +// getDeviceButtonMappingReply reads a byte slice into a GetDeviceButtonMappingReply value. +func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { + v := new(GetDeviceButtonMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MapSize = buf[b] + b += 1 + + b += 23 // padding + + v.Map = make([]byte, v.MapSize) + copy(v.Map[:v.MapSize], buf[b:]) + b += xgb.Pad(int(v.MapSize)) + + return v +} + +// Write request to wire for GetDeviceButtonMapping +// getDeviceButtonMappingRequest writes a GetDeviceButtonMapping request to a byte slice. +func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// GetDeviceControlCookie is a cookie used only for GetDeviceControl requests. +type GetDeviceControlCookie struct { + *xgb.Cookie +} + +// GetDeviceControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceControlCookie.Reply() +func GetDeviceControl(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{cookie} +} + +// GetDeviceControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceControlUnchecked(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{cookie} +} + +// GetDeviceControlReply represents the data returned from a GetDeviceControl request. +type GetDeviceControlReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Reply blocks and returns the reply data for a GetDeviceControl request. +func (cook GetDeviceControlCookie) Reply() (*GetDeviceControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceControlReply(buf), nil +} + +// getDeviceControlReply reads a byte slice into a GetDeviceControlReply value. +func getDeviceControlReply(buf []byte) *GetDeviceControlReply { + v := new(GetDeviceControlReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for GetDeviceControl +// getDeviceControlRequest writes a GetDeviceControl request to a byte slice. +func getDeviceControlRequest(c *xgb.Conn, ControlId uint16, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 34 // 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) + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 1 // padding + + return buf +} + +// GetDeviceDontPropagateListCookie is a cookie used only for GetDeviceDontPropagateList requests. +type GetDeviceDontPropagateListCookie struct { + *xgb.Cookie +} + +// GetDeviceDontPropagateList sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceDontPropagateListCookie.Reply() +func GetDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} +} + +// GetDeviceDontPropagateListUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceDontPropagateListUnchecked(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceDontPropagateList' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} +} + +// GetDeviceDontPropagateListReply represents the data returned from a GetDeviceDontPropagateList request. +type GetDeviceDontPropagateListReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumClasses uint16 + // padding: 22 bytes + Classes []EventClass // size: xgb.Pad((int(NumClasses) * 4)) +} + +// Reply blocks and returns the reply data for a GetDeviceDontPropagateList request. +func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceDontPropagateListReply(buf), nil +} + +// getDeviceDontPropagateListReply reads a byte slice into a GetDeviceDontPropagateListReply value. +func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListReply { + v := new(GetDeviceDontPropagateListReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumClasses = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Classes = make([]EventClass, v.NumClasses) + for i := 0; i < int(v.NumClasses); i++ { + v.Classes[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDeviceDontPropagateList +// getDeviceDontPropagateListRequest writes a GetDeviceDontPropagateList request to a byte slice. +func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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(Window)) + b += 4 + + return buf +} + +// GetDeviceFocusCookie is a cookie used only for GetDeviceFocus requests. +type GetDeviceFocusCookie 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceFocus' 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} +} + +// GetDeviceFocusUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceFocus' 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} +} + +// GetDeviceFocusReply represents the data returned from a GetDeviceFocus request. +type GetDeviceFocusReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Focus xproto.Window + Time xproto.Timestamp + RevertTo byte + // padding: 15 bytes +} + +// Reply blocks and returns the reply data for a GetDeviceFocus request. +func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceFocusReply(buf), nil +} + +// getDeviceFocusReply reads a byte slice into a GetDeviceFocusReply value. +func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { + v := new(GetDeviceFocusReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Focus = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.RevertTo = buf[b] + b += 1 + + b += 15 // padding + + return v +} + +// Write request to wire for GetDeviceFocus +// getDeviceFocusRequest writes a GetDeviceFocus request to a byte slice. +func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 20 // 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 +} + +// GetDeviceKeyMappingCookie is a cookie used only for GetDeviceKeyMapping requests. +type GetDeviceKeyMappingCookie struct { + *xgb.Cookie +} + +// GetDeviceKeyMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceKeyMappingCookie.Reply() +func GetDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +// GetDeviceKeyMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +// GetDeviceKeyMappingReply represents the data returned from a GetDeviceKeyMapping request. +type GetDeviceKeyMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + KeysymsPerKeycode byte + // padding: 23 bytes + Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) +} + +// Reply blocks and returns the reply data for a GetDeviceKeyMapping request. +func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceKeyMappingReply(buf), nil +} + +// getDeviceKeyMappingReply reads a byte slice into a GetDeviceKeyMappingReply value. +func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { + v := new(GetDeviceKeyMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + 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 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 +} + +// GetDeviceModifierMappingCookie is a cookie used only for GetDeviceModifierMapping requests. +type GetDeviceModifierMappingCookie 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceModifierMapping' 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} +} + +// GetDeviceModifierMappingUnchecked 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceModifierMapping' 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} +} + +// 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 + KeycodesPerModifier byte + // padding: 23 bytes + Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) +} + +// Reply blocks and returns the reply data for a GetDeviceModifierMapping request. +func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceModifierMappingReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + 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 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) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + 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] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// GetDeviceMotionEventsCookie is a cookie used only for GetDeviceMotionEvents requests. +type GetDeviceMotionEventsCookie 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceMotionEvents' 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} +} + +// GetDeviceMotionEventsUnchecked 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetDeviceMotionEvents' 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} +} + +// 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 + NumCoords uint32 + NumAxes byte + DeviceMode byte + // padding: 18 bytes +} + +// 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 + } + if buf == nil { + return nil, nil + } + return getDeviceMotionEventsReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumCoords = xgb.Get32(buf[b:]) + b += 4 + + v.NumAxes = buf[b] + b += 1 + + v.DeviceMode = buf[b] + b += 1 + + b += 18 // 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 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Start)) + b += 4 + + xgb.Put32(buf[b:], uint32(Stop)) + b += 4 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// GetExtensionVersionCookie is a cookie used only for GetExtensionVersion requests. +type GetExtensionVersionCookie 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. +// 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 'GetExtensionVersion' 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 +} + +// 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 + } + return getExtensionVersionReply(buf), nil +} + +// 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 +} + +// 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] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// GetFeedbackControlCookie is a cookie used only for GetFeedbackControl requests. +type GetFeedbackControlCookie 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 { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetFeedbackControl' 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} +} + +// 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 'GetFeedbackControl' 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} +} + +// 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 +} + +// 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 +} + +// getFeedbackControlReply reads a byte slice into a GetFeedbackControlReply value. +func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { + v := new(GetFeedbackControlReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumFeedback = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + return v +} + +// Write request to wire for GetFeedbackControl +// getFeedbackControlRequest writes a GetFeedbackControl request to a byte slice. +func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + 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 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// GetSelectedExtensionEventsCookie is a cookie used only for GetSelectedExtensionEvents requests. +type GetSelectedExtensionEventsCookie struct { + *xgb.Cookie +} + +// GetSelectedExtensionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectedExtensionEventsCookie.Reply() +func GetSelectedExtensionEvents(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +// GetSelectedExtensionEventsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'GetSelectedExtensionEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +// GetSelectedExtensionEventsReply represents the data returned from a GetSelectedExtensionEvents request. +type GetSelectedExtensionEventsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumThisClasses uint16 + NumAllClasses uint16 + // padding: 20 bytes + ThisClasses []EventClass // size: xgb.Pad((int(NumThisClasses) * 4)) + AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) +} + +// Reply blocks and returns the reply data for a GetSelectedExtensionEvents request. +func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectedExtensionEventsReply(buf), nil +} + +// getSelectedExtensionEventsReply reads a byte slice into a GetSelectedExtensionEventsReply value. +func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { + v := new(GetSelectedExtensionEventsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumThisClasses = xgb.Get16(buf[b:]) + b += 2 + + v.NumAllClasses = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.ThisClasses = make([]EventClass, v.NumThisClasses) + for i := 0; i < int(v.NumThisClasses); i++ { + v.ThisClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.AllClasses = make([]EventClass, v.NumAllClasses) + for i := 0; i < int(v.NumAllClasses); i++ { + v.AllClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetSelectedExtensionEvents +// getSelectedExtensionEventsRequest writes a GetSelectedExtensionEvents request to a byte slice. +func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + // GrabDeviceCookie is a cookie used only for GrabDevice requests. type GrabDeviceCookie struct { *xgb.Cookie @@ -5787,61 +6222,90 @@ func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timest return buf } -// UngrabDeviceCookie is a cookie used only for UngrabDevice requests. -type UngrabDeviceCookie struct { +// GrabDeviceButtonCookie is a cookie used only for GrabDeviceButton requests. +type GrabDeviceButtonCookie struct { *xgb.Cookie } -// UngrabDevice sends an unchecked request. +// GrabDeviceButton sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabDevice(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { +func GrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) - return UngrabDeviceCookie{cookie} + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{cookie} } -// UngrabDeviceChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabDeviceCookie.Check() -func UngrabDeviceChecked(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { +// GrabDeviceButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabDeviceButtonCookie.Check() +func GrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'GrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) - return UngrabDeviceCookie{cookie} + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabDeviceCookie) Check() error { +func (cook GrabDeviceButtonCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UngrabDevice -// ungrabDeviceRequest writes a UngrabDevice request to a byte slice. -func ungrabDeviceRequest(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) []byte { - size := 12 +// Write request to wire for GrabDeviceButton +// grabDeviceButtonRequest writes a GrabDeviceButton request to a byte slice. +func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - buf[b] = DeviceId + buf[b] = GrabbedDevice b += 1 + buf[b] = ModifierDevice + b += 1 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + buf[b] = Button + b += 1 + + buf[b] = OwnerEvents + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + return buf } @@ -5936,149 +6400,343 @@ func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint return buf } -// UngrabDeviceKeyCookie is a cookie used only for UngrabDeviceKey requests. -type UngrabDeviceKeyCookie struct { +// ListInputDevicesCookie is a cookie used only for ListInputDevices requests. +type ListInputDevicesCookie struct { *xgb.Cookie } -// UngrabDeviceKey sends an unchecked request. +// 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 'ListInputDevices' 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} +} + +// ListInputDevicesUnchecked 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 { +func ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'UngrabDeviceKey' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'ListInputDevices' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return UngrabDeviceKeyCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} } -// 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.") +// 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)) +} + +// 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return UngrabDeviceKeyCookie{cookie} + if buf == nil { + return nil, nil + } + return listInputDevicesReply(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 UngrabDeviceKeyCookie) Check() error { - return cook.Cookie.Check() +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.DevicesLen = buf[b] + b += 1 + + b += 23 // padding + + v.Devices = make([]DeviceInfo, v.DevicesLen) + b += DeviceInfoReadList(buf[b:], v.Devices) + + return v } -// Write request to wire for 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 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] = 16 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Key - b += 1 - - buf[b] = GrabbedDevice - b += 1 - return buf } -// GrabDeviceButtonCookie is a cookie used only for GrabDeviceButton requests. -type GrabDeviceButtonCookie struct { +// OpenDeviceCookie is a cookie used only for OpenDevice requests. +type OpenDeviceCookie struct { *xgb.Cookie } -// GrabDeviceButton sends an unchecked request. +// 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 'OpenDevice' 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} +} + +// OpenDeviceUnchecked 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 { +func OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { 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 'OpenDevice' 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(false, true) + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") +// OpenDeviceReply represents the data returned from a OpenDevice request. +type OpenDeviceReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumClasses byte + // padding: 23 bytes + ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) +} + +// 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 } - cookie := c.NewCookie(true, false) - c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return GrabDeviceButtonCookie{cookie} + if buf == nil { + return nil, nil + } + return openDeviceReply(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 GrabDeviceButtonCookie) Check() error { - return cook.Cookie.Check() +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumClasses = buf[b] + b += 1 + + b += 23 // padding + + v.ClassInfo = make([]InputClassInfo, v.NumClasses) + b += InputClassInfoReadList(buf[b:], v.ClassInfo) + + return v } -// Write request to wire for GrabDeviceButton -// grabDeviceButtonRequest writes a GrabDeviceButton request to a byte slice. -func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) []byte { - size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +// Write request to wire for 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] = 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(GrabWindow)) + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// QueryDeviceStateCookie is a cookie used only for QueryDeviceState requests. +type QueryDeviceStateCookie struct { + *xgb.Cookie +} + +// QueryDeviceState sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryDeviceStateCookie.Reply() +func QueryDeviceState(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'QueryDeviceState' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} +} + +// QueryDeviceStateUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'QueryDeviceState' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} +} + +// QueryDeviceStateReply represents the data returned from a QueryDeviceState request. +type QueryDeviceStateReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumClasses byte + // padding: 23 bytes +} + +// Reply blocks and returns the reply data for a QueryDeviceState request. +func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryDeviceStateReply(buf), nil +} + +// queryDeviceStateReply reads a byte slice into a QueryDeviceStateReply value. +func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { + v := new(QueryDeviceStateReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - buf[b] = GrabbedDevice + v.NumClasses = buf[b] b += 1 - buf[b] = ModifierDevice + b += 23 // padding + + return v +} + +// Write request to wire for QueryDeviceState +// queryDeviceStateRequest writes a QueryDeviceState request to a byte slice. +func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] b += 1 + buf[b] = 30 // 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 +} + +// SelectExtensionEventCookie is a cookie used only for SelectExtensionEvent requests. +type SelectExtensionEventCookie struct { + *xgb.Cookie +} + +// SelectExtensionEvent sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SelectExtensionEvent(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { + if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { + panic("Cannot issue request 'SelectExtensionEvent' 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} +} + +// 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 'SelectExtensionEvent' 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} +} + +// Check returns an error if one occurred 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() +} + +// Write request to wire for SelectExtensionEvent +// selectExtensionEventRequest writes a SelectExtensionEvent request to a byte slice. +func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 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)) + b += 4 + 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++ { @@ -6090,859 +6748,85 @@ func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevic return buf } -// UngrabDeviceButtonCookie is a cookie used only for UngrabDeviceButton requests. -type UngrabDeviceButtonCookie struct { +// SendExtensionEventCookie is a cookie used only for SendExtensionEvent requests. +type SendExtensionEventCookie struct { *xgb.Cookie } -// UngrabDeviceButton sends an unchecked request. +// SendExtensionEvent 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 { +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 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SendExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return UngrabDeviceButtonCookie{cookie} + c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) + return SendExtensionEventCookie{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 { +// 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 'UngrabDeviceButton' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + panic("Cannot issue request 'SendExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return UngrabDeviceButtonCookie{cookie} + 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 UngrabDeviceButtonCookie) Check() error { +func (cook SendExtensionEventCookie) Check() error { return cook.Cookie.Check() } -// 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 +// 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] = 18 // 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(GrabWindow)) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - xgb.Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - return buf -} - -// AllowDeviceEventsCookie is a cookie used only for AllowDeviceEvents requests. -type AllowDeviceEventsCookie struct { - *xgb.Cookie -} - -// AllowDeviceEvents sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllowDeviceEvents(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'AllowDeviceEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) - return AllowDeviceEventsCookie{cookie} -} - -// AllowDeviceEventsChecked sends a checked request. -// If an error occurs, it can be retrieved using AllowDeviceEventsCookie.Check() -func AllowDeviceEventsChecked(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'AllowDeviceEvents' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) - return AllowDeviceEventsCookie{cookie} -} - -// Check returns an error if one occurred 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 AllowDeviceEvents -// allowDeviceEventsRequest writes a AllowDeviceEvents request to a byte slice. -func allowDeviceEventsRequest(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = Mode - b += 1 - buf[b] = DeviceId b += 1 - return buf -} - -// GetDeviceFocusCookie is a cookie used only for GetDeviceFocus requests. -type GetDeviceFocusCookie 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceFocus' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) - return GetDeviceFocusCookie{cookie} -} + b += 1 -// GetDeviceFocusUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceFocus' 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} -} - -// GetDeviceFocusReply represents the data returned from a GetDeviceFocus request. -type GetDeviceFocusReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Focus xproto.Window - Time xproto.Timestamp - RevertTo byte - // padding: 15 bytes -} - -// Reply blocks and returns the reply data for a GetDeviceFocus request. -func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDeviceFocusReply(buf), nil -} - -// getDeviceFocusReply reads a byte slice into a GetDeviceFocusReply value. -func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { - v := new(GetDeviceFocusReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], NumClasses) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Focus = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.RevertTo = buf[b] - b += 1 - - b += 15 // padding - - return v -} - -// Write request to wire for GetDeviceFocus -// getDeviceFocusRequest writes a GetDeviceFocus request to a byte slice. -func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId + buf[b] = NumEvents b += 1 b += 3 // padding - return buf -} + copy(buf[b:], Events[:(int(NumEvents)*32)]) + b += xgb.Pad(int((int(NumEvents) * 32))) -// SetDeviceFocusCookie is a cookie used only for SetDeviceFocus requests. -type SetDeviceFocusCookie struct { - *xgb.Cookie -} - -// 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 '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 -} - -// GetFeedbackControlCookie is a cookie used only for GetFeedbackControl requests. -type GetFeedbackControlCookie 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetFeedbackControl' 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} -} - -// 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 'GetFeedbackControl' 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} -} - -// 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 -} - -// 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 -} - -// getFeedbackControlReply reads a byte slice into a GetFeedbackControlReply value. -func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { - v := new(GetFeedbackControlReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumFeedback = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -// Write request to wire for GetFeedbackControl -// getFeedbackControlRequest writes a GetFeedbackControl request to a byte slice. -func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - 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 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// GetDeviceKeyMappingCookie is a cookie used only for GetDeviceKeyMapping requests. -type GetDeviceKeyMappingCookie struct { - *xgb.Cookie -} - -// GetDeviceKeyMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceKeyMappingCookie.Reply() -func GetDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) - return GetDeviceKeyMappingCookie{cookie} -} - -// GetDeviceKeyMappingUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceKeyMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) - return GetDeviceKeyMappingCookie{cookie} -} - -// GetDeviceKeyMappingReply represents the data returned from a GetDeviceKeyMapping request. -type GetDeviceKeyMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - KeysymsPerKeycode byte - // padding: 23 bytes - Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) -} - -// Reply blocks and returns the reply data for a GetDeviceKeyMapping request. -func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDeviceKeyMappingReply(buf), nil -} - -// getDeviceKeyMappingReply reads a byte slice into a GetDeviceKeyMappingReply value. -func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { - v := new(GetDeviceKeyMappingReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - 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:])) + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) b += 4 } b = xgb.Pad(b) - return v -} - -// Write request to wire for GetDeviceKeyMapping -// getDeviceKeyMappingRequest writes a GetDeviceKeyMapping request to a byte slice. -func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = Count - b += 1 - - return buf -} - -// 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - 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 -} - -// GetDeviceModifierMappingCookie is a cookie used only for GetDeviceModifierMapping requests. -type GetDeviceModifierMappingCookie 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceModifierMapping' 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} -} - -// GetDeviceModifierMappingUnchecked 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceModifierMapping' 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} -} - -// 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 - KeycodesPerModifier byte - // padding: 23 bytes - Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) -} - -// Reply blocks and returns the reply data for a GetDeviceModifierMapping request. -func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDeviceModifierMappingReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - 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 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) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - 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] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// SetDeviceModifierMappingCookie is a cookie used only for SetDeviceModifierMapping requests. -type SetDeviceModifierMappingCookie 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SetDeviceModifierMapping' 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} -} - -// 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 'SetDeviceModifierMapping' 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} -} - -// 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 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return setDeviceModifierMappingReply(buf), nil -} - -// 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 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] = 27 // 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] = KeycodesPerModifier - b += 1 - - b += 1 // padding - - copy(buf[b:], Keymaps[:(int(KeycodesPerModifier)*8)]) - b += xgb.Pad(int((int(KeycodesPerModifier) * 8))) - - return buf -} - -// GetDeviceButtonMappingCookie is a cookie used only for GetDeviceButtonMapping requests. -type GetDeviceButtonMappingCookie struct { - *xgb.Cookie -} - -// GetDeviceButtonMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceButtonMappingCookie.Reply() -func GetDeviceButtonMapping(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) - return GetDeviceButtonMappingCookie{cookie} -} - -// GetDeviceButtonMappingUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceButtonMapping' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) - return GetDeviceButtonMappingCookie{cookie} -} - -// GetDeviceButtonMappingReply represents the data returned from a GetDeviceButtonMapping request. -type GetDeviceButtonMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MapSize byte - // padding: 23 bytes - Map []byte // size: xgb.Pad((int(MapSize) * 1)) -} - -// Reply blocks and returns the reply data for a GetDeviceButtonMapping request. -func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getDeviceButtonMappingReply(buf), nil -} - -// getDeviceButtonMappingReply reads a byte slice into a GetDeviceButtonMappingReply value. -func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { - v := new(GetDeviceButtonMappingReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.MapSize = buf[b] - b += 1 - - b += 23 // padding - - v.Map = make([]byte, v.MapSize) - copy(v.Map[:v.MapSize], buf[b:]) - b += xgb.Pad(int(v.MapSize)) - - return v -} - -// Write request to wire for GetDeviceButtonMapping -// getDeviceButtonMappingRequest writes a GetDeviceButtonMapping request to a byte slice. -func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - return buf } @@ -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. +// 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 'SetDeviceModifierMapping' 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} +} + +// SetDeviceModifierMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SendExtensionEvent(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { +func 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.") + 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(false, 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'SendExtensionEvent' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") +// 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 +} + +// 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(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) - return SendExtensionEventCookie{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 SendExtensionEventCookie) 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 -// 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) + b += 1 // padding - 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 + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Destination)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - buf[b] = DeviceId + v.Status = buf[b] b += 1 - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 23 // padding - 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 + return v } -// DeviceBellCookie is a cookie used only for DeviceBell requests. -type DeviceBellCookie struct { - *xgb.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} -} - -// DeviceBellChecked sends a checked request. -// If an error occurs, it can be retrieved using DeviceBellCookie.Check() -func DeviceBellChecked(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'DeviceBell' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return DeviceBellCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DeviceBellCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for DeviceBell -// deviceBellRequest writes a DeviceBell request to a byte slice. -func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { - size := 8 +// 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 { - if _, ok := c.Extensions["XINPUTEXTENSION"]; !ok { - panic("Cannot issue request 'GetDeviceControl' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) - return GetDeviceControlCookie{cookie} -} - -// GetDeviceControlUnchecked sends an unchecked request. +// UngrabDevice 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 { +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(false, 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} } -// 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 +// 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 'UngrabDevice' using the uninitialized extension 'XInputExtension'. xinput.Init(connObj) must be called first.") } - if buf == nil { - return nil, nil - } - return getDeviceControlReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{cookie} } -// 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 +// Check returns an error if one occurred 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 GetDeviceControl -// getDeviceControlRequest writes a GetDeviceControl request to a byte slice. -func getDeviceControlRequest(c *xgb.Conn, ControlId uint16, DeviceId byte) []byte { - size := 8 +// 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] = 34 // 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.Put16(buf[b:], ControlId) - b += 2 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 buf[b] = DeviceId b += 1 - b += 1 // padding + 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.") + } + 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UngrabDeviceButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabDeviceButton +// ungrabDeviceButtonRequest writes a UngrabDeviceButton request to a byte slice. +func ungrabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 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(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + buf[b] = Button + b += 1 + + buf[b] = GrabbedDevice + b += 1 + + return buf +} + +// 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] = 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(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + 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,198 +208,181 @@ func init() { xgb.NewExtErrorFuncs["XpExtension"][1] = BadSequenceErrorNew } -// PrintQueryVersionCookie is a cookie used only for PrintQueryVersion requests. -type PrintQueryVersionCookie struct { - *xgb.Cookie +const ( + DetailStartJobNotify = 1 + DetailEndJobNotify = 2 + DetailStartDocNotify = 3 + DetailEndDocNotify = 4 + DetailStartPageNotify = 5 + DetailEndPageNotify = 6 +) + +const ( + EvMaskNoEventMask = 0 + EvMaskPrintMask = 1 + EvMaskAttributeMask = 2 +) + +const ( + GetDocFinished = 0 + GetDocSecondConsumer = 1 +) + +// Notify is the event number for a NotifyEvent. +const Notify = 0 + +type NotifyEvent struct { + Sequence uint16 + Detail byte + Context Pcontext + Cancel bool } -// 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} -} +// 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 -// 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} -} - -// 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 -} - -// 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 -} - -// 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 + v.Detail = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + v.Context = Pcontext(xgb.Get32(buf[b:])) b += 4 - v.MajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 + if buf[b] == 1 { + v.Cancel = true + } else { + v.Cancel = false + } + b += 1 return v } -// Write request to wire for PrintQueryVersion -// printQueryVersionRequest writes a PrintQueryVersion request to a byte slice. -func printQueryVersionRequest(c *xgb.Conn) []byte { - size := 4 +// Bytes writes a NotifyEvent value to a byte slice. +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf := make([]byte, size) - buf[b] = c.Extensions["XPEXTENSION"] + // write event number + buf[b] = 0 b += 1 - buf[b] = 0 // request opcode + buf[b] = v.Detail b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Context)) + b += 4 + + if v.Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 return buf } -// PrintGetPrinterListCookie is a cookie used only for PrintGetPrinterList requests. -type PrintGetPrinterListCookie struct { - *xgb.Cookie +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence } -// PrintGetPrinterList sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetPrinterListCookie.Reply() -func PrintGetPrinterList(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return PrintGetPrinterListCookie{cookie} +// String is a rudimentary string representation of NotifyEvent. +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Context: %d", v.Context)) + fieldVals = append(fieldVals, xgb.Sprintf("Cancel: %t", v.Cancel)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// PrintGetPrinterListUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetPrinterListUnchecked(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return PrintGetPrinterListCookie{cookie} +func init() { + xgb.NewExtEventFuncs["XpExtension"][0] = NotifyEventNew } -// PrintGetPrinterListReply represents the data returned from a PrintGetPrinterList request. -type PrintGetPrinterListReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ListCount uint32 - // padding: 20 bytes - Printers []Printer // size: PrinterListSize(Printers) -} +type Pcontext uint32 -// Reply blocks and returns the reply data for a PrintGetPrinterList request. -func (cook PrintGetPrinterListCookie) Reply() (*PrintGetPrinterListReply, error) { - buf, err := cook.Cookie.Reply() +func NewPcontextId(c *xgb.Conn) (Pcontext, error) { + id, err := c.NewId() if err != nil { - return nil, err + return 0, err } - if buf == nil { - return nil, nil - } - return printGetPrinterListReply(buf), nil + return Pcontext(id), nil } -// printGetPrinterListReply reads a byte slice into a PrintGetPrinterListReply value. -func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { - v := new(PrintGetPrinterListReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.ListCount = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Printers = make([]Printer, v.ListCount) - b += PrinterReadList(buf[b:], v.Printers) - - return v +type Printer struct { + NameLen uint32 + Name []String8 // size: xgb.Pad((int(NameLen) * 1)) + DescLen uint32 + Description []String8 // size: xgb.Pad((int(DescLen) * 1)) } -// 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)))) +// PrinterRead reads a byte slice into a Printer value. +func PrinterRead(buf []byte, v *Printer) int { b := 0 - buf := make([]byte, size) - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], PrinterNameLen) + v.NameLen = xgb.Get32(buf[b:]) b += 4 - xgb.Put32(buf[b:], LocaleLen) - b += 4 - - for i := 0; i < int(PrinterNameLen); i++ { - buf[b] = byte(PrinterName[i]) + 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) - for i := 0; i < int(LocaleLen); i++ { - buf[b] = byte(Locale[i]) + 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) @@ -636,58 +390,53 @@ func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen ui return buf } -// PrintRehashPrinterListCookie is a cookie used only for PrintRehashPrinterList requests. -type PrintRehashPrinterListCookie struct { - *xgb.Cookie -} - -// PrintRehashPrinterList sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintRehashPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - 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 +// PrinterListBytes writes a list of Printer values to a byte slice. +func PrinterListBytes(buf []byte, list []Printer) int { b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf + 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 +} + +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 @@ -761,42 +510,42 @@ func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, return buf } -// PrintSetContextCookie is a cookie used only for PrintSetContext requests. -type PrintSetContextCookie struct { +// PrintDestroyContextCookie is a cookie used only for PrintDestroyContext requests. +type PrintDestroyContextCookie struct { *xgb.Cookie } -// PrintSetContext sends an unchecked request. +// PrintDestroyContext 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 PrintDestroyContext(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { 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 'PrintDestroyContext' 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(printDestroyContextRequest(c, Context), cookie) + return PrintDestroyContextCookie{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 { +// 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 'PrintSetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintDestroyContext' 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(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 PrintSetContextCookie) Check() error { +func (cook PrintDestroyContextCookie) 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 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) @@ -804,7 +553,7 @@ func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -816,6 +565,285 @@ func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { return buf } +// PrintEndDocCookie is a cookie used only for PrintEndDoc requests. +type PrintEndDocCookie 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 { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintEndDoc' 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} +} + +// 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 'PrintEndDoc' 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 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 +} + +// PrintEndJobCookie is a cookie used only for PrintEndJob requests. +type PrintEndJobCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 8 // 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 +} + +// PrintEndPageCookie is a cookie used only for PrintEndPage requests. +type PrintEndPageCookie struct { + *xgb.Cookie +} + +// PrintEndPage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { + 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 + + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// PrintGetAttributesCookie is a cookie used only for PrintGetAttributes requests. +type PrintGetAttributesCookie 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. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintGetAttributes' 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 +} + +// Reply blocks and returns the reply data for a PrintGetAttributes request. +func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetAttributesReply(buf), nil +} + +// printGetAttributesReply reads a byte slice into a PrintGetAttributesReply value. +func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { + v := new(PrintGetAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.StringLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attributes = String8(buf[b]) + b += 1 + + return v +} + +// Write request to wire for PrintGetAttributes +// printGetAttributesRequest writes a PrintGetAttributes request to a byte slice. +func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 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(Context)) + b += 4 + + buf[b] = Pool + b += 1 + + b += 3 // padding + + return buf +} + // PrintGetContextCookie is a cookie used only for PrintGetContext requests. type PrintGetContextCookie struct { *xgb.Cookie @@ -901,453 +929,6 @@ func printGetContextRequest(c *xgb.Conn) []byte { 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() -} - -// 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 -} - -// PrintGetScreenOfContextCookie is a cookie used only for PrintGetScreenOfContext requests. -type PrintGetScreenOfContextCookie struct { - *xgb.Cookie -} - -// PrintGetScreenOfContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintGetScreenOfContextCookie.Reply() -func PrintGetScreenOfContext(c *xgb.Conn) PrintGetScreenOfContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(printGetScreenOfContextRequest(c), cookie) - return PrintGetScreenOfContextCookie{cookie} -} - -// PrintGetScreenOfContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetScreenOfContextUnchecked(c *xgb.Conn) PrintGetScreenOfContextCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(printGetScreenOfContextRequest(c), cookie) - return PrintGetScreenOfContextCookie{cookie} -} - -// PrintGetScreenOfContextReply represents the data returned from a PrintGetScreenOfContext request. -type PrintGetScreenOfContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Root xproto.Window -} - -// Reply blocks and returns the reply data for a PrintGetScreenOfContext request. -func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return printGetScreenOfContextReply(buf), nil -} - -// printGetScreenOfContextReply reads a byte slice into a PrintGetScreenOfContextReply value. -func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { - v := new(PrintGetScreenOfContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for PrintGetScreenOfContext -// printGetScreenOfContextRequest writes a PrintGetScreenOfContext request to a byte slice. -func printGetScreenOfContextRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// PrintStartJobCookie is a cookie used only for PrintStartJob requests. -type PrintStartJobCookie struct { - *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.") - } - 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(printStartJobRequest(c, OutputMode), cookie) - return PrintStartJobCookie{cookie} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["XPEXTENSION"] - 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 - - buf[b] = OutputMode - b += 1 - - return buf -} - -// PrintEndJobCookie is a cookie used only for PrintEndJob requests. -type PrintEndJobCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 8 // 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 -} - -// PrintStartDocCookie is a cookie used only for PrintStartDoc requests. -type PrintStartDocCookie 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 { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartDoc' 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} -} - -// 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 'PrintStartDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(printStartDocRequest(c, DriverMode), cookie) - return PrintStartDocCookie{cookie} -} - -// Check returns an error if one occurred 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() -} - -// 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 -} - -// PrintEndDocCookie is a cookie used only for PrintEndDoc requests. -type PrintEndDocCookie 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 { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintEndDoc' 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} -} - -// 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 'PrintEndDoc' 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 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 -} - -// PrintPutDocumentDataCookie is a cookie used only for PrintPutDocumentData requests. -type PrintPutDocumentDataCookie struct { - *xgb.Cookie -} - -// PrintPutDocumentData sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintPutDocumentData(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { - 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} -} - -// 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.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return PrintPutDocumentDataCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PrintPutDocumentDataCookie) Check() error { - return cook.Cookie.Check() -} - -// 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] = 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], LenData) - 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)) - - 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 -} - // PrintGetDocumentDataCookie is a cookie used only for PrintGetDocumentData requests. type PrintGetDocumentDataCookie struct { *xgb.Cookie @@ -1455,225 +1036,43 @@ func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) return buf } -// PrintStartPageCookie is a cookie used only for PrintStartPage requests. -type PrintStartPageCookie struct { +// PrintGetImageResolutionCookie is a cookie used only for PrintGetImageResolution requests. +type PrintGetImageResolutionCookie struct { *xgb.Cookie } -// PrintStartPage sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintStartPage(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { +// PrintGetImageResolution sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetImageResolutionCookie.Reply() +func PrintGetImageResolution(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintStartPage' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - 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) - - buf[b] = c.Extensions["XPEXTENSION"] - 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(Window)) - b += 4 - - return buf -} - -// PrintEndPageCookie is a cookie used only for PrintEndPage requests. -type PrintEndPageCookie struct { - *xgb.Cookie -} - -// PrintEndPage sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { - 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = c.Extensions["XPEXTENSION"] - 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 - - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// PrintSelectInputCookie is a cookie used only for PrintSelectInput requests. -type PrintSelectInputCookie struct { - *xgb.Cookie -} - -// PrintSelectInput sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) - return PrintSelectInputCookie{cookie} -} - -// PrintSelectInputChecked sends a checked request. -// If an error occurs, it can be retrieved using PrintSelectInputCookie.Check() -func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) - return PrintSelectInputCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PrintSelectInputCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for PrintSelectInput -// printSelectInputRequest writes a PrintSelectInput request to a byte slice. -func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Context)) - b += 4 - - xgb.Put32(buf[b:], EventMask) - b += 4 - for i := 0; i < xgb.PopCount(int(EventMask)); i++ { - xgb.Put32(buf[b:], EventList[i]) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// PrintInputSelectedCookie is a cookie used only for PrintInputSelected requests. -type PrintInputSelectedCookie struct { - *xgb.Cookie -} - -// PrintInputSelected sends a checked request. -// If an error occurs, it will be returned with the reply by calling PrintInputSelectedCookie.Reply() -func PrintInputSelected(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetImageResolution' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(printInputSelectedRequest(c, Context), cookie) - return PrintInputSelectedCookie{cookie} + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{cookie} } -// PrintInputSelectedUnchecked sends an unchecked request. +// PrintGetImageResolutionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintInputSelectedUnchecked(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { +func PrintGetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + panic("Cannot issue request 'PrintGetImageResolution' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(printInputSelectedRequest(c, Context), cookie) - return PrintInputSelectedCookie{cookie} + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{cookie} } -// PrintInputSelectedReply represents the data returned from a PrintInputSelected request. -type PrintInputSelectedReply struct { +// 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 - EventMask uint32 - EventList []uint32 - AllEventsMask uint32 - AllEventsList []uint32 + ImageResolution uint16 } -// Reply blocks and returns the reply data for a PrintInputSelected request. -func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { +// Reply blocks and returns the reply data for a PrintGetImageResolution request. +func (cook PrintGetImageResolutionCookie) Reply() (*PrintGetImageResolutionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1681,12 +1080,12 @@ func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { if buf == nil { return nil, nil } - return printInputSelectedReply(buf), nil + return printGetImageResolutionReply(buf), nil } -// printInputSelectedReply reads a byte slice into a PrintInputSelectedReply value. -func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { - v := new(PrintInputSelectedReply) +// 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 @@ -1697,32 +1096,15 @@ func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.EventMask = xgb.Get32(buf[b:]) - b += 4 - - v.EventList = make([]uint32, xgb.PopCount(int(v.EventMask))) - for i := 0; i < xgb.PopCount(int(v.EventMask)); i++ { - v.EventList[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - v.AllEventsMask = xgb.Get32(buf[b:]) - b += 4 - - v.AllEventsList = make([]uint32, xgb.PopCount(int(v.AllEventsMask))) - for i := 0; i < xgb.PopCount(int(v.AllEventsMask)); i++ { - v.AllEventsList[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.ImageResolution = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for PrintInputSelected -// printInputSelectedRequest writes a PrintInputSelected request to a byte slice. -func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { +// 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) @@ -1730,7 +1112,7 @@ func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 16 // request opcode + buf[b] = 24 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1742,106 +1124,6 @@ func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { return buf } -// PrintGetAttributesCookie is a cookie used only for PrintGetAttributes requests. -type PrintGetAttributesCookie 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. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetAttributes' 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 -} - -// Reply blocks and returns the reply data for a PrintGetAttributes request. -func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return printGetAttributesReply(buf), nil -} - -// printGetAttributesReply reads a byte slice into a PrintGetAttributesReply value. -func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { - v := new(PrintGetAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.StringLen = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attributes = String8(buf[b]) - b += 1 - - return v -} - -// Write request to wire for PrintGetAttributes -// printGetAttributesRequest writes a PrintGetAttributes request to a byte slice. -func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - b += 1 - - buf[b] = 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(Context)) - b += 4 - - buf[b] = Pool - b += 1 - - b += 3 // padding - - return buf -} - // PrintGetOneAttributesCookie is a cookie used only for PrintGetOneAttributes requests. type PrintGetOneAttributesCookie struct { *xgb.Cookie @@ -1955,78 +1237,6 @@ func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XPEXTENSION"] - 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 - - 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 { *xgb.Cookie @@ -2135,6 +1345,388 @@ func printGetPageDimensionsRequest(c *xgb.Conn, Context Pcontext) []byte { return buf } +// PrintGetPrinterListCookie is a cookie used only for PrintGetPrinterList requests. +type PrintGetPrinterListCookie struct { + *xgb.Cookie +} + +// 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} +} + +// PrintGetPrinterListUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetPrinterListUnchecked(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintGetPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{cookie} +} + +// 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) +} + +// 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 +} + +// printGetPrinterListReply reads a byte slice into a PrintGetPrinterListReply value. +func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { + v := new(PrintGetPrinterListReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ListCount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Printers = make([]Printer, v.ListCount) + b += PrinterReadList(buf[b:], v.Printers) + + return v +} + +// 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] = 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:], PrinterNameLen) + b += 4 + + xgb.Put32(buf[b:], LocaleLen) + b += 4 + + for i := 0; i < int(PrinterNameLen); i++ { + buf[b] = byte(PrinterName[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(LocaleLen); i++ { + buf[b] = byte(Locale[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// PrintGetScreenOfContextCookie is a cookie used only for PrintGetScreenOfContext requests. +type PrintGetScreenOfContextCookie struct { + *xgb.Cookie +} + +// PrintGetScreenOfContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetScreenOfContextCookie.Reply() +func PrintGetScreenOfContext(c *xgb.Conn) PrintGetScreenOfContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} +} + +// PrintGetScreenOfContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintGetScreenOfContextUnchecked(c *xgb.Conn) PrintGetScreenOfContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintGetScreenOfContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} +} + +// PrintGetScreenOfContextReply represents the data returned from a PrintGetScreenOfContext request. +type PrintGetScreenOfContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Root xproto.Window +} + +// Reply blocks and returns the reply data for a PrintGetScreenOfContext request. +func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetScreenOfContextReply(buf), nil +} + +// printGetScreenOfContextReply reads a byte slice into a PrintGetScreenOfContextReply value. +func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { + v := new(PrintGetScreenOfContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for PrintGetScreenOfContext +// printGetScreenOfContextRequest writes a PrintGetScreenOfContext request to a byte slice. +func printGetScreenOfContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// PrintInputSelectedCookie is a cookie used only for PrintInputSelected requests. +type PrintInputSelectedCookie struct { + *xgb.Cookie +} + +// PrintInputSelected sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintInputSelectedCookie.Reply() +func PrintInputSelected(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} +} + +// PrintInputSelectedUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintInputSelectedUnchecked(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintInputSelected' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} +} + +// PrintInputSelectedReply represents the data returned from a PrintInputSelected request. +type PrintInputSelectedReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + EventMask uint32 + EventList []uint32 + AllEventsMask uint32 + AllEventsList []uint32 +} + +// Reply blocks and returns the reply data for a PrintInputSelected request. +func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printInputSelectedReply(buf), nil +} + +// printInputSelectedReply reads a byte slice into a PrintInputSelectedReply value. +func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { + v := new(PrintInputSelectedReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.EventMask = xgb.Get32(buf[b:]) + b += 4 + + v.EventList = make([]uint32, xgb.PopCount(int(v.EventMask))) + for i := 0; i < xgb.PopCount(int(v.EventMask)); i++ { + v.EventList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.AllEventsMask = xgb.Get32(buf[b:]) + b += 4 + + v.AllEventsList = make([]uint32, xgb.PopCount(int(v.AllEventsMask))) + for i := 0; i < xgb.PopCount(int(v.AllEventsMask)); i++ { + v.AllEventsList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintInputSelected +// printInputSelectedRequest writes a PrintInputSelected request to a byte slice. +func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 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(Context)) + b += 4 + + return buf +} + +// PrintPutDocumentDataCookie is a cookie used only for PrintPutDocumentData requests. +type PrintPutDocumentDataCookie struct { + *xgb.Cookie +} + +// PrintPutDocumentData sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintPutDocumentData(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { + 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} +} + +// 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PrintPutDocumentDataCookie) Check() error { + return cook.Cookie.Check() +} + +// 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] = 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], LenData) + 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)) + + 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 +} + // PrintQueryScreensCookie is a cookie used only for PrintQueryScreens requests. type PrintQueryScreensCookie struct { *xgb.Cookie @@ -2231,6 +1823,337 @@ func printQueryScreensRequest(c *xgb.Conn) []byte { return buf } +// PrintQueryVersionCookie is a cookie used only for PrintQueryVersion requests. +type PrintQueryVersionCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// 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 +} + +// 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 +} + +// 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 + + 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 + + return v +} + +// Write request to wire for PrintQueryVersion +// printQueryVersionRequest writes a PrintQueryVersion request to a byte slice. +func printQueryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// PrintRehashPrinterListCookie is a cookie used only for PrintRehashPrinterList requests. +type PrintRehashPrinterListCookie struct { + *xgb.Cookie +} + +// PrintRehashPrinterList sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintRehashPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{cookie} +} + +// PrintRehashPrinterListChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintRehashPrinterListCookie.Check() +func PrintRehashPrinterListChecked(c *xgb.Conn) PrintRehashPrinterListCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintRehashPrinterList' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PrintRehashPrinterListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintRehashPrinterList +// printRehashPrinterListRequest writes a PrintRehashPrinterList request to a byte slice. +func printRehashPrinterListRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// PrintSelectInputCookie is a cookie used only for PrintSelectInput requests. +type PrintSelectInputCookie struct { + *xgb.Cookie +} + +// PrintSelectInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} +} + +// PrintSelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSelectInputCookie.Check() +func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PrintSelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSelectInput +// printSelectInputRequest writes a PrintSelectInput request to a byte slice. +func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + for i := 0; i < xgb.PopCount(int(EventMask)); i++ { + xgb.Put32(buf[b:], EventList[i]) + b += 4 + } + b = xgb.Pad(b) + + return 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)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], StringLen) + b += 4 + + buf[b] = Pool + b += 1 + + buf[b] = Rule + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Attributes)); i++ { + buf[b] = byte(Attributes[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// PrintSetContextCookie is a cookie used only for PrintSetContext requests. +type PrintSetContextCookie struct { + *xgb.Cookie +} + +// PrintSetContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func PrintSetContext(c *xgb.Conn, Context uint32) PrintSetContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{cookie} +} + +// PrintSetContextChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSetContextCookie.Check() +func PrintSetContextChecked(c *xgb.Conn, Context uint32) PrintSetContextCookie { + if _, ok := c.Extensions["XPEXTENSION"]; !ok { + panic("Cannot issue request 'PrintSetContext' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PrintSetContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSetContext +// printSetContextRequest writes a PrintSetContext request to a byte slice. +func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + // PrintSetImageResolutionCookie is a cookie used only for PrintSetImageResolution requests. type PrintSetImageResolutionCookie struct { *xgb.Cookie @@ -2327,75 +2250,42 @@ 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 { - if _, ok := c.Extensions["XPEXTENSION"]; !ok { - panic("Cannot issue request 'PrintGetImageResolution' 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} -} - -// PrintGetImageResolutionUnchecked sends an unchecked request. +// PrintStartDoc 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 { +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(false, true) - c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) - return PrintGetImageResolutionCookie{cookie} + cookie := c.NewCookie(false, 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 -} - -// 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 +// 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 'PrintStartDoc' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") } - if buf == nil { - return nil, nil - } - return printGetImageResolutionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(printStartDocRequest(c, DriverMode), cookie) + return PrintStartDocCookie{cookie} } -// 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 +// Check returns an error if one occurred 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() } -// Write request to wire for PrintGetImageResolution -// printGetImageResolutionRequest writes a PrintGetImageResolution request to a byte slice. -func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { +// 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) @@ -2403,13 +2293,123 @@ func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { buf[b] = c.Extensions["XPEXTENSION"] b += 1 - buf[b] = 24 // 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.Put32(buf[b:], uint32(Context)) + 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.") + } + 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.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(printStartJobRequest(c, OutputMode), cookie) + return PrintStartJobCookie{cookie} +} + +// Check returns an error if one occurred 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() +} + +// 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) + + buf[b] = c.Extensions["XPEXTENSION"] + 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 + + buf[b] = OutputMode + b += 1 + + return buf +} + +// 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) + + buf[b] = c.Extensions["XPEXTENSION"] + 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(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,373 +23,86 @@ 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' - -// 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' +func init() { + xgb.NewErrorFuncs[10] = AccessErrorNew +} const ( - VisualClassStaticGray = 0 - VisualClassGrayScale = 1 - VisualClassStaticColor = 2 - VisualClassPseudoColor = 3 - VisualClassTrueColor = 4 - VisualClassDirectColor = 5 + AccessControlDisable = 0 + AccessControlEnable = 1 ) -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 -) +// BadAlloc is the error number for a BadAlloc. +const BadAlloc = 11 -const ( - BackingStoreNotUseful = 0 - BackingStoreWhenMapped = 1 - BackingStoreAlways = 2 -) +type AllocError RequestError -const ( - ImageOrderLSBFirst = 0 - ImageOrderMSBFirst = 1 -) +// 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 +} -const ( - ModMaskShift = 1 - ModMaskLock = 2 - ModMaskControl = 4 - ModMask1 = 8 - ModMask2 = 16 - ModMask3 = 32 - ModMask4 = 64 - ModMask5 = 128 - ModMaskAny = 32768 -) +// SequenceId returns the sequence id attached to the BadAlloc error. +// This is mostly used internally. +func (err AllocError) SequenceId() uint16 { + return err.Sequence +} -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 -) +// 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 ( - WindowNone = 0 -) +// 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 ( - ButtonMask1 = 256 - ButtonMask2 = 512 - ButtonMask3 = 1024 - ButtonMask4 = 2048 - ButtonMask5 = 4096 - ButtonMaskAny = 32768 -) - -const ( - MotionNormal = 0 - MotionHint = 1 -) - -const ( - NotifyDetailAncestor = 0 - NotifyDetailVirtual = 1 - NotifyDetailInferior = 2 - NotifyDetailNonlinear = 3 - NotifyDetailNonlinearVirtual = 4 - NotifyDetailPointer = 5 - NotifyDetailPointerRoot = 6 - NotifyDetailNone = 7 -) - -const ( - NotifyModeNormal = 0 - NotifyModeGrab = 1 - NotifyModeUngrab = 2 - NotifyModeWhileGrabbed = 3 -) - -const ( - VisibilityUnobscured = 0 - VisibilityPartiallyObscured = 1 - VisibilityFullyObscured = 2 -) - -const ( - PlaceOnTop = 0 - PlaceOnBottom = 1 -) - -const ( - PropertyNewValue = 0 - PropertyDelete = 1 -) - -const ( - TimeCurrentTime = 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 - AtomCutBuffer5 = 14 - AtomCutBuffer6 = 15 - AtomCutBuffer7 = 16 - AtomDrawable = 17 - AtomFont = 18 - AtomInteger = 19 - AtomPixmap = 20 - AtomPoint = 21 - AtomRectangle = 22 - AtomResourceManager = 23 - AtomRgbColorMap = 24 - AtomRgbBestMap = 25 - AtomRgbBlueMap = 26 - AtomRgbDefaultMap = 27 - AtomRgbGrayMap = 28 - AtomRgbGreenMap = 29 - AtomRgbRedMap = 30 - AtomString = 31 - AtomVisualid = 32 - AtomWindow = 33 - AtomWmCommand = 34 - AtomWmHints = 35 - AtomWmClientMachine = 36 - AtomWmIconName = 37 - AtomWmIconSize = 38 - AtomWmName = 39 - AtomWmNormalHints = 40 - AtomWmSizeHints = 41 - AtomWmZoomHints = 42 - AtomMinSpace = 43 - AtomNormSpace = 44 - AtomMaxSpace = 45 - AtomEndSpace = 46 - AtomSuperscriptX = 47 - AtomSuperscriptY = 48 - AtomSubscriptX = 49 - AtomSubscriptY = 50 - AtomUnderlinePosition = 51 - AtomUnderlineThickness = 52 - AtomStrikeoutAscent = 53 - AtomStrikeoutDescent = 54 - AtomItalicAngle = 55 - AtomXHeight = 56 - AtomQuadWidth = 57 - AtomWeight = 58 - AtomPointSize = 59 - AtomResolution = 60 - AtomCopyright = 61 - AtomNotice = 62 - AtomFontName = 63 - AtomFamilyName = 64 - AtomFullName = 65 - AtomCapHeight = 66 - AtomWmClass = 67 - 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 -) - -const ( - MapStateUnmapped = 0 - MapStateUnviewable = 1 - MapStateViewable = 2 -) - -const ( - SetModeInsert = 0 - SetModeDelete = 1 -) - -const ( - ConfigWindowX = 1 - ConfigWindowY = 2 - ConfigWindowWidth = 4 - ConfigWindowHeight = 8 - ConfigWindowBorderWidth = 16 - ConfigWindowSibling = 32 - ConfigWindowStackMode = 64 -) - -const ( - StackModeAbove = 0 - StackModeBelow = 1 - StackModeTopIf = 2 - StackModeBottomIf = 3 - StackModeOpposite = 4 -) - -const ( - CirculateRaiseLowest = 0 - CirculateLowerHighest = 1 -) - -const ( - PropModeReplace = 0 - PropModePrepend = 1 - PropModeAppend = 2 -) - -const ( - GetPropertyTypeAny = 0 -) - -const ( - SendEventDestPointerWindow = 0 - SendEventDestItemFocus = 1 -) - -const ( - GrabModeSync = 0 - GrabModeAsync = 1 -) - -const ( - GrabStatusSuccess = 0 - GrabStatusAlreadyGrabbed = 1 - GrabStatusInvalidTime = 2 - GrabStatusNotViewable = 3 - GrabStatusFrozen = 4 -) - -const ( - CursorNone = 0 -) - -const ( - ButtonIndexAny = 0 - ButtonIndex1 = 1 - ButtonIndex2 = 2 - ButtonIndex3 = 3 - ButtonIndex4 = 4 - ButtonIndex5 = 5 -) - -const ( - GrabAny = 0 -) +func init() { + xgb.NewErrorFuncs[11] = AllocErrorNew +} const ( AllowAsyncPointer = 0 @@ -402,513 +115,6 @@ const ( AllowSyncBoth = 7 ) -const ( - InputFocusNone = 0 - InputFocusPointerRoot = 1 - InputFocusParent = 2 - InputFocusFollowKeyboard = 3 -) - -const ( - FontDrawLeftToRight = 0 - FontDrawRightToLeft = 1 -) - -const ( - GcFunction = 1 - GcPlaneMask = 2 - GcForeground = 4 - GcBackground = 8 - GcLineWidth = 16 - GcLineStyle = 32 - GcCapStyle = 64 - GcJoinStyle = 128 - GcFillStyle = 256 - GcFillRule = 512 - GcTile = 1024 - GcStipple = 2048 - GcTileStippleOriginX = 4096 - GcTileStippleOriginY = 8192 - GcFont = 16384 - GcSubwindowMode = 32768 - GcGraphicsExposures = 65536 - GcClipOriginX = 131072 - GcClipOriginY = 262144 - GcClipMask = 524288 - GcDashOffset = 1048576 - GcDashList = 2097152 - GcArcMode = 4194304 -) - -const ( - GxClear = 0 - GxAnd = 1 - GxAndReverse = 2 - GxCopy = 3 - GxAndInverted = 4 - GxNoop = 5 - GxXor = 6 - GxOr = 7 - GxNor = 8 - GxEquiv = 9 - GxInvert = 10 - GxOrReverse = 11 - GxCopyInverted = 12 - GxOrInverted = 13 - GxNand = 14 - GxSet = 15 -) - -const ( - LineStyleSolid = 0 - LineStyleOnOffDash = 1 - LineStyleDoubleDash = 2 -) - -const ( - CapStyleNotLast = 0 - CapStyleButt = 1 - CapStyleRound = 2 - CapStyleProjecting = 3 -) - -const ( - JoinStyleMiter = 0 - JoinStyleRound = 1 - JoinStyleBevel = 2 -) - -const ( - FillStyleSolid = 0 - FillStyleTiled = 1 - FillStyleStippled = 2 - FillStyleOpaqueStippled = 3 -) - -const ( - FillRuleEvenOdd = 0 - FillRuleWinding = 1 -) - -const ( - SubwindowModeClipByChildren = 0 - SubwindowModeIncludeInferiors = 1 -) - -const ( - ArcModeChord = 0 - ArcModePieSlice = 1 -) - -const ( - ClipOrderingUnsorted = 0 - ClipOrderingYSorted = 1 - ClipOrderingYXSorted = 2 - ClipOrderingYXBanded = 3 -) - -const ( - CoordModeOrigin = 0 - CoordModePrevious = 1 -) - -const ( - PolyShapeComplex = 0 - PolyShapeNonconvex = 1 - PolyShapeConvex = 2 -) - -const ( - ImageFormatXYBitmap = 0 - ImageFormatXYPixmap = 1 - ImageFormatZPixmap = 2 -) - -const ( - ColormapAllocNone = 0 - ColormapAllocAll = 1 -) - -const ( - ColorFlagRed = 1 - ColorFlagGreen = 2 - ColorFlagBlue = 4 -) - -const ( - PixmapNone = 0 -) - -const ( - FontNone = 0 -) - -const ( - QueryShapeOfLargestCursor = 0 - QueryShapeOfFastestTile = 1 - QueryShapeOfFastestStipple = 2 -) - -const ( - KbKeyClickPercent = 1 - KbBellPercent = 2 - KbBellPitch = 4 - KbBellDuration = 8 - KbLed = 16 - KbLedMode = 32 - KbKey = 64 - KbAutoRepeatMode = 128 -) - -const ( - LedModeOff = 0 - LedModeOn = 1 -) - -const ( - AutoRepeatModeOff = 0 - AutoRepeatModeOn = 1 - AutoRepeatModeDefault = 2 -) - -const ( - BlankingNotPreferred = 0 - BlankingPreferred = 1 - BlankingDefault = 2 -) - -const ( - ExposuresNotAllowed = 0 - ExposuresAllowed = 1 - ExposuresDefault = 2 -) - -const ( - HostModeInsert = 0 - HostModeDelete = 1 -) - -const ( - FamilyInternet = 0 - FamilyDECnet = 1 - FamilyChaos = 2 - FamilyServerInterpreted = 5 - FamilyInternet6 = 6 -) - -const ( - AccessControlDisable = 0 - AccessControlEnable = 1 -) - -const ( - CloseDownDestroyAll = 0 - CloseDownRetainPermanent = 1 - CloseDownRetainTemporary = 2 -) - -const ( - KillAllTemporary = 0 -) - -const ( - ScreenSaverReset = 0 - ScreenSaverActive = 1 -) - -const ( - MappingStatusSuccess = 0 - MappingStatusBusy = 1 - MappingStatusFailure = 2 -) - -const ( - MapIndexShift = 0 - MapIndexLock = 1 - MapIndexControl = 2 - MapIndex1 = 3 - MapIndex2 = 4 - MapIndex3 = 5 - MapIndex4 = 6 - MapIndex5 = 7 -) - -type Window uint32 - -func NewWindowId(c *xgb.Conn) (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} - -type Pixmap uint32 - -func NewPixmapId(c *xgb.Conn) (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} - -type Cursor uint32 - -func NewCursorId(c *xgb.Conn) (Cursor, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Cursor(id), nil -} - -type Font uint32 - -func NewFontId(c *xgb.Conn) (Font, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Font(id), nil -} - -type Gcontext uint32 - -func NewGcontextId(c *xgb.Conn) (Gcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Gcontext(id), nil -} - -type Colormap uint32 - -func NewColormapId(c *xgb.Conn) (Colormap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Colormap(id), nil -} - -type Atom uint32 - -func NewAtomId(c *xgb.Conn) (Atom, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Atom(id), nil -} - -type Drawable uint32 - -func NewDrawableId(c *xgb.Conn) (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil -} - -type Fontable uint32 - -func NewFontableId(c *xgb.Conn) (Fontable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fontable(id), nil -} - -type Visualid uint32 - -type Timestamp uint32 - -type Keysym uint32 - -type Keycode byte - -type Button byte - -type Char2b struct { - Byte1 byte - Byte2 byte -} - -// Char2bRead reads a byte slice into a Char2b value. -func Char2bRead(buf []byte, v *Char2b) int { - b := 0 - - v.Byte1 = buf[b] - b += 1 - - v.Byte2 = buf[b] - b += 1 - - return b -} - -// Char2bReadList reads a byte slice into a list of Char2b values. -func Char2bReadList(buf []byte, dest []Char2b) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Char2b{} - b += Char2bRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Char2b value to a byte slice. -func (v Char2b) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.Byte1 - b += 1 - - buf[b] = v.Byte2 - b += 1 - - return buf -} - -// Char2bListBytes writes a list of Char2b values to a byte slice. -func Char2bListBytes(buf []byte, list []Char2b) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Point struct { - X int16 - Y int16 -} - -// PointRead reads a byte slice into a Point value. -func PointRead(buf []byte, v *Point) int { - b := 0 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - return b -} - -// PointReadList reads a byte slice into a list of Point values. -func PointReadList(buf []byte, dest []Point) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Point{} - b += PointRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Point value to a byte slice. -func (v Point) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// PointListBytes writes a list of Point values to a byte slice. -func PointListBytes(buf []byte, list []Point) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Rectangle struct { - X int16 - Y int16 - Width uint16 - Height uint16 -} - -// RectangleRead reads a byte slice into a Rectangle value. -func RectangleRead(buf []byte, v *Rectangle) int { - b := 0 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - return b -} - -// RectangleReadList reads a byte slice into a list of Rectangle values. -func RectangleReadList(buf []byte, dest []Rectangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rectangle{} - b += RectangleRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Rectangle value to a byte slice. -func (v Rectangle) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -// RectangleListBytes writes a list of Rectangle values to a byte slice. -func RectangleListBytes(buf []byte, list []Rectangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - type Arc struct { X int16 Y int16 @@ -991,1023 +197,420 @@ func ArcListBytes(buf []byte, list []Arc) int { return b } -type Format struct { - Depth byte - BitsPerPixel byte - ScanlinePad byte - // padding: 5 bytes -} +const ( + ArcModeChord = 0 + ArcModePieSlice = 1 +) -// FormatRead reads a byte slice into a Format value. -func FormatRead(buf []byte, v *Format) int { - b := 0 +type Atom uint32 - v.Depth = buf[b] - b += 1 - - v.BitsPerPixel = buf[b] - b += 1 - - v.ScanlinePad = buf[b] - b += 1 - - b += 5 // padding - - return b -} - -// FormatReadList reads a byte slice into a list of Format values. -func FormatReadList(buf []byte, dest []Format) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Format{} - b += FormatRead(buf[b:], &dest[i]) +func NewAtomId(c *xgb.Conn) (Atom, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return xgb.Pad(b) + return Atom(id), nil } -// Bytes writes a Format value to a byte slice. -func (v Format) Bytes() []byte { - buf := make([]byte, 8) - 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 + AtomCutBuffer5 = 14 + AtomCutBuffer6 = 15 + AtomCutBuffer7 = 16 + AtomDrawable = 17 + AtomFont = 18 + AtomInteger = 19 + AtomPixmap = 20 + AtomPoint = 21 + AtomRectangle = 22 + AtomResourceManager = 23 + AtomRgbColorMap = 24 + AtomRgbBestMap = 25 + AtomRgbBlueMap = 26 + AtomRgbDefaultMap = 27 + AtomRgbGrayMap = 28 + AtomRgbGreenMap = 29 + AtomRgbRedMap = 30 + AtomString = 31 + AtomVisualid = 32 + AtomWindow = 33 + AtomWmCommand = 34 + AtomWmHints = 35 + AtomWmClientMachine = 36 + AtomWmIconName = 37 + AtomWmIconSize = 38 + AtomWmName = 39 + AtomWmNormalHints = 40 + AtomWmSizeHints = 41 + AtomWmZoomHints = 42 + AtomMinSpace = 43 + AtomNormSpace = 44 + AtomMaxSpace = 45 + AtomEndSpace = 46 + AtomSuperscriptX = 47 + AtomSuperscriptY = 48 + AtomSubscriptX = 49 + AtomSubscriptY = 50 + AtomUnderlinePosition = 51 + AtomUnderlineThickness = 52 + AtomStrikeoutAscent = 53 + AtomStrikeoutDescent = 54 + AtomItalicAngle = 55 + AtomXHeight = 56 + AtomQuadWidth = 57 + AtomWeight = 58 + AtomPointSize = 59 + AtomResolution = 60 + AtomCopyright = 61 + AtomNotice = 62 + AtomFontName = 63 + AtomFamilyName = 64 + AtomFullName = 65 + AtomCapHeight = 66 + AtomWmClass = 67 + AtomWmTransientFor = 68 +) - buf[b] = v.Depth - b += 1 +// BadAtom is the error number for a BadAtom. +const BadAtom = 5 - buf[b] = v.BitsPerPixel - b += 1 +type AtomError ValueError - buf[b] = v.ScanlinePad - b += 1 - - b += 5 // padding - - return buf +// 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 } -// 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 +// SequenceId returns the sequence id attached to the BadAtom error. +// This is mostly used internally. +func (err AtomError) SequenceId() uint16 { + return err.Sequence } -type VisualInfo struct { - VisualId Visualid - Class byte - BitsPerRgbValue byte - ColormapEntries uint16 - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 4 bytes +// 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 } -// VisualInfoRead reads a byte slice into a VisualInfo value. -func VisualInfoRead(buf []byte, v *VisualInfo) int { - b := 0 - - v.VisualId = Visualid(xgb.Get32(buf[b:])) - b += 4 - - v.Class = buf[b] - b += 1 - - v.BitsPerRgbValue = buf[b] - b += 1 - - v.ColormapEntries = xgb.Get16(buf[b:]) - b += 2 - - v.RedMask = xgb.Get32(buf[b:]) - b += 4 - - v.GreenMask = xgb.Get32(buf[b:]) - b += 4 - - v.BlueMask = xgb.Get32(buf[b:]) - b += 4 - - b += 4 // padding - - return b +// 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, ", ") + "}" } -// 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 init() { + xgb.NewErrorFuncs[5] = AtomErrorNew } -// Bytes writes a VisualInfo value to a byte slice. -func (v VisualInfo) Bytes() []byte { - buf := make([]byte, 24) - b := 0 +const ( + AutoRepeatModeOff = 0 + AutoRepeatModeOn = 1 + AutoRepeatModeDefault = 2 +) - xgb.Put32(buf[b:], uint32(v.VisualId)) - b += 4 +const ( + BackPixmapNone = 0 + BackPixmapParentRelative = 1 +) - buf[b] = v.Class - b += 1 +const ( + BackingStoreNotUseful = 0 + BackingStoreWhenMapped = 1 + BackingStoreAlways = 2 +) - buf[b] = v.BitsPerRgbValue - b += 1 +const ( + BlankingNotPreferred = 0 + BlankingPreferred = 1 + BlankingDefault = 2 +) - xgb.Put16(buf[b:], v.ColormapEntries) - b += 2 +type Button byte - xgb.Put32(buf[b:], v.RedMask) - b += 4 +const ( + ButtonIndexAny = 0 + ButtonIndex1 = 1 + ButtonIndex2 = 2 + ButtonIndex3 = 3 + ButtonIndex4 = 4 + ButtonIndex5 = 5 +) - xgb.Put32(buf[b:], v.GreenMask) - b += 4 +const ( + ButtonMask1 = 256 + ButtonMask2 = 512 + ButtonMask3 = 1024 + ButtonMask4 = 2048 + ButtonMask5 = 4096 + ButtonMaskAny = 32768 +) - xgb.Put32(buf[b:], v.BlueMask) - b += 4 +// ButtonPress is the event number for a ButtonPressEvent. +const ButtonPress = 4 - b += 4 // padding - - return buf -} - -// VisualInfoListBytes writes a list of VisualInfo values to a byte slice. -func VisualInfoListBytes(buf []byte, list []VisualInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type DepthInfo struct { - Depth byte +type ButtonPressEvent struct { + Sequence uint16 + Detail Button + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool // padding: 1 bytes - VisualsLen uint16 - // padding: 4 bytes - Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) } -// DepthInfoRead reads a byte slice into a DepthInfo value. -func DepthInfoRead(buf []byte, v *DepthInfo) int { - b := 0 +// 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 - v.Depth = buf[b] + v.Detail = Button(buf[b]) b += 1 - b += 1 // padding - - v.VisualsLen = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - b += 4 // padding - - v.Visuals = make([]VisualInfo, v.VisualsLen) - b += VisualInfoReadList(buf[b:], v.Visuals) - - return b -} - -// DepthInfoReadList reads a byte slice into a list of DepthInfo values. -func DepthInfoReadList(buf []byte, dest []DepthInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DepthInfo{} - b += DepthInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a DepthInfo value to a byte slice. -func (v DepthInfo) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) - b := 0 - - buf[b] = v.Depth - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], v.VisualsLen) - b += 2 - - b += 4 // padding - - b += VisualInfoListBytes(buf[b:], v.Visuals) - - return buf -} - -// DepthInfoListBytes writes a list of DepthInfo values to a byte slice. -func DepthInfoListBytes(buf []byte, list []DepthInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. -func DepthInfoListSize(list []DepthInfo) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) - } - return size -} - -type ScreenInfo struct { - Root Window - DefaultColormap Colormap - WhitePixel uint32 - BlackPixel uint32 - CurrentInputMasks uint32 - WidthInPixels uint16 - HeightInPixels uint16 - WidthInMillimeters uint16 - HeightInMillimeters uint16 - MinInstalledMaps uint16 - MaxInstalledMaps uint16 - RootVisual Visualid - BackingStores byte - SaveUnders bool - RootDepth byte - AllowedDepthsLen byte - AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) -} - -// ScreenInfoRead reads a byte slice into a ScreenInfo value. -func ScreenInfoRead(buf []byte, v *ScreenInfo) int { - b := 0 + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 v.Root = Window(xgb.Get32(buf[b:])) b += 4 - v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.WhitePixel = xgb.Get32(buf[b:]) + v.Child = Window(xgb.Get32(buf[b:])) b += 4 - v.BlackPixel = xgb.Get32(buf[b:]) - b += 4 - - v.CurrentInputMasks = xgb.Get32(buf[b:]) - b += 4 - - v.WidthInPixels = xgb.Get16(buf[b:]) + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - v.HeightInPixels = xgb.Get16(buf[b:]) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.WidthInMillimeters = xgb.Get16(buf[b:]) + v.EventX = int16(xgb.Get16(buf[b:])) b += 2 - v.HeightInMillimeters = xgb.Get16(buf[b:]) + v.EventY = int16(xgb.Get16(buf[b:])) b += 2 - v.MinInstalledMaps = xgb.Get16(buf[b:]) + v.State = xgb.Get16(buf[b:]) b += 2 - v.MaxInstalledMaps = xgb.Get16(buf[b:]) - b += 2 - - v.RootVisual = Visualid(xgb.Get32(buf[b:])) - b += 4 - - v.BackingStores = buf[b] - b += 1 - if buf[b] == 1 { - v.SaveUnders = true + v.SameScreen = true } else { - v.SaveUnders = false + v.SameScreen = false } b += 1 - v.RootDepth = buf[b] - b += 1 + b += 1 // padding - 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 ButtonPressEvent value to a byte slice. +func (v ButtonPressEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ScreenInfo{} - b += ScreenInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} -// Bytes writes a ScreenInfo value to a byte slice. -func (v ScreenInfo) Bytes() []byte { - buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) - b := 0 + // write event number + buf[b] = 4 + b += 1 + + 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.DefaultColormap)) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put32(buf[b:], v.WhitePixel) + xgb.Put32(buf[b:], uint32(v.Child)) b += 4 - xgb.Put32(buf[b:], v.BlackPixel) - b += 4 - - xgb.Put32(buf[b:], v.CurrentInputMasks) - b += 4 - - xgb.Put16(buf[b:], v.WidthInPixels) + xgb.Put16(buf[b:], uint16(v.RootX)) b += 2 - xgb.Put16(buf[b:], v.HeightInPixels) + xgb.Put16(buf[b:], uint16(v.RootY)) b += 2 - xgb.Put16(buf[b:], v.WidthInMillimeters) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], v.HeightInMillimeters) + xgb.Put16(buf[b:], uint16(v.EventY)) b += 2 - xgb.Put16(buf[b:], v.MinInstalledMaps) + xgb.Put16(buf[b:], v.State) 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 { + if v.SameScreen { buf[b] = 1 } else { buf[b] = 0 } b += 1 - buf[b] = v.RootDepth - b += 1 - - buf[b] = v.AllowedDepthsLen - b += 1 - - b += DepthInfoListBytes(buf[b:], v.AllowedDepths) - - return buf -} - -// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. -func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// ScreenInfoListSize computes the size (bytes) of a list of ScreenInfo values. -func ScreenInfoListSize(list []ScreenInfo) int { - size := 0 - for _, item := range list { - size += (40 + DepthInfoListSize(item.AllowedDepths)) - } - return size -} - -type SetupRequest struct { - ByteOrder byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - AuthorizationProtocolNameLen uint16 - AuthorizationProtocolDataLen uint16 - // padding: 2 bytes - AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) - AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) -} - -// SetupRequestRead reads a byte slice into a SetupRequest value. -func SetupRequestRead(buf []byte, v *SetupRequest) int { - b := 0 - - v.ByteOrder = buf[b] - b += 1 - b += 1 // padding - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 + return buf +} - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 +// 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 +} - v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) - b += 2 +// 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, ", ") + "}" +} - v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) - b += 2 +func init() { + xgb.NewEventFuncs[4] = ButtonPressEventNew +} - b += 2 // padding +// ButtonRelease is the event number for a ButtonReleaseEvent. +const ButtonRelease = 5 - { - byteString := make([]byte, v.AuthorizationProtocolNameLen) - copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) - v.AuthorizationProtocolName = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - } +type ButtonReleaseEvent ButtonPressEvent - { - byteString := make([]byte, v.AuthorizationProtocolDataLen) - copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) - v.AuthorizationProtocolData = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) - } +// 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 ( + 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 } -// SetupRequestReadList reads a byte slice into a list of SetupRequest values. -func SetupRequestReadList(buf []byte, dest []SetupRequest) int { +// Char2bReadList reads a byte slice into a list of Char2b values. +func Char2bReadList(buf []byte, dest []Char2b) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = SetupRequest{} - b += SetupRequestRead(buf[b:], &dest[i]) + dest[i] = Char2b{} + b += Char2bRead(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)))) +// Bytes writes a Char2b value to a byte slice. +func (v Char2b) Bytes() []byte { + buf := make([]byte, 2) b := 0 - buf[b] = v.ByteOrder + buf[b] = v.Byte1 b += 1 - b += 1 // padding - - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) - b += 2 - - xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - - copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + buf[b] = v.Byte2 + b += 1 return buf } -// SetupRequestListBytes writes a list of SetupRequest values to a byte slice. -func SetupRequestListBytes(buf []byte, list []SetupRequest) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. -func SetupRequestListSize(list []SetupRequest) int { - size := 0 - for _, item := range list { - size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) - } - return size -} - -type SetupFailed struct { - Status byte - ReasonLen byte - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - Reason string // size: xgb.Pad((int(ReasonLen) * 1)) -} - -// SetupFailedRead reads a byte slice into a SetupFailed value. -func SetupFailedRead(buf []byte, v *SetupFailed) int { - b := 0 - - v.Status = buf[b] - b += 1 - - v.ReasonLen = buf[b] - b += 1 - - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.ReasonLen) - copy(byteString[:v.ReasonLen], buf[b:]) - v.Reason = string(byteString) - b += xgb.Pad(int(v.ReasonLen)) - } - - return b -} - -// SetupFailedReadList reads a byte slice into a list of SetupFailed values. -func SetupFailedReadList(buf []byte, dest []SetupFailed) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupFailed{} - b += SetupFailedRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a SetupFailed value to a byte slice. -func (v SetupFailed) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - buf[b] = v.ReasonLen - b += 1 - - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - xgb.Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:v.ReasonLen]) - b += xgb.Pad(int(v.ReasonLen)) - - return buf -} - -// 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 -} - -// 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 SetupAuthenticate struct { - Status byte - // padding: 5 bytes - Length uint16 - Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) -} - -// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. -func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { - b := 0 - - v.Status = buf[b] - b += 1 - - b += 5 // padding - - v.Length = xgb.Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, (int(v.Length) * 4)) - copy(byteString[:(int(v.Length)*4)], buf[b:]) - v.Reason = string(byteString) - b += xgb.Pad(int((int(v.Length) * 4))) - } - - return b -} - -// 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) -} - -// Bytes writes a SetupAuthenticate value to a byte slice. -func (v SetupAuthenticate) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - b += 5 // padding - - xgb.Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:(int(v.Length)*4)]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return buf -} - -// 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 -} - -// SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. -func SetupAuthenticateListSize(list []SetupAuthenticate) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) - } - return size -} - -type 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) -} - -// SetupInfoRead reads a byte slice into a SetupInfo value. -func SetupInfoRead(buf []byte, v *SetupInfo) int { - b := 0 - - v.Status = buf[b] - b += 1 - - b += 1 // padding - - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get16(buf[b:]) - b += 2 - - v.ReleaseNumber = xgb.Get32(buf[b:]) - b += 4 - - v.ResourceIdBase = xgb.Get32(buf[b:]) - b += 4 - - v.ResourceIdMask = xgb.Get32(buf[b:]) - b += 4 - - v.MotionBufferSize = xgb.Get32(buf[b:]) - b += 4 - - v.VendorLen = xgb.Get16(buf[b:]) - b += 2 - - v.MaximumRequestLength = xgb.Get16(buf[b:]) - b += 2 - - v.RootsLen = buf[b] - b += 1 - - v.PixmapFormatsLen = buf[b] - b += 1 - - v.ImageByteOrder = buf[b] - b += 1 - - v.BitmapFormatBitOrder = buf[b] - b += 1 - - v.BitmapFormatScanlineUnit = buf[b] - b += 1 - - v.BitmapFormatScanlinePad = buf[b] - b += 1 - - v.MinKeycode = Keycode(buf[b]) - b += 1 - - v.MaxKeycode = Keycode(buf[b]) - b += 1 - - b += 4 // padding - - { - byteString := make([]byte, v.VendorLen) - copy(byteString[:v.VendorLen], buf[b:]) - v.Vendor = string(byteString) - b += xgb.Pad(int(v.VendorLen)) - } - - v.PixmapFormats = make([]Format, v.PixmapFormatsLen) - b += FormatReadList(buf[b:], v.PixmapFormats) - - v.Roots = make([]ScreenInfo, v.RootsLen) - b += ScreenInfoReadList(buf[b:], v.Roots) - - return b -} - -// SetupInfoReadList reads a byte slice into a list of SetupInfo values. -func SetupInfoReadList(buf []byte, dest []SetupInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupInfo{} - b += SetupInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a SetupInfo value to a byte slice. -func (v SetupInfo) Bytes() []byte { - buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) - b := 0 - - buf[b] = v.Status - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - xgb.Put16(buf[b:], v.Length) - b += 2 - - xgb.Put32(buf[b:], v.ReleaseNumber) - b += 4 - - xgb.Put32(buf[b:], v.ResourceIdBase) - b += 4 - - xgb.Put32(buf[b:], v.ResourceIdMask) - b += 4 - - xgb.Put32(buf[b:], v.MotionBufferSize) - b += 4 - - xgb.Put16(buf[b:], v.VendorLen) - b += 2 - - xgb.Put16(buf[b:], v.MaximumRequestLength) - b += 2 - - buf[b] = v.RootsLen - b += 1 - - buf[b] = v.PixmapFormatsLen - b += 1 - - buf[b] = v.ImageByteOrder - b += 1 - - buf[b] = v.BitmapFormatBitOrder - b += 1 - - buf[b] = v.BitmapFormatScanlineUnit - b += 1 - - buf[b] = v.BitmapFormatScanlinePad - b += 1 - - buf[b] = byte(v.MinKeycode) - b += 1 - - buf[b] = byte(v.MaxKeycode) - b += 1 - - b += 4 // padding - - copy(buf[b:], v.Vendor[:v.VendorLen]) - b += xgb.Pad(int(v.VendorLen)) - - b += FormatListBytes(buf[b:], v.PixmapFormats) - - b += ScreenInfoListBytes(buf[b:], v.Roots) - - return buf -} - -// SetupInfoListBytes writes a list of SetupInfo values to a byte slice. -func SetupInfoListBytes(buf []byte, list []SetupInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. -func SetupInfoListSize(list []SetupInfo) int { - size := 0 - for _, item := range list { - size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) - } - return size -} - -type Timecoord struct { - Time Timestamp - X int16 - Y int16 -} - -// TimecoordRead reads a byte slice into a Timecoord value. -func TimecoordRead(buf []byte, v *Timecoord) int { - b := 0 - - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - return b -} - -// TimecoordReadList reads a byte slice into a list of Timecoord values. -func TimecoordReadList(buf []byte, dest []Timecoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Timecoord{} - b += TimecoordRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Timecoord value to a byte slice. -func (v Timecoord) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// TimecoordListBytes writes a list of Timecoord values to a byte slice. -func TimecoordListBytes(buf []byte, list []Timecoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Fontprop struct { - Name Atom - Value uint32 -} - -// FontpropRead reads a byte slice into a Fontprop value. -func FontpropRead(buf []byte, v *Fontprop) int { - b := 0 - - v.Name = Atom(xgb.Get32(buf[b:])) - b += 4 - - v.Value = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// FontpropReadList reads a byte slice into a list of Fontprop values. -func FontpropReadList(buf []byte, dest []Fontprop) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Fontprop{} - b += FontpropRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Fontprop value to a byte slice. -func (v Fontprop) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Name)) - b += 4 - - xgb.Put32(buf[b:], v.Value) - b += 4 - - return buf -} - -// FontpropListBytes writes a list of Fontprop values to a byte slice. -func FontpropListBytes(buf []byte, list []Fontprop) int { +// Char2bListBytes writes a list of Char2b values to a byte slice. +func Char2bListBytes(buf []byte, list []Char2b) int { b := 0 var structBytes []byte for _, item := range list { @@ -2100,361 +703,217 @@ func CharinfoListBytes(buf []byte, list []Charinfo) int { return b } -type Str struct { - NameLen byte - Name string // size: xgb.Pad((int(NameLen) * 1)) +const ( + CirculateRaiseLowest = 0 + CirculateLowerHighest = 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 } -// StrRead reads a byte slice into a Str value. -func StrRead(buf []byte, v *Str) int { +// 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 + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + b += 4 // padding + + v.Place = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a CirculateNotifyEvent value to a byte slice. +func (v CirculateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.NameLen = buf[b] + // write event number + buf[b] = 26 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 + + b += 4 // padding + + buf[b] = v.Place + b += 1 + + b += 3 // padding + + 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[26] = CirculateNotifyEventNew +} + +// CirculateRequest is the event number for a CirculateRequestEvent. +const CirculateRequest = 27 + +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)) +} + +// Bytes writes a CirculateRequestEvent value to a byte slice. +func (v CirculateRequestEvent) Bytes() []byte { + return CirculateNotifyEvent(v).Bytes() +} + +// 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 +} + +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 init() { + xgb.NewEventFuncs[27] = CirculateRequestEventNew +} + +// ClientMessage is the event number for a ClientMessageEvent. +const ClientMessage = 33 + +type ClientMessageEvent struct { + Sequence uint16 + Format byte + Window Window + Type Atom + Data ClientMessageDataUnion +} + +// ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. +func ClientMessageEventNew(buf []byte) xgb.Event { + v := ClientMessageEvent{} + b := 1 // don't read event number + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Type = Atom(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 + + buf[b] = v.Format + 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 + { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) + unionBytes := v.Data.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) } - return b -} - -// StrReadList reads a byte slice into a list of Str values. -func StrReadList(buf []byte, dest []Str) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Str{} - b += StrRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Str value to a byte slice. -func (v Str) Bytes() []byte { - buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) - b := 0 - - buf[b] = v.NameLen - b += 1 - - copy(buf[b:], v.Name[:v.NameLen]) - b += xgb.Pad(int(v.NameLen)) - return buf } -// StrListBytes writes a list of Str values to a byte slice. -func StrListBytes(buf []byte, list []Str) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// 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 } -// 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 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, ", ") + "}" } -type Segment struct { - X1 int16 - Y1 int16 - X2 int16 - Y2 int16 -} - -// SegmentRead reads a byte slice into a Segment value. -func SegmentRead(buf []byte, v *Segment) int { - b := 0 - - v.X1 = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y1 = int16(xgb.Get16(buf[b:])) - b += 2 - - v.X2 = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y2 = int16(xgb.Get16(buf[b:])) - b += 2 - - return b -} - -// 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) -} - -// Bytes writes a Segment value to a byte slice. -func (v Segment) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put16(buf[b:], uint16(v.X1)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y1)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.X2)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y2)) - b += 2 - - return buf -} - -// SegmentListBytes writes a list of Segment values to a byte slice. -func SegmentListBytes(buf []byte, list []Segment) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Coloritem struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Flags byte - // padding: 1 bytes -} - -// ColoritemRead reads a byte slice into a Coloritem value. -func ColoritemRead(buf []byte, v *Coloritem) int { - b := 0 - - v.Pixel = xgb.Get32(buf[b:]) - b += 4 - - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 - - v.Blue = xgb.Get16(buf[b:]) - b += 2 - - v.Flags = buf[b] - b += 1 - - b += 1 // padding - - return b -} - -// ColoritemReadList reads a byte slice into a list of Coloritem values. -func ColoritemReadList(buf []byte, dest []Coloritem) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Coloritem{} - b += ColoritemRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Coloritem value to a byte slice. -func (v Coloritem) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - xgb.Put32(buf[b:], v.Pixel) - b += 4 - - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 - - xgb.Put16(buf[b:], v.Blue) - b += 2 - - buf[b] = v.Flags - b += 1 - - b += 1 // padding - - return buf -} - -// ColoritemListBytes writes a list of Coloritem values to a byte slice. -func ColoritemListBytes(buf []byte, list []Coloritem) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Rgb struct { - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes -} - -// RgbRead reads a byte slice into a Rgb value. -func RgbRead(buf []byte, v *Rgb) int { - b := 0 - - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 - - v.Blue = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return b -} - -// RgbReadList reads a byte slice into a list of Rgb values. -func RgbReadList(buf []byte, dest []Rgb) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rgb{} - b += RgbRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Rgb value to a byte slice. -func (v Rgb) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 - - xgb.Put16(buf[b:], v.Blue) - b += 2 - - b += 2 // padding - - return buf -} - -// 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 -} - -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 - - 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 - - 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 +func init() { + xgb.NewEventFuncs[33] = ClientMessageEventNew } // ClientMessageDataUnion is a represention of the ClientMessageDataUnion union type. @@ -2649,121 +1108,86 @@ func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) return b } -// KeyPress is the event number for a KeyPressEvent. -const KeyPress = 2 +const ( + ClipOrderingUnsorted = 0 + ClipOrderingYSorted = 1 + ClipOrderingYXSorted = 2 + ClipOrderingYXBanded = 3 +) -type KeyPressEvent struct { - Sequence uint16 - Detail Keycode - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool +const ( + CloseDownDestroyAll = 0 + CloseDownRetainPermanent = 1 + CloseDownRetainTemporary = 2 +) + +const ( + ColorFlagRed = 1 + ColorFlagGreen = 2 + ColorFlagBlue = 4 +) + +type Coloritem struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Flags byte // padding: 1 bytes } -// KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. -func KeyPressEventNew(buf []byte) xgb.Event { - v := KeyPressEvent{} - b := 1 // don't read event number +// ColoritemRead reads a byte slice into a Coloritem value. +func ColoritemRead(buf []byte, v *Coloritem) int { + b := 0 - v.Detail = Keycode(buf[b]) - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(xgb.Get32(buf[b:])) + v.Pixel = 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:])) + v.Red = xgb.Get16(buf[b:]) b += 2 - v.RootY = int16(xgb.Get16(buf[b:])) + v.Green = xgb.Get16(buf[b:]) b += 2 - v.EventX = int16(xgb.Get16(buf[b:])) + v.Blue = 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 - } + v.Flags = buf[b] b += 1 b += 1 // padding - return v + return b } -// Bytes writes a KeyPressEvent value to a byte slice. -func (v KeyPressEvent) Bytes() []byte { - buf := make([]byte, 32) +// ColoritemReadList reads a byte slice into a list of Coloritem values. +func ColoritemReadList(buf []byte, dest []Coloritem) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Coloritem{} + b += ColoritemRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Coloritem value to a byte slice. +func (v Coloritem) Bytes() []byte { + buf := make([]byte, 12) b := 0 - // write event number - buf[b] = 2 - b += 1 - - buf[b] = byte(v.Detail) - b += 1 - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) + xgb.Put32(buf[b:], v.Pixel) 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)) + xgb.Put16(buf[b:], v.Red) b += 2 - xgb.Put16(buf[b:], uint16(v.RootY)) + xgb.Put16(buf[b:], v.Green) b += 2 - xgb.Put16(buf[b:], uint16(v.EventX)) + xgb.Put16(buf[b:], v.Blue) 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 - } + buf[b] = v.Flags b += 1 b += 1 // padding @@ -2771,631 +1195,91 @@ func (v KeyPressEvent) Bytes() []byte { return buf } -// 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 KeyPressEvent) SequenceId() uint16 { - return v.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, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[2] = KeyPressEventNew -} - -// ButtonPress is the event number for a ButtonPressEvent. -const ButtonPress = 4 - -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 -} - -// 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 - - v.Detail = Button(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 +// ColoritemListBytes writes a list of Coloritem values to a byte slice. +func ColoritemListBytes(buf []byte, list []Coloritem) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } - b += 1 + return b +} - b += 1 // padding +type Colormap uint32 +func NewColormapId(c *xgb.Conn) (Colormap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Colormap(id), nil +} + +// BadColormap is the error number for a BadColormap. +const BadColormap = 12 + +type ColormapError ValueError + +// ColormapErrorNew constructs a ColormapError value that implements xgb.Error from a byte slice. +func ColormapErrorNew(buf []byte) xgb.Error { + v := ColormapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Colormap" return v } -// 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. +// SequenceId returns the sequence id attached to the BadColormap error. // This is mostly used internally. -func (v ButtonPressEvent) SequenceId() uint16 { - return v.Sequence +func (err ColormapError) SequenceId() uint16 { + return err.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, ", ") + "}" +// 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 } -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 -} - -// 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 - - b += 1 // padding - - return v -} - -// 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 -} - -// 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 MotionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of MotionNotifyEvent. -func (v MotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("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[6] = MotionNotifyEventNew -} - -// EnterNotify is the event number for a EnterNotifyEvent. -const EnterNotify = 7 - -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 -} - -// 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 - - 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 - - return v -} - -// Bytes writes a EnterNotifyEvent value to a byte slice. -func (v EnterNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 7 - 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 - - buf[b] = v.Mode - b += 1 - - buf[b] = v.SameScreenFocus - b += 1 - - return buf -} - -// 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 -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[7] = EnterNotifyEventNew -} - -// FocusIn is the event number for a FocusInEvent. -const FocusIn = 9 - -type FocusInEvent struct { - Sequence uint16 - Detail byte - Event Window - Mode byte - // padding: 3 bytes -} - -// 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.Detail = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Mode = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Bytes writes a FocusInEvent value to a byte slice. -func (v FocusInEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 9 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - - buf[b] = v.Mode - b += 1 - - b += 3 // padding - - 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 -} - -// String is a rudimentary string representation of FocusInEvent. -func (v FocusInEvent) String() string { +// Error returns a rudimentary string representation of the BadColormap error. +func (err ColormapError) Error() 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, ", ") + "}" + 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.NewEventFuncs[9] = FocusInEventNew + xgb.NewErrorFuncs[12] = ColormapErrorNew } -// KeymapNotify is the event number for a KeymapNotifyEvent. -const KeymapNotify = 11 +const ( + ColormapNone = 0 +) -type KeymapNotifyEvent struct { - Keys []byte // size: 32 -} +const ( + ColormapAllocNone = 0 + ColormapAllocAll = 1 +) -// 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 +// ColormapNotify is the event number for a ColormapNotifyEvent. +const ColormapNotify = 32 - v.Keys = make([]byte, 31) - copy(v.Keys[:31], buf[b:]) - b += xgb.Pad(int(31)) - - return v -} - -// 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] = 11 - b += 1 - - copy(buf[b:], v.Keys[:31]) - b += xgb.Pad(int(31)) - - return buf -} - -// 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) -} - -// String is a rudimentary string representation of KeymapNotifyEvent. -func (v KeymapNotifyEvent) String() string { - fieldVals := make([]string, 0, 1) - return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[11] = KeymapNotifyEventNew -} - -// Expose is the event number for a ExposeEvent. -const Expose = 12 - -type ExposeEvent struct { +type ColormapNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Window Window - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 + Window Window + Colormap Colormap + New bool + State byte // padding: 2 bytes } -// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. -func ExposeEventNew(buf []byte) xgb.Event { - v := ExposeEvent{} +// 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 @@ -3406,333 +1290,31 @@ func ExposeEventNew(buf []byte) xgb.Event { v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.X = xgb.Get16(buf[b:]) - b += 2 - - v.Y = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.Count = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -// Bytes writes a ExposeEvent value to a byte slice. -func (v ExposeEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 12 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Window)) + v.Colormap = Colormap(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], v.X) - b += 2 - - xgb.Put16(buf[b:], v.Y) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], v.Count) - b += 2 - - b += 2 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the Expose event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ExposeEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of ExposeEvent. -func (v ExposeEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[12] = ExposeEventNew -} - -// GraphicsExposure is the event number for a GraphicsExposureEvent. -const GraphicsExposure = 13 - -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 -} - -// 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 += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(xgb.Get32(buf[b:])) - b += 4 - - v.X = xgb.Get16(buf[b:]) - b += 2 - - v.Y = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.Count = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] + if buf[b] == 1 { + v.New = true + } else { + v.New = false + } b += 1 - b += 3 // padding - - return v -} - -// Bytes writes a GraphicsExposureEvent value to a byte slice. -func (v GraphicsExposureEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 13 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - xgb.Put16(buf[b:], v.X) - b += 2 - - xgb.Put16(buf[b:], v.Y) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], v.MinorOpcode) - b += 2 - - xgb.Put16(buf[b:], v.Count) - b += 2 - - buf[b] = v.MajorOpcode - b += 1 - - b += 3 // padding - - return buf -} - -// 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 -} - -// 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, ", ") + "}" -} - -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 -} - -// 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 - - b += 1 // padding - - return v -} - -// Bytes writes a NoExposureEvent value to a byte slice. -func (v NoExposureEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 14 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - xgb.Put16(buf[b:], v.MinorOpcode) - b += 2 - - buf[b] = v.MajorOpcode - b += 1 - - b += 1 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the NoExposure event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v NoExposureEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of NoExposureEvent. -func (v NoExposureEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[14] = NoExposureEventNew -} - -// VisibilityNotify is the event number for a VisibilityNotifyEvent. -const VisibilityNotify = 15 - -type VisibilityNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - State byte - // padding: 3 bytes -} - -// VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. -func VisibilityNotifyEventNew(buf []byte) xgb.Event { - v := VisibilityNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - v.State = buf[b] b += 1 - b += 3 // padding + b += 2 // padding return v } -// Bytes writes a VisibilityNotifyEvent value to a byte slice. -func (v VisibilityNotifyEvent) Bytes() []byte { +// Bytes writes a ColormapNotifyEvent value to a byte slice. +func (v ColormapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 15 + buf[b] = 32 b += 1 b += 1 // padding @@ -3742,607 +1324,60 @@ func (v VisibilityNotifyEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Window)) b += 4 + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + if v.New { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + buf[b] = v.State b += 1 - b += 3 // padding + b += 2 // padding return buf } -// SequenceId returns the sequence id attached to the VisibilityNotify event. +// 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 VisibilityNotifyEvent) SequenceId() uint16 { +func (v ColormapNotifyEvent) 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 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 "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[15] = VisibilityNotifyEventNew + xgb.NewEventFuncs[32] = ColormapNotifyEventNew } -// 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.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 - - 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 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Bytes writes a CreateNotifyEvent value to a byte slice. -func (v CreateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 16 - b += 1 - - 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 - - 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 - - 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 -} - -// String is a rudimentary string representation of CreateNotifyEvent. -func (v CreateNotifyEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[16] = CreateNotifyEventNew -} - -// DestroyNotify is the event number for a DestroyNotifyEvent. -const DestroyNotify = 17 - -type DestroyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window -} - -// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. -func DestroyNotifyEventNew(buf []byte) xgb.Event { - v := DestroyNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Bytes writes a DestroyNotifyEvent value to a byte slice. -func (v DestroyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 17 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - return buf -} - -// SequenceId returns the sequence id attached to the DestroyNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v DestroyNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of DestroyNotifyEvent. -func (v DestroyNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[17] = DestroyNotifyEventNew -} - -// UnmapNotify is the event number for a UnmapNotifyEvent. -const UnmapNotify = 18 - -type UnmapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - FromConfigure bool - // padding: 3 bytes -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.FromConfigure = true - } else { - v.FromConfigure = false - } - b += 1 - - b += 3 // padding - - return v -} - -// 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] = 18 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - if v.FromConfigure { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the UnmapNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v UnmapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of UnmapNotifyEvent. -func (v UnmapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) - return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[18] = UnmapNotifyEventNew -} - -// MapNotify is the event number for a MapNotifyEvent. -const MapNotify = 19 - -type MapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - OverrideRedirect bool - // padding: 3 bytes -} - -// 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 - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 3 // padding - - return v -} - -// 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] = 19 - 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 - - b += 3 // padding - - return buf -} - -// 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 MapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// 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("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, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[19] = MapNotifyEventNew -} - -// MapRequest is the event number for a MapRequestEvent. -const MapRequest = 20 - -type MapRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window -} - -// 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 - - 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 MapRequestEvent value to a byte slice. -func (v MapRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 20 - b += 1 - - 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 MapRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v MapRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -// 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[20] = MapRequestEventNew -} - -// ReparentNotify is the event number for a ReparentNotifyEvent. -const ReparentNotify = 21 - -type ReparentNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - Parent Window - X int16 - Y int16 - OverrideRedirect bool - // padding: 3 bytes -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 3 // padding - - return v -} - -// Bytes writes a ReparentNotifyEvent value to a byte slice. -func (v ReparentNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 21 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Parent)) - b += 4 - - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the ReparentNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ReparentNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// 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, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[21] = ReparentNotifyEventNew -} +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 @@ -4614,6 +1649,1255 @@ func init() { xgb.NewEventFuncs[23] = ConfigureRequestEventNew } +const ( + CoordModeOrigin = 0 + CoordModePrevious = 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.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 + + 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 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Bytes writes a CreateNotifyEvent value to a byte slice. +func (v CreateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 16 + b += 1 + + 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 + + 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 + + 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 +} + +// String is a rudimentary string representation of CreateNotifyEvent. +func (v CreateNotifyEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[16] = CreateNotifyEventNew +} + +type Cursor uint32 + +func NewCursorId(c *xgb.Conn) (Cursor, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Cursor(id), nil +} + +// BadCursor is the error number for a BadCursor. +const BadCursor = 6 + +type CursorError ValueError + +// CursorErrorNew constructs a CursorError value that implements xgb.Error from a byte slice. +func CursorErrorNew(buf []byte) xgb.Error { + v := CursorError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Cursor" + return v +} + +// SequenceId returns the sequence id attached to the BadCursor error. +// This is mostly used internally. +func (err CursorError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadCursor error. If no bad value exists, 0 is returned. +func (err CursorError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadCursor error. +func (err CursorError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[6] = CursorErrorNew +} + +const ( + CursorNone = 0 +) + +const ( + CwBackPixmap = 1 + CwBackPixel = 2 + CwBorderPixmap = 4 + CwBorderPixel = 8 + CwBitGravity = 16 + CwWinGravity = 32 + CwBackingStore = 64 + CwBackingPlanes = 128 + CwBackingPixel = 256 + CwOverrideRedirect = 512 + CwSaveUnder = 1024 + CwEventMask = 2048 + CwDontPropagate = 4096 + CwColormap = 8192 + CwCursor = 16384 +) + +type DepthInfo struct { + Depth byte + // padding: 1 bytes + VisualsLen uint16 + // padding: 4 bytes + Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) +} + +// DepthInfoRead reads a byte slice into a DepthInfo value. +func DepthInfoRead(buf []byte, v *DepthInfo) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.VisualsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]VisualInfo, v.VisualsLen) + b += VisualInfoReadList(buf[b:], v.Visuals) + + return b +} + +// DepthInfoReadList reads a byte slice into a list of DepthInfo values. +func DepthInfoReadList(buf []byte, dest []DepthInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DepthInfo{} + b += DepthInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a DepthInfo value to a byte slice. +func (v DepthInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.VisualsLen) + b += 2 + + b += 4 // padding + + b += VisualInfoListBytes(buf[b:], v.Visuals) + + return buf +} + +// DepthInfoListBytes writes a list of DepthInfo values to a byte slice. +func DepthInfoListBytes(buf []byte, list []DepthInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. +func DepthInfoListSize(list []DepthInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) + } + return size +} + +// DestroyNotify is the event number for a DestroyNotifyEvent. +const DestroyNotify = 17 + +type DestroyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window +} + +// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. +func DestroyNotifyEventNew(buf []byte) xgb.Event { + v := DestroyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Bytes writes a DestroyNotifyEvent value to a byte slice. +func (v DestroyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 17 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +// SequenceId returns the sequence id attached to the DestroyNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DestroyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of DestroyNotifyEvent. +func (v DestroyNotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[17] = DestroyNotifyEventNew +} + +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Drawable(id), nil +} + +// BadDrawable is the error number for a BadDrawable. +const BadDrawable = 9 + +type DrawableError ValueError + +// DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. +func DrawableErrorNew(buf []byte) xgb.Error { + v := DrawableError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Drawable" + return v +} + +// SequenceId returns the sequence id attached to the BadDrawable error. +// This is mostly used internally. +func (err DrawableError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadDrawable error. If no bad value exists, 0 is returned. +func (err DrawableError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadDrawable error. +func (err DrawableError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[9] = DrawableErrorNew +} + +// EnterNotify is the event number for a EnterNotifyEvent. +const EnterNotify = 7 + +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 +} + +// 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 + + 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 + + return v +} + +// Bytes writes a EnterNotifyEvent value to a byte slice. +func (v EnterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 7 + 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 + + buf[b] = v.Mode + b += 1 + + buf[b] = v.SameScreenFocus + b += 1 + + return buf +} + +// 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[7] = EnterNotifyEventNew +} + +const ( + EventMaskNoEvent = 0 + EventMaskKeyPress = 1 + EventMaskKeyRelease = 2 + EventMaskButtonPress = 4 + EventMaskButtonRelease = 8 + EventMaskEnterWindow = 16 + EventMaskLeaveWindow = 32 + EventMaskPointerMotion = 64 + EventMaskPointerMotionHint = 128 + EventMaskButton1Motion = 256 + EventMaskButton2Motion = 512 + EventMaskButton3Motion = 1024 + EventMaskButton4Motion = 2048 + EventMaskButton5Motion = 4096 + EventMaskButtonMotion = 8192 + EventMaskKeymapState = 16384 + EventMaskExposure = 32768 + EventMaskVisibilityChange = 65536 + EventMaskStructureNotify = 131072 + EventMaskResizeRedirect = 262144 + EventMaskSubstructureNotify = 524288 + EventMaskSubstructureRedirect = 1048576 + EventMaskFocusChange = 2097152 + EventMaskPropertyChange = 4194304 + EventMaskColorMapChange = 8388608 + EventMaskOwnerGrabButton = 16777216 +) + +// Expose is the event number for a ExposeEvent. +const Expose = 12 + +type ExposeEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 2 bytes +} + +// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. +func ExposeEventNew(buf []byte) xgb.Event { + v := ExposeEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Bytes writes a ExposeEvent value to a byte slice. +func (v ExposeEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 12 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + b += 2 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the Expose event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ExposeEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of ExposeEvent. +func (v ExposeEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[12] = ExposeEventNew +} + +const ( + ExposuresNotAllowed = 0 + ExposuresAllowed = 1 + ExposuresDefault = 2 +) + +const ( + FamilyInternet = 0 + FamilyDECnet = 1 + FamilyChaos = 2 + FamilyServerInterpreted = 5 + FamilyInternet6 = 6 +) + +const ( + FillRuleEvenOdd = 0 + FillRuleWinding = 1 +) + +const ( + FillStyleSolid = 0 + FillStyleTiled = 1 + FillStyleStippled = 2 + FillStyleOpaqueStippled = 3 +) + +// FocusIn is the event number for a FocusInEvent. +const FocusIn = 9 + +type FocusInEvent struct { + Sequence uint16 + Detail byte + Event Window + Mode byte + // padding: 3 bytes +} + +// 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.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a FocusInEvent value to a byte slice. +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 9 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + buf[b] = v.Mode + b += 1 + + b += 3 // padding + + 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[9] = FocusInEventNew +} + +// FocusOut is the event number for a FocusOutEvent. +const FocusOut = 10 + +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)) +} + +// Bytes writes a FocusOutEvent value to a byte slice. +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} + +// 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 +} + +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, ", ") + "}" +} + +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 Font(id), nil +} + +const ( + FontNone = 0 +) + +// BadFont is the error number for a BadFont. +const BadFont = 7 + +type FontError ValueError + +// FontErrorNew constructs a FontError value that implements xgb.Error from a byte slice. +func FontErrorNew(buf []byte) xgb.Error { + v := FontError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Font" + return v +} + +// SequenceId returns the sequence id attached to the BadFont error. +// This is mostly used internally. +func (err FontError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadFont error. If no bad value exists, 0 is returned. +func (err FontError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadFont error. +func (err FontError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.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 Fontable(id), nil +} + +type Fontprop struct { + Name Atom + Value uint32 +} + +// FontpropRead reads a byte slice into a Fontprop value. +func FontpropRead(buf []byte, v *Fontprop) int { + b := 0 + + v.Name = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Value = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// FontpropReadList reads a byte slice into a list of Fontprop values. +func FontpropReadList(buf []byte, dest []Fontprop) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Fontprop{} + b += FontpropRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Fontprop value to a byte slice. +func (v Fontprop) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + xgb.Put32(buf[b:], v.Value) + b += 4 + + return buf +} + +// FontpropListBytes writes a list of Fontprop values to a byte slice. +func FontpropListBytes(buf []byte, list []Fontprop) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Format struct { + Depth byte + BitsPerPixel byte + ScanlinePad byte + // padding: 5 bytes +} + +// FormatRead reads a byte slice into a Format value. +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + v.BitsPerPixel = buf[b] + b += 1 + + v.ScanlinePad = buf[b] + b += 1 + + b += 5 // padding + + return b +} + +// FormatReadList reads a byte slice into a list of Format values. +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Format value to a byte slice. +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.Depth + b += 1 + + buf[b] = v.BitsPerPixel + b += 1 + + buf[b] = v.ScanlinePad + b += 1 + + b += 5 // padding + + return buf +} + +// FormatListBytes writes a list of Format values to a byte slice. +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// BadGContext is the error number for a BadGContext. +const BadGContext = 13 + +type GContextError ValueError + +// GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. +func GContextErrorNew(buf []byte) xgb.Error { + v := GContextError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "GContext" + return v +} + +// SequenceId returns the sequence id attached to the BadGContext error. +// This is mostly used internally. +func (err GContextError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadGContext error. If no bad value exists, 0 is returned. +func (err GContextError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadGContext error. +func (err GContextError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[13] = GContextErrorNew +} + +const ( + GcFunction = 1 + GcPlaneMask = 2 + GcForeground = 4 + GcBackground = 8 + GcLineWidth = 16 + GcLineStyle = 32 + GcCapStyle = 64 + GcJoinStyle = 128 + GcFillStyle = 256 + GcFillRule = 512 + GcTile = 1024 + GcStipple = 2048 + GcTileStippleOriginX = 4096 + GcTileStippleOriginY = 8192 + GcFont = 16384 + GcSubwindowMode = 32768 + GcGraphicsExposures = 65536 + GcClipOriginX = 131072 + GcClipOriginY = 262144 + GcClipMask = 524288 + GcDashOffset = 1048576 + GcDashList = 2097152 + GcArcMode = 4194304 +) + +type Gcontext uint32 + +func NewGcontextId(c *xgb.Conn) (Gcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Gcontext(id), nil +} + +const ( + GetPropertyTypeAny = 0 +) + +const ( + GrabAny = 0 +) + +const ( + GrabModeSync = 0 + GrabModeAsync = 1 +) + +const ( + GrabStatusSuccess = 0 + GrabStatusAlreadyGrabbed = 1 + GrabStatusInvalidTime = 2 + GrabStatusNotViewable = 3 + GrabStatusFrozen = 4 +) + +// GraphicsExposure is the event number for a GraphicsExposureEvent. +const GraphicsExposure = 13 + +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 +} + +// 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 += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a GraphicsExposureEvent value to a byte slice. +func (v GraphicsExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 13 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 3 // padding + + return buf +} + +// 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[13] = GraphicsExposureEventNew +} + +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 @@ -4701,101 +2985,605 @@ func init() { xgb.NewEventFuncs[24] = GravityNotifyEventNew } -// ResizeRequest is the event number for a ResizeRequestEvent. -const ResizeRequest = 25 +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 ResizeRequestEvent struct { - Sequence uint16 +type Host struct { + Family byte // padding: 1 bytes - Window Window - Width uint16 - Height uint16 + AddressLen uint16 + Address []byte // size: xgb.Pad((int(AddressLen) * 1)) } -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// Bytes writes a ResizeRequestEvent value to a byte slice. -func (v ResizeRequestEvent) Bytes() []byte { - buf := make([]byte, 32) +// HostRead reads a byte slice into a Host value. +func HostRead(buf []byte, v *Host) int { b := 0 - // write event number - buf[b] = 25 + v.Family = buf[b] b += 1 b += 1 // padding - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - xgb.Put16(buf[b:], v.Width) + v.AddressLen = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], v.Height) + 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 + + xgb.Put16(buf[b:], v.AddressLen) b += 2 + copy(buf[b:], v.Address[:v.AddressLen]) + b += xgb.Pad(int(v.AddressLen)) + 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 +// 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 } -// String is a rudimentary string representation of ResizeRequestEvent. -func (v ResizeRequestEvent) String() string { +// 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, 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, ", ") + "}" + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[25] = ResizeRequestEventNew + xgb.NewErrorFuncs[14] = IDChoiceErrorNew } -// CirculateNotify is the event number for a CirculateNotifyEvent. -const CirculateNotify = 26 +const ( + ImageFormatXYBitmap = 0 + ImageFormatXYPixmap = 1 + ImageFormatZPixmap = 2 +) -type CirculateNotifyEvent struct { +const ( + ImageOrderLSBFirst = 0 + ImageOrderMSBFirst = 1 +) + +// BadImplementation is the error number for a BadImplementation. +const BadImplementation = 17 + +type ImplementationError RequestError + +// ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. +func ImplementationErrorNew(buf []byte) xgb.Error { + v := ImplementationError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Implementation" + return v +} + +// SequenceId returns the sequence id attached to the BadImplementation error. +// This is mostly used internally. +func (err ImplementationError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadImplementation error. If no bad value exists, 0 is returned. +func (err ImplementationError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadImplementation error. +func (err ImplementationError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[17] = ImplementationErrorNew +} + +const ( + InputFocusNone = 0 + InputFocusPointerRoot = 1 + InputFocusParent = 2 + InputFocusFollowKeyboard = 3 +) + +const ( + JoinStyleMiter = 0 + JoinStyleRound = 1 + JoinStyleBevel = 2 +) + +const ( + KbKeyClickPercent = 1 + KbBellPercent = 2 + KbBellPitch = 4 + KbBellDuration = 8 + KbLed = 16 + KbLedMode = 32 + KbKey = 64 + KbAutoRepeatMode = 128 +) + +const ( + KeyButMaskShift = 1 + KeyButMaskLock = 2 + KeyButMaskControl = 4 + KeyButMaskMod1 = 8 + KeyButMaskMod2 = 16 + KeyButMaskMod3 = 32 + KeyButMaskMod4 = 64 + KeyButMaskMod5 = 128 + KeyButMaskButton1 = 256 + KeyButMaskButton2 = 512 + KeyButMaskButton3 = 1024 + KeyButMaskButton4 = 2048 + KeyButMaskButton5 = 4096 +) + +// KeyPress is the event number for a KeyPressEvent. +const KeyPress = 2 + +type KeyPressEvent struct { + Sequence uint16 + Detail Keycode + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// 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 = Keycode(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 + + b += 1 // padding + + return v +} + +// 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] = 2 + 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 KeyPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v KeyPressEvent) SequenceId() uint16 { + return v.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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[2] = KeyPressEventNew +} + +// KeyRelease is the event number for a KeyReleaseEvent. +const KeyRelease = 3 + +type KeyReleaseEvent KeyPressEvent + +// 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 KeyReleaseEvent value to a byte slice. +func (v KeyReleaseEvent) Bytes() []byte { + return KeyPressEvent(v).Bytes() +} + +// 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 +} + +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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[3] = KeyReleaseEventNew +} + +type Keycode byte + +// KeymapNotify is the event number for a KeymapNotifyEvent. +const KeymapNotify = 11 + +type KeymapNotifyEvent struct { + Keys []byte // size: 32 +} + +// 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.Keys = make([]byte, 31) + copy(v.Keys[:31], buf[b:]) + b += xgb.Pad(int(31)) + + return v +} + +// 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] = 11 + b += 1 + + copy(buf[b:], v.Keys[:31]) + b += xgb.Pad(int(31)) + + return buf +} + +// 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) +} + +// String is a rudimentary string representation of KeymapNotifyEvent. +func (v KeymapNotifyEvent) String() string { + fieldVals := make([]string, 0, 1) + return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[11] = KeymapNotifyEventNew +} + +type Keysym uint32 + +const ( + KillAllTemporary = 0 +) + +// LeaveNotify is the event number for a LeaveNotifyEvent. +const LeaveNotify = 8 + +type LeaveNotifyEvent EnterNotifyEvent + +// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. +func LeaveNotifyEventNew(buf []byte) xgb.Event { + return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) +} + +// Bytes writes a LeaveNotifyEvent value to a byte slice. +func (v LeaveNotifyEvent) Bytes() []byte { + return EnterNotifyEvent(v).Bytes() +} + +// SequenceId returns the sequence id attached to the LeaveNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v LeaveNotifyEvent) SequenceId() uint16 { + return v.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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[8] = LeaveNotifyEventNew +} + +const ( + LedModeOff = 0 + LedModeOn = 1 +) + +// BadLength is the error number for a BadLength. +const BadLength = 16 + +type LengthError RequestError + +// LengthErrorNew constructs a LengthError value that implements xgb.Error from a byte slice. +func LengthErrorNew(buf []byte) xgb.Error { + v := LengthError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Length" + return v +} + +// SequenceId returns the sequence id attached to the BadLength error. +// This is mostly used internally. +func (err LengthError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadLength error. If no bad value exists, 0 is returned. +func (err LengthError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadLength error. +func (err LengthError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[16] = LengthErrorNew +} + +const ( + LineStyleSolid = 0 + LineStyleOnOffDash = 1 + LineStyleDoubleDash = 2 +) + +const ( + MapIndexShift = 0 + MapIndexLock = 1 + MapIndexControl = 2 + MapIndex1 = 3 + MapIndex2 = 4 + MapIndex3 = 5 + MapIndex4 = 6 + MapIndex5 = 7 +) + +// MapNotify is the event number for a MapNotifyEvent. +const MapNotify = 19 + +type MapNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - // padding: 4 bytes - Place byte + Event Window + Window Window + OverrideRedirect bool // padding: 3 bytes } -// CirculateNotifyEventNew constructs a CirculateNotifyEvent value that implements xgb.Event from a byte slice. -func CirculateNotifyEventNew(buf []byte) xgb.Event { - v := CirculateNotifyEvent{} +// 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 b += 1 // padding @@ -4809,9 +3597,11 @@ func CirculateNotifyEventNew(buf []byte) xgb.Event { v.Window = Window(xgb.Get32(buf[b:])) b += 4 - b += 4 // padding - - v.Place = buf[b] + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } b += 1 b += 3 // padding @@ -4819,13 +3609,13 @@ func CirculateNotifyEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a CirculateNotifyEvent value to a byte slice. -func (v CirculateNotifyEvent) 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] = 26 + buf[b] = 19 b += 1 b += 1 // padding @@ -4838,9 +3628,11 @@ func (v CirculateNotifyEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - b += 4 // padding - - buf[b] = v.Place + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 b += 3 // padding @@ -4848,27 +3640,674 @@ func (v CirculateNotifyEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the CirculateNotify 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 CirculateNotifyEvent) SequenceId() uint16 { +func (v MapNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of CirculateNotifyEvent. -func (v CirculateNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) +// 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("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, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[26] = CirculateNotifyEventNew + xgb.NewEventFuncs[19] = MapNotifyEventNew } +// MapRequest is the event number for a MapRequestEvent. +const MapRequest = 20 + +type MapRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window +} + +// 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 + + 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 MapRequestEvent value to a byte slice. +func (v MapRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 20 + b += 1 + + 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 MapRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v MapRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +// 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[20] = MapRequestEventNew +} + +const ( + MapStateUnmapped = 0 + MapStateUnviewable = 1 + MapStateViewable = 2 +) + +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 + Request byte + FirstKeycode Keycode + Count byte + // padding: 1 bytes +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Request = buf[b] + b += 1 + + v.FirstKeycode = Keycode(buf[b]) + b += 1 + + v.Count = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// 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] = 34 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count + b += 1 + + b += 1 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the MappingNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v MappingNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of MappingNotifyEvent. +func (v MappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + 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 +} + +// BadId returns the 'BadValue' number if one exists for the BadMatch error. If no bad value exists, 0 is returned. +func (err MatchError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadMatch error. +func (err MatchError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[8] = MatchErrorNew +} + +const ( + ModMaskShift = 1 + ModMaskLock = 2 + ModMaskControl = 4 + ModMask1 = 8 + ModMask2 = 16 + ModMask3 = 32 + ModMask4 = 64 + ModMask5 = 128 + ModMaskAny = 32768 +) + +const ( + MotionNormal = 0 + MotionHint = 1 +) + +// MotionNotify is the event number for a MotionNotifyEvent. +const MotionNotify = 6 + +type MotionNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// 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 + + b += 1 // padding + + return v +} + +// 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 +} + +// 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 MotionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of MotionNotifyEvent. +func (v MotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("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[6] = MotionNotifyEventNew +} + +// BadName is the error number for a BadName. +const BadName = 15 + +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 +} + +// SequenceId returns the sequence id attached to the BadName error. +// This is mostly used internally. +func (err NameError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadName error. If no bad value exists, 0 is returned. +func (err NameError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadName error. +func (err NameError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[15] = NameErrorNew +} + +// NoExposure is the event number for a NoExposureEvent. +const NoExposure = 14 + +type NoExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// NoExposureEventNew constructs a NoExposureEvent value that implements xgb.Event from a byte slice. +func NoExposureEventNew(buf []byte) xgb.Event { + v := NoExposureEvent{} + b := 1 // don't read event number + + 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 + + b += 1 // padding + + return v +} + +// Bytes writes a NoExposureEvent value to a byte slice. +func (v NoExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 1 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the NoExposure event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v NoExposureEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of NoExposureEvent. +func (v NoExposureEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[14] = NoExposureEventNew +} + +const ( + NotifyDetailAncestor = 0 + NotifyDetailVirtual = 1 + NotifyDetailInferior = 2 + NotifyDetailNonlinear = 3 + NotifyDetailNonlinearVirtual = 4 + NotifyDetailPointer = 5 + NotifyDetailPointerRoot = 6 + NotifyDetailNone = 7 +) + +const ( + NotifyModeNormal = 0 + NotifyModeGrab = 1 + NotifyModeUngrab = 2 + NotifyModeWhileGrabbed = 3 +) + +type Pixmap uint32 + +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} + +// BadPixmap is the error number for a BadPixmap. +const BadPixmap = 4 + +type PixmapError ValueError + +// PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. +func PixmapErrorNew(buf []byte) xgb.Error { + v := PixmapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Pixmap" + return v +} + +// SequenceId returns the sequence id attached to the BadPixmap error. +// This is mostly used internally. +func (err PixmapError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadPixmap error. If no bad value exists, 0 is returned. +func (err PixmapError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadPixmap error. +func (err PixmapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[4] = PixmapErrorNew +} + +const ( + PixmapNone = 0 +) + +const ( + PlaceOnTop = 0 + PlaceOnBottom = 1 +) + +type Point struct { + X int16 + Y int16 +} + +// PointRead reads a byte slice into a Point value. +func PointRead(buf []byte, v *Point) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// PointReadList reads a byte slice into a list of Point values. +func PointReadList(buf []byte, dest []Point) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Point{} + b += PointRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Point value to a byte slice. +func (v Point) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// PointListBytes writes a list of Point values to a byte slice. +func PointListBytes(buf []byte, list []Point) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + PolyShapeComplex = 0 + PolyShapeNonconvex = 1 + PolyShapeConvex = 2 +) + +const ( + PropModeReplace = 0 + PropModePrepend = 1 + PropModeAppend = 2 +) + +const ( + PropertyNewValue = 0 + PropertyDelete = 1 +) + // PropertyNotify is the event number for a PropertyNotifyEvent. const PropertyNotify = 28 @@ -4961,6 +4400,653 @@ func init() { xgb.NewEventFuncs[28] = PropertyNotifyEventNew } +const ( + QueryShapeOfLargestCursor = 0 + QueryShapeOfFastestTile = 1 + QueryShapeOfFastestStipple = 2 +) + +type Rectangle struct { + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// RectangleRead reads a byte slice into a Rectangle value. +func RectangleRead(buf []byte, v *Rectangle) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + 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 + Parent Window + X int16 + Y int16 + OverrideRedirect bool + // padding: 3 bytes +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a ReparentNotifyEvent value to a byte slice. +func (v ReparentNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 21 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the ReparentNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ReparentNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// 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, ", ") + "}" +} + +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.NewErrorFuncs[1] = RequestErrorNew +} + +// 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 +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// 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] = 25 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + 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 +} + +// 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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[25] = ResizeRequestEventNew +} + +type Rgb struct { + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes +} + +// RgbRead reads a byte slice into a Rgb value. +func RgbRead(buf []byte, v *Rgb) int { + b := 0 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b +} + +// RgbReadList reads a byte slice into a list of Rgb values. +func RgbReadList(buf []byte, dest []Rgb) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rgb{} + b += RgbRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Rgb value to a byte slice. +func (v Rgb) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + b += 2 // padding + + return buf +} + +// 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 +} + +type ScreenInfo struct { + Root Window + DefaultColormap Colormap + WhitePixel uint32 + BlackPixel uint32 + CurrentInputMasks uint32 + WidthInPixels uint16 + HeightInPixels uint16 + WidthInMillimeters uint16 + HeightInMillimeters uint16 + MinInstalledMaps uint16 + MaxInstalledMaps uint16 + RootVisual Visualid + BackingStores byte + SaveUnders bool + RootDepth byte + AllowedDepthsLen byte + AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) +} + +// ScreenInfoRead reads a byte slice into a ScreenInfo value. +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { + b := 0 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + v.WhitePixel = xgb.Get32(buf[b:]) + b += 4 + + v.BlackPixel = xgb.Get32(buf[b:]) + b += 4 + + v.CurrentInputMasks = xgb.Get32(buf[b:]) + b += 4 + + v.WidthInPixels = xgb.Get16(buf[b:]) + b += 2 + + v.HeightInPixels = xgb.Get16(buf[b:]) + b += 2 + + v.WidthInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.HeightInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.MinInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.MaxInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.RootVisual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.BackingStores = buf[b] + b += 1 + + 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 +} + +// 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) +} + +// Bytes writes a ScreenInfo value to a byte slice. +func (v ScreenInfo) Bytes() []byte { + buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.DefaultColormap)) + b += 4 + + xgb.Put32(buf[b:], v.WhitePixel) + b += 4 + + xgb.Put32(buf[b:], v.BlackPixel) + b += 4 + + xgb.Put32(buf[b:], v.CurrentInputMasks) + b += 4 + + xgb.Put16(buf[b:], v.WidthInPixels) + b += 2 + + xgb.Put16(buf[b:], v.HeightInPixels) + b += 2 + + xgb.Put16(buf[b:], v.WidthInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.HeightInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.MinInstalledMaps) + b += 2 + + xgb.Put16(buf[b:], v.MaxInstalledMaps) + b += 2 + + xgb.Put32(buf[b:], uint32(v.RootVisual)) + b += 4 + + buf[b] = v.BackingStores + b += 1 + + 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 +} + +// 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 +} + +const ( + ScreenSaverReset = 0 + ScreenSaverActive = 1 +) + +type Segment struct { + X1 int16 + Y1 int16 + X2 int16 + Y2 int16 +} + +// SegmentRead reads a byte slice into a Segment value. +func SegmentRead(buf []byte, v *Segment) int { + b := 0 + + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y2 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// 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) +} + +// Bytes writes a Segment value to a byte slice. +func (v Segment) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X2)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y2)) + b += 2 + + return buf +} + +// SegmentListBytes writes a list of Segment values to a byte slice. +func SegmentListBytes(buf []byte, list []Segment) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + // SelectionClear is the event number for a SelectionClearEvent. const SelectionClear = 29 @@ -5040,6 +5126,101 @@ func init() { xgb.NewEventFuncs[29] = SelectionClearEventNew } +// SelectionNotify is the event number for a SelectionNotifyEvent. +const SelectionNotify = 31 + +type SelectionNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Requestor Window + Selection Atom + Target Atom + Property Atom +} + +// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. +func SelectionNotifyEventNew(buf []byte) xgb.Event { + v := SelectionNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Requestor = Window(xgb.Get32(buf[b:])) + b += 4 + + 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 SelectionNotifyEvent value to a byte slice. +func (v SelectionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 31 + 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.Requestor)) + b += 4 + + 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 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, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[31] = SelectionNotifyEventNew +} + // SelectionRequest is the event number for a SelectionRequestEvent. const SelectionRequest = 30 @@ -5143,117 +5324,676 @@ func init() { xgb.NewEventFuncs[30] = SelectionRequestEventNew } -// SelectionNotify is the event number for a SelectionNotifyEvent. -const SelectionNotify = 31 +const ( + SendEventDestPointerWindow = 0 + SendEventDestItemFocus = 1 +) -type SelectionNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Requestor Window - Selection Atom - Target Atom - Property Atom +const ( + SetModeInsert = 0 + SetModeDelete = 1 +) + +type SetupAuthenticate struct { + Status byte + // padding: 5 bytes + Length uint16 + Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) } -// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. -func SelectionNotifyEventNew(buf []byte) xgb.Event { - v := SelectionNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Requestor = Window(xgb.Get32(buf[b:])) - b += 4 - - 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 SelectionNotifyEvent value to a byte slice. -func (v SelectionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. +func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { b := 0 - // write event number - buf[b] = 31 + v.Status = buf[b] b += 1 - b += 1 // padding + b += 5 // padding - b += 2 // skip sequence number + v.Length = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + { + byteString := make([]byte, (int(v.Length) * 4)) + copy(byteString[:(int(v.Length)*4)], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int((int(v.Length) * 4))) + } - xgb.Put32(buf[b:], uint32(v.Requestor)) - b += 4 + return b +} - xgb.Put32(buf[b:], uint32(v.Selection)) - b += 4 +// 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) +} - xgb.Put32(buf[b:], uint32(v.Target)) - b += 4 +// 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 - xgb.Put32(buf[b:], uint32(v.Property)) - b += 4 + buf[b] = v.Status + b += 1 + + b += 5 // padding + + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:(int(v.Length)*4)]) + b += xgb.Pad(int((int(v.Length) * 4))) return buf } -// 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 +// 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 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, ", ") + "}" +// 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[31] = SelectionNotifyEventNew +type SetupFailed struct { + Status byte + ReasonLen byte + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + Reason string // size: xgb.Pad((int(ReasonLen) * 1)) } -// ColormapNotify is the event number for a ColormapNotifyEvent. -const ColormapNotify = 32 +// SetupFailedRead reads a byte slice into a SetupFailed value. +func SetupFailedRead(buf []byte, v *SetupFailed) int { + b := 0 -type ColormapNotifyEvent struct { + v.Status = buf[b] + b += 1 + + v.ReasonLen = buf[b] + b += 1 + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.ReasonLen) + copy(byteString[:v.ReasonLen], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int(v.ReasonLen)) + } + + return b +} + +// SetupFailedReadList reads a byte slice into a list of SetupFailed values. +func SetupFailedReadList(buf []byte, dest []SetupFailed) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupFailed{} + b += SetupFailedRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a SetupFailed value to a byte slice. +func (v SetupFailed) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) + b := 0 + + buf[b] = v.Status + b += 1 + + buf[b] = v.ReasonLen + b += 1 + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:v.ReasonLen]) + b += xgb.Pad(int(v.ReasonLen)) + + return buf +} + +// 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 +} + +// 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) +} + +// SetupInfoRead reads a byte slice into a SetupInfo value. +func SetupInfoRead(buf []byte, v *SetupInfo) int { + b := 0 + + v.Status = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + v.ReleaseNumber = xgb.Get32(buf[b:]) + b += 4 + + v.ResourceIdBase = xgb.Get32(buf[b:]) + b += 4 + + v.ResourceIdMask = xgb.Get32(buf[b:]) + b += 4 + + v.MotionBufferSize = xgb.Get32(buf[b:]) + b += 4 + + v.VendorLen = xgb.Get16(buf[b:]) + b += 2 + + v.MaximumRequestLength = xgb.Get16(buf[b:]) + b += 2 + + v.RootsLen = buf[b] + b += 1 + + v.PixmapFormatsLen = buf[b] + b += 1 + + v.ImageByteOrder = buf[b] + b += 1 + + v.BitmapFormatBitOrder = buf[b] + b += 1 + + v.BitmapFormatScanlineUnit = buf[b] + b += 1 + + v.BitmapFormatScanlinePad = buf[b] + b += 1 + + v.MinKeycode = Keycode(buf[b]) + b += 1 + + v.MaxKeycode = Keycode(buf[b]) + b += 1 + + b += 4 // padding + + { + byteString := make([]byte, v.VendorLen) + copy(byteString[:v.VendorLen], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLen)) + } + + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) + b += FormatReadList(buf[b:], v.PixmapFormats) + + v.Roots = make([]ScreenInfo, v.RootsLen) + b += ScreenInfoReadList(buf[b:], v.Roots) + + return b +} + +// SetupInfoReadList reads a byte slice into a list of SetupInfo values. +func SetupInfoReadList(buf []byte, dest []SetupInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupInfo{} + b += SetupInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a SetupInfo value to a byte slice. +func (v SetupInfo) Bytes() []byte { + buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) + b := 0 + + buf[b] = v.Status + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + xgb.Put32(buf[b:], v.ReleaseNumber) + b += 4 + + xgb.Put32(buf[b:], v.ResourceIdBase) + b += 4 + + xgb.Put32(buf[b:], v.ResourceIdMask) + b += 4 + + xgb.Put32(buf[b:], v.MotionBufferSize) + b += 4 + + xgb.Put16(buf[b:], v.VendorLen) + b += 2 + + xgb.Put16(buf[b:], v.MaximumRequestLength) + b += 2 + + buf[b] = v.RootsLen + b += 1 + + buf[b] = v.PixmapFormatsLen + b += 1 + + buf[b] = v.ImageByteOrder + b += 1 + + buf[b] = v.BitmapFormatBitOrder + b += 1 + + buf[b] = v.BitmapFormatScanlineUnit + b += 1 + + buf[b] = v.BitmapFormatScanlinePad + b += 1 + + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + b += 4 // padding + + copy(buf[b:], v.Vendor[:v.VendorLen]) + b += xgb.Pad(int(v.VendorLen)) + + b += FormatListBytes(buf[b:], v.PixmapFormats) + + b += ScreenInfoListBytes(buf[b:], v.Roots) + + return buf +} + +// SetupInfoListBytes writes a list of SetupInfo values to a byte slice. +func SetupInfoListBytes(buf []byte, list []SetupInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. +func SetupInfoListSize(list []SetupInfo) int { + size := 0 + for _, item := range list { + size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) + } + return size +} + +type SetupRequest struct { + ByteOrder byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + AuthorizationProtocolNameLen uint16 + AuthorizationProtocolDataLen uint16 + // padding: 2 bytes + AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) + AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) +} + +// SetupRequestRead reads a byte slice into a SetupRequest value. +func SetupRequestRead(buf []byte, v *SetupRequest) int { + b := 0 + + v.ByteOrder = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + { + byteString := make([]byte, v.AuthorizationProtocolNameLen) + copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) + v.AuthorizationProtocolName = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + } + + { + byteString := make([]byte, v.AuthorizationProtocolDataLen) + copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) + v.AuthorizationProtocolData = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + } + + return b +} + +// SetupRequestReadList reads a byte slice into a list of SetupRequest values. +func SetupRequestReadList(buf []byte, dest []SetupRequest) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupRequest{} + b += SetupRequestRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a SetupRequest value to a byte slice. +func (v SetupRequest) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) + b := 0 + + buf[b] = v.ByteOrder + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) + b += 2 + + xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + + copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + + return buf +} + +// SetupRequestListBytes writes a list of SetupRequest values to a byte slice. +func SetupRequestListBytes(buf []byte, list []SetupRequest) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. +func SetupRequestListSize(list []SetupRequest) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) + } + return size +} + +const ( + StackModeAbove = 0 + StackModeBelow = 1 + StackModeTopIf = 2 + StackModeBottomIf = 3 + StackModeOpposite = 4 +) + +type Str struct { + NameLen byte + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// StrRead reads a byte slice into a Str value. +func StrRead(buf []byte, v *Str) int { + b := 0 + + v.NameLen = buf[b] + b += 1 + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b +} + +// StrReadList reads a byte slice into a list of Str values. +func StrReadList(buf []byte, dest []Str) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Str{} + b += StrRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Str value to a byte slice. +func (v Str) Bytes() []byte { + buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 + + buf[b] = v.NameLen + b += 1 + + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) + + return buf +} + +// StrListBytes writes a list of Str values to a byte slice. +func StrListBytes(buf []byte, list []Str) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// StrListSize computes the size (bytes) of a list of Str values. +func StrListSize(list []Str) int { + size := 0 + for _, item := range list { + size += (1 + xgb.Pad((int(item.NameLen) * 1))) + } + return size +} + +const ( + SubwindowModeClipByChildren = 0 + SubwindowModeIncludeInferiors = 1 +) + +const ( + TimeCurrentTime = 0 +) + +type Timecoord struct { + Time Timestamp + X int16 + Y int16 +} + +// TimecoordRead reads a byte slice into a Timecoord value. +func TimecoordRead(buf []byte, v *Timecoord) int { + b := 0 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// TimecoordReadList reads a byte slice into a list of Timecoord values. +func TimecoordReadList(buf []byte, dest []Timecoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Timecoord{} + b += TimecoordRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Timecoord value to a byte slice. +func (v Timecoord) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// TimecoordListBytes writes a list of Timecoord values to a byte slice. +func TimecoordListBytes(buf []byte, list []Timecoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Timestamp uint32 + +// UnmapNotify is the event number for a UnmapNotifyEvent. +const UnmapNotify = 18 + +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,513 +6001,74 @@ func ColormapNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.Colormap = Colormap(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.Event)) + b += 4 + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], uint32(v.Colormap)) - 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) - 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 -} - -// ClientMessage is the event number for a ClientMessageEvent. -const ClientMessage = 33 - -type ClientMessageEvent struct { - Sequence uint16 - Format byte - Window Window - Type Atom - Data ClientMessageDataUnion -} - -// ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. -func ClientMessageEventNew(buf []byte) xgb.Event { - v := ClientMessageEvent{} - b := 1 // don't read event number - - v.Format = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Type = Atom(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 - - buf[b] = v.Format - 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)) - } - - return buf -} - -// 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 -} - -// String is a rudimentary string representation of ClientMessageEvent. -func (v ClientMessageEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) - return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[33] = ClientMessageEventNew -} - -// MappingNotify is the event number for a MappingNotifyEvent. -const MappingNotify = 34 - -type MappingNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Request byte - FirstKeycode Keycode - Count byte - // padding: 1 bytes -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Request = buf[b] - b += 1 - - v.FirstKeycode = Keycode(buf[b]) - b += 1 - - v.Count = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -// 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] = 34 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - buf[b] = v.Request - b += 1 - - buf[b] = byte(v.FirstKeycode) - b += 1 - - buf[b] = v.Count - b += 1 - - b += 1 // padding - - return buf -} - -// SequenceId returns the sequence id attached to the MappingNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v MappingNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of MappingNotifyEvent. -func (v MappingNotifyEvent) String() string { +// 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("Request: %d", v.Request)) - fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[34] = MappingNotifyEventNew -} - -// KeyRelease is the event number for a KeyReleaseEvent. -const KeyRelease = 3 - -type KeyReleaseEvent KeyPressEvent - -// 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 KeyReleaseEvent value to a byte slice. -func (v KeyReleaseEvent) Bytes() []byte { - return KeyPressEvent(v).Bytes() -} - -// 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 -} - -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, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[3] = KeyReleaseEventNew -} - -// 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 -} - -// LeaveNotify is the event number for a LeaveNotifyEvent. -const LeaveNotify = 8 - -type LeaveNotifyEvent EnterNotifyEvent - -// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. -func LeaveNotifyEventNew(buf []byte) xgb.Event { - return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) -} - -// Bytes writes a LeaveNotifyEvent value to a byte slice. -func (v LeaveNotifyEvent) Bytes() []byte { - return EnterNotifyEvent(v).Bytes() -} - -// SequenceId returns the sequence id attached to the LeaveNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v LeaveNotifyEvent) SequenceId() uint16 { - return v.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, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[8] = LeaveNotifyEventNew -} - -// FocusOut is the event number for a FocusOutEvent. -const FocusOut = 10 - -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)) -} - -// Bytes writes a FocusOutEvent value to a byte slice. -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() -} - -// 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 -} - -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, ", ") + "}" -} - -func init() { - xgb.NewEventFuncs[10] = FocusOutEventNew -} - -// CirculateRequest is the event number for a CirculateRequestEvent. -const CirculateRequest = 27 - -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)) -} - -// Bytes writes a CirculateRequestEvent value to a byte slice. -func (v CirculateRequestEvent) Bytes() []byte { - return CirculateNotifyEvent(v).Bytes() -} - -// 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 -} - -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, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) + return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[27] = CirculateRequestEventNew -} - -// BadRequest is the error number for a BadRequest. -const BadRequest = 1 - -type RequestError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes -} - -// RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. -func RequestErrorNew(buf []byte) xgb.Error { - v := RequestError{} - v.NiceName = "Request" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.BadValue = xgb.Get32(buf[b:]) - b += 4 - - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -// SequenceId returns the sequence id attached to the BadRequest error. -// This is mostly used internally. -func (err RequestError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadRequest error. If no bad value exists, 0 is returned. -func (err RequestError) BadId() uint32 { - return err.BadValue -} - -// Error returns a rudimentary string representation of the BadRequest error. - -func (err RequestError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} - -func init() { - xgb.NewErrorFuncs[1] = RequestErrorNew + xgb.NewEventFuncs[18] = UnmapNotifyEventNew } // BadValue is the error number for a BadValue. @@ -5834,6 +6135,207 @@ func init() { xgb.NewErrorFuncs[2] = ValueErrorNew } +const ( + VisibilityUnobscured = 0 + VisibilityPartiallyObscured = 1 + VisibilityFullyObscured = 2 +) + +// VisibilityNotify is the event number for a VisibilityNotifyEvent. +const VisibilityNotify = 15 + +type VisibilityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + State byte + // padding: 3 bytes +} + +// VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. +func VisibilityNotifyEventNew(buf []byte) xgb.Event { + v := VisibilityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Bytes writes a VisibilityNotifyEvent value to a byte slice. +func (v VisibilityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 15 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the VisibilityNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v VisibilityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of VisibilityNotifyEvent. +func (v VisibilityNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[15] = VisibilityNotifyEventNew +} + +const ( + VisualClassStaticGray = 0 + VisualClassGrayScale = 1 + VisualClassStaticColor = 2 + VisualClassPseudoColor = 3 + VisualClassTrueColor = 4 + VisualClassDirectColor = 5 +) + +type VisualInfo struct { + VisualId Visualid + Class byte + BitsPerRgbValue byte + ColormapEntries uint16 + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 4 bytes +} + +// VisualInfoRead reads a byte slice into a VisualInfo value. +func VisualInfoRead(buf []byte, v *VisualInfo) int { + b := 0 + + v.VisualId = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Class = buf[b] + b += 1 + + v.BitsPerRgbValue = buf[b] + b += 1 + + v.ColormapEntries = xgb.Get16(buf[b:]) + b += 2 + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + return b +} + +// VisualInfoReadList reads a byte slice into a list of VisualInfo values. +func VisualInfoReadList(buf []byte, dest []VisualInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = VisualInfo{} + b += VisualInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a VisualInfo value to a byte slice. +func (v VisualInfo) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + xgb.Put32(buf[b:], uint32(v.VisualId)) + b += 4 + + buf[b] = v.Class + b += 1 + + buf[b] = v.BitsPerRgbValue + b += 1 + + xgb.Put16(buf[b:], v.ColormapEntries) + b += 2 + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + b += 4 // padding + + return buf +} + +// VisualInfoListBytes writes a list of VisualInfo values to a byte slice. +func VisualInfoListBytes(buf []byte, list []VisualInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Visualid uint32 + +type Window uint32 + +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil +} + +const ( + WindowNone = 0 +) + // BadWindow is the error number for a BadWindow. const BadWindow = 3 @@ -5872,536 +6374,1970 @@ func init() { xgb.NewErrorFuncs[3] = WindowErrorNew } -// BadPixmap is the error number for a BadPixmap. -const BadPixmap = 4 +const ( + WindowClassCopyFromParent = 0 + WindowClassInputOutput = 1 + WindowClassInputOnly = 2 +) -type PixmapError ValueError +// Skipping definition for base type 'Bool' + +// 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' + +// AllocColorCookie is a cookie used only for AllocColor requests. +type AllocColorCookie 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. +// 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} +} + +// 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 +} + +// 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 +} + +// 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.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 -// PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. -func PixmapErrorNew(buf []byte) xgb.Error { - v := PixmapError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Pixmap" return v } -// SequenceId returns the sequence id attached to the BadPixmap error. -// This is mostly used internally. -func (err PixmapError) SequenceId() uint16 { - return err.Sequence +// 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) + + buf[b] = 84 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Red) + b += 2 + + xgb.Put16(buf[b:], Green) + b += 2 + + xgb.Put16(buf[b:], Blue) + b += 2 + + b += 2 // padding + + return buf } -// 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 +// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. +type AllocColorCellsCookie struct { + *xgb.Cookie } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[4] = PixmapErrorNew +// 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} } -// BadAtom is the error number for a BadAtom. -const BadAtom = 5 +// 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)) +} -type AtomError ValueError +// 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 +} + +// 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.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PixelsLen = xgb.Get16(buf[b:]) + b += 2 + + v.MasksLen = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Masks = make([]uint32, v.MasksLen) + for i := 0; i < int(v.MasksLen); i++ { + v.Masks[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) -// 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 } -// SequenceId returns the sequence id attached to the BadAtom error. -// This is mostly used internally. -func (err AtomError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for AllocColorCells +// allocColorCellsRequest writes a AllocColorCells request to a byte slice. +func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 86 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Colors) + b += 2 + + xgb.Put16(buf[b:], Planes) + b += 2 + + return buf } -// 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 +// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. +type AllocColorPlanesCookie struct { + *xgb.Cookie } -// Error returns a rudimentary string representation of the BadAtom error. -func (err AtomError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[5] = AtomErrorNew +// 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} } -// BadCursor is the error number for a BadCursor. -const BadCursor = 6 +// 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)) +} -type CursorError ValueError +// 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 +} + +// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. +func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { + v := new(AllocColorPlanesReply) + 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.PixelsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) -// 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 +// Write request to wire for AllocColorPlanes +// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. +func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 87 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Colors) + b += 2 + + xgb.Put16(buf[b:], Reds) + b += 2 + + xgb.Put16(buf[b:], Greens) + b += 2 + + xgb.Put16(buf[b:], Blues) + b += 2 + + return buf } -// 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 +// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. +type AllocNamedColorCookie struct { + *xgb.Cookie } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[6] = CursorErrorNew +// 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} } -// BadFont is the error number for a BadFont. -const BadFont = 7 +// 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 +} -type FontError ValueError +// 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 +} + +// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. +func allocNamedColorReply(buf []byte) *AllocNamedColorReply { + v := new(AllocNamedColorReply) + 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.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:]) + b += 2 + + v.VisualBlue = xgb.Get16(buf[b:]) + 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 } -// SequenceId returns the sequence id attached to the BadFont error. -// This is mostly used internally. -func (err FontError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for 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) + + buf[b] = 85 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + 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 +// AllowEventsCookie is a cookie used only for AllowEvents requests. +type AllowEventsCookie struct { + *xgb.Cookie } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[7] = FontErrorNew +// 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} } -// 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 +// Check returns an error if one occurred 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() } -// SequenceId returns the sequence id attached to the BadMatch error. -// This is mostly used internally. -func (err MatchError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for AllowEvents +// allowEventsRequest writes a AllowEvents request to a byte slice. +func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 35 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf } -// 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 +// BellCookie is a cookie used only for Bell requests. +type BellCookie struct { + *xgb.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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[8] = MatchErrorNew +// 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} } -// BadDrawable is the error number for a BadDrawable. -const BadDrawable = 9 - -type DrawableError ValueError - -// DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. -func DrawableErrorNew(buf []byte) xgb.Error { - v := DrawableError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Drawable" - return v +// Check returns an error if one occurred 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() } -// SequenceId returns the sequence id attached to the BadDrawable error. -// This is mostly used internally. -func (err DrawableError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for Bell +// bellRequest writes a Bell request to a byte slice. +func bellRequest(c *xgb.Conn, Percent int8) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 104 // request opcode + b += 1 + + buf[b] = byte(Percent) + b += 1 + + 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 BadDrawable error. If no bad value exists, 0 is returned. -func (err DrawableError) 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 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, ", ") + "}" +// 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[9] = DrawableErrorNew +// 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} } -// BadAccess is the error number for a BadAccess. -const BadAccess = 10 - -type AccessError RequestError - -// 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 +// Check returns an error if one occurred 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() } -// SequenceId returns the sequence id attached to the BadAccess error. -// This is mostly used internally. -func (err AccessError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for 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) + + buf[b] = 30 // 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(Cursor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + b += 2 // padding + + return buf } -// 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 +// ChangeGCCookie is a cookie used only for ChangeGC requests. +type ChangeGCCookie struct { + *xgb.Cookie } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[10] = AccessErrorNew +// 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} } -// BadAlloc is the error number for a BadAlloc. -const BadAlloc = 11 - -type AllocError RequestError - -// 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 +// Check returns an error if one occurred 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() } -// SequenceId returns the sequence id attached to the BadAlloc error. -// This is mostly used internally. -func (err AllocError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for ChangeGC +// changeGCRequest writes a ChangeGC request to a byte slice. +func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 56 // 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(Gc)) + 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 } -// 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 +// ChangeHostsCookie is a cookie used only for ChangeHosts requests. +type ChangeHostsCookie struct { + *xgb.Cookie } -// Error returns a rudimentary string representation of the BadAlloc error. -func (err AllocError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeHosts 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} } -func init() { - xgb.NewErrorFuncs[11] = AllocErrorNew +// ChangeHostsChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeHostsCookie.Check() +func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} } -// 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 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeHostsCookie) Check() error { + return cook.Cookie.Check() } -// SequenceId returns the sequence id attached to the BadColormap error. -// This is mostly used internally. -func (err ColormapError) SequenceId() uint16 { - return err.Sequence +// 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] = 109 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Family + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], AddressLen) + b += 2 + + copy(buf[b:], Address[:AddressLen]) + b += xgb.Pad(int(AddressLen)) + + return buf } -// 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 +// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. +type ChangeKeyboardControlCookie struct { + *xgb.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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[12] = ColormapErrorNew +// 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} } -// BadGContext is the error number for a BadGContext. -const BadGContext = 13 - -type GContextError ValueError - -// GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. -func GContextErrorNew(buf []byte) xgb.Error { - v := GContextError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "GContext" - return v +// Check returns an error if one occurred 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() } -// SequenceId returns the sequence id attached to the BadGContext error. -// This is mostly used internally. -func (err GContextError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for 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 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf } -// 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 +// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. +type ChangeKeyboardMappingCookie struct { + *xgb.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, ", ") + "}" +// ChangeKeyboardMapping sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} } -func init() { - xgb.NewErrorFuncs[13] = GContextErrorNew +// ChangeKeyboardMappingChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() +func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} } -// 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 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeKeyboardMappingCookie) Check() error { + return cook.Cookie.Check() } -// SequenceId returns the sequence id attached to the BadIDChoice error. -// This is mostly used internally. -func (err IDChoiceError) SequenceId() uint16 { - return err.Sequence +// 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] = 100 // request opcode + b += 1 + + buf[b] = KeycodeCount + 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] = KeysymsPerKeycode + b += 1 + + b += 2 // padding + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf } -// 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 +// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. +type ChangePointerControlCookie 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, ", ") + "}" +// ChangePointerControl sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} } -func init() { - xgb.NewErrorFuncs[14] = IDChoiceErrorNew +// 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} } -// BadName is the error number for a BadName. -const BadName = 15 - -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 +// Check returns an error if one occurred 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() } -// SequenceId returns the sequence id attached to the BadName error. -// This is mostly used internally. -func (err NameError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for ChangePointerControl +// changePointerControlRequest writes a ChangePointerControl request to a byte slice. +func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 105 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], uint16(AccelerationNumerator)) + b += 2 + + xgb.Put16(buf[b:], uint16(AccelerationDenominator)) + b += 2 + + xgb.Put16(buf[b:], uint16(Threshold)) + b += 2 + + if DoAcceleration { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if DoThreshold { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf } -// 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 +// ChangePropertyCookie is a cookie used only for ChangeProperty requests. +type ChangePropertyCookie struct { + *xgb.Cookie } -// 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, ", ") + "}" +// 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} } -func init() { - xgb.NewErrorFuncs[15] = NameErrorNew +// 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} } -// 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 +// Check returns an error if one occurred 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() } -// SequenceId returns the sequence id attached to the BadLength error. -// This is mostly used internally. -func (err LengthError) SequenceId() uint16 { - return err.Sequence +// Write request to wire for 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] = 18 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(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 } -// 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 +// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. +type ChangeSaveSetCookie struct { + *xgb.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, ", ") + "}" +// ChangeSaveSet 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} } -func init() { - xgb.NewErrorFuncs[16] = LengthErrorNew +// 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(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} } -// BadImplementation is the error number for a BadImplementation. -const BadImplementation = 17 - -type ImplementationError RequestError - -// ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. -func ImplementationErrorNew(buf []byte) xgb.Error { - v := ImplementationError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Implementation" - return v +// Check returns an error if one occurred 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 { + return cook.Cookie.Check() } -// SequenceId returns the sequence id attached to the BadImplementation error. -// This is mostly used internally. -func (err ImplementationError) SequenceId() uint16 { - return err.Sequence +// 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] = 6 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf } -// 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 +// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. +type ChangeWindowAttributesCookie struct { + *xgb.Cookie } -// Error returns a rudimentary string representation of the BadImplementation error. -func (err ImplementationError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeWindowAttributes 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} } -func init() { - xgb.NewErrorFuncs[17] = ImplementationErrorNew +// 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(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 ChangeWindowAttributesCookie) 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))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 2 // 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 + + 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 +} + +// CirculateWindowCookie is a cookie used only for CirculateWindow requests. +type CirculateWindowCookie struct { + *xgb.Cookie +} + +// CirculateWindow 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{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 { + cookie := c.NewCookie(true, false) + 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 CirculateWindowCookie) 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 + b := 0 + buf := make([]byte, size) + + buf[b] = 13 // request opcode + b += 1 + + buf[b] = Direction + 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 +} + +// ClearAreaCookie is a cookie used only for ClearArea requests. +type ClearAreaCookie struct { + *xgb.Cookie +} + +// ClearArea sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} +} + +// ClearAreaChecked sends a checked request. +// If an error occurs, it can be retrieved using ClearAreaCookie.Check() +func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ClearAreaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ClearArea +// clearAreaRequest writes a ClearArea request to a byte slice. +func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 61 // request opcode + b += 1 + + if Exposures { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 46 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + return buf +} + +// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. +type ConfigureWindowCookie struct { + *xgb.Cookie +} + +// ConfigureWindow 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{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 { + cookie := c.NewCookie(true, false) + 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 ConfigureWindowCookie) 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))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 12 // 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 + + 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 +} + +// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. +type ConvertSelectionCookie struct { + *xgb.Cookie +} + +// ConvertSelection 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{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 { + cookie := c.NewCookie(true, false) + 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 ConvertSelectionCookie) 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 + b := 0 + buf := make([]byte, size) + + buf[b] = 24 // 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(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 +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// Write request to wire for CopyArea +// copyAreaRequest writes a CopyArea request to a byte slice. +func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = 62 // request opcode + b += 1 + + b += 1 // padding + + 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)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. +type CopyColormapAndFreeCookie struct { + *xgb.Cookie +} + +// CopyColormapAndFree sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +// CopyColormapAndFreeChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() +func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CopyColormapAndFreeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyColormapAndFree +// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. +func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 80 // 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(Mid)) + b += 4 + + xgb.Put32(buf[b:], uint32(SrcCmap)) + b += 4 + + return buf +} + +// CopyGCCookie is a cookie used only for CopyGC requests. +type CopyGCCookie struct { + *xgb.Cookie +} + +// CopyGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} +} + +// CopyGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyGCCookie.Check() +func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CopyGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyGC +// copyGCRequest writes a CopyGC request to a byte slice. +func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 57 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcGc)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstGc)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + + return buf +} + +// CopyPlaneCookie is a cookie used only for CopyPlane requests. +type CopyPlaneCookie struct { + *xgb.Cookie +} + +// CopyPlane sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} +} + +// CopyPlaneChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyPlaneCookie.Check() +func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CopyPlaneCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyPlane +// copyPlaneRequest writes a CopyPlane request to a byte slice. +func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 63 // request opcode + b += 1 + + b += 1 // padding + + 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)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], BitPlane) + b += 4 + + return buf +} + +// CreateColormapCookie is a cookie used only for CreateColormap requests. +type CreateColormapCookie struct { + *xgb.Cookie +} + +// CreateColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} +} + +// CreateColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateColormapCookie.Check() +func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateColormap +// createColormapRequest writes a CreateColormap request to a byte slice. +func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 78 // request opcode + b += 1 + + 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 +} + +// CreateCursorCookie is a cookie used only for CreateCursor requests. +type CreateCursorCookie 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 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mask)) + 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 +} + +// CreateGCCookie is a cookie used only for CreateGC requests. +type CreateGCCookie struct { + *xgb.Cookie +} + +// CreateGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +// CreateGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGCCookie.Check() +func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGC +// createGCRequest writes a CreateGC request to a byte slice. +func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 55 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + 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 +} + +// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. +type CreateGlyphCursorCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + return buf +} + +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { + *xgb.Cookie +} + +// CreatePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() +func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. +func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 53 // request opcode + b += 1 + + buf[b] = Depth + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf } // CreateWindowCookie is a cookie used only for CreateWindow requests. @@ -6485,41 +8421,41 @@ 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 { +// DeletePropertyCookie is a cookie used only for DeleteProperty requests. +type DeletePropertyCookie struct { *xgb.Cookie } -// ChangeWindowAttributes sends an unchecked request. +// DeleteProperty 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 DeleteProperty(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) + return DeletePropertyCookie{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 { +// DeletePropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using DeletePropertyCookie.Check() +func DeletePropertyChecked(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) + return DeletePropertyCookie{cookie} } // Check returns an error if one occurred 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 DeletePropertyCookie) 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 DeleteProperty +// deletePropertyRequest writes a DeleteProperty request to a byte slice. +func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 2 // request opcode + buf[b] = 19 // request opcode b += 1 b += 1 // padding @@ -6530,10 +8466,313 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Property)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) + + return buf +} + +// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. +type DestroySubwindowsCookie struct { + *xgb.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} +} + +// 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 DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroyWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyWindow +// destroyWindowRequest writes a DestroyWindow request to a byte slice. +func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 4 // 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 +} + +// FillPolyCookie is a cookie used only for FillPoly requests. +type FillPolyCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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 FillPoly +// fillPolyRequest writes a FillPoly request to a byte slice. +func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 69 // request opcode + b += 1 + + b += 1 // padding + + 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 + + buf[b] = Shape + b += 1 + + buf[b] = CoordinateMode + b += 1 + + b += 2 // padding + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. +type ForceScreenSaverCookie struct { + *xgb.Cookie +} + +// ForceScreenSaver sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} +} + +// ForceScreenSaverChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check() +func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ForceScreenSaverCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ForceScreenSaver +// forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice. +func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 115 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// FreeColormapCookie is a cookie used only for FreeColormap requests. +type FreeColormapCookie struct { + *xgb.Cookie +} + +// FreeColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} +} + +// FreeColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColormapCookie.Check() +func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreeColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeColormap +// freeColormapRequest writes a FreeColormap request to a byte slice. +func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 79 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// FreeColorsCookie is a cookie used only for FreeColors requests. +type FreeColorsCookie struct { + *xgb.Cookie +} + +// FreeColors sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} +} + +// FreeColorsChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColorsCookie.Check() +func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreeColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeColors +// freeColorsRequest writes a FreeColors request to a byte slice. +func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 88 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put32(buf[b:], PlaneMask) + b += 4 + + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) b += 4 } b = xgb.Pad(b) @@ -6541,6 +8780,1446 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, return buf } +// 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] = 95 // 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(Cursor)) + b += 4 + + return buf +} + +// FreeGCCookie is a cookie used only for FreeGC requests. +type FreeGCCookie struct { + *xgb.Cookie +} + +// FreeGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 60 // 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(Gc)) + b += 4 + + return buf +} + +// FreePixmapCookie is a cookie used only for FreePixmap requests. +type FreePixmapCookie struct { + *xgb.Cookie +} + +// FreePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} +} + +// FreePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreePixmapCookie.Check() +func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreePixmap +// freePixmapRequest writes a FreePixmap request to a byte slice. +func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 54 // request opcode + b += 1 + + 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 +} + +// GetAtomNameCookie is a cookie used only for GetAtomName requests. +type GetAtomNameCookie 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. +// 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} +} + +// 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)) +} + +// 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 +} + +// getAtomNameReply reads a byte slice into a GetAtomNameReply value. +func getAtomNameReply(buf []byte) *GetAtomNameReply { + v := new(GetAtomNameReply) + 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.NameLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return v +} + +// Write request to wire for 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] = 17 // 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(Atom)) + b += 4 + + return buf +} + +// GetFontPathCookie is a cookie used only for GetFontPath requests. +type GetFontPathCookie 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 { + cookie := c.NewCookie(true, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} +} + +// GetFontPathUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} +} + +// GetFontPathReply represents the data returned from a GetFontPath request. +type GetFontPathReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + PathLen uint16 + // padding: 22 bytes + Path []Str // size: StrListSize(Path) +} + +// 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 +} + +// getFontPathReply reads a byte slice into a GetFontPathReply value. +func getFontPathReply(buf []byte) *GetFontPathReply { + v := new(GetFontPathReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PathLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Path = make([]Str, v.PathLen) + b += StrReadList(buf[b:], v.Path) + + return v +} + +// Write request to wire for GetFontPath +// getFontPathRequest writes a GetFontPath request to a byte slice. +func getFontPathRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 52 // 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 +} + +// GetGeometryCookie is a cookie used only for GetGeometry requests. +type GetGeometryCookie 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. +// 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} +} + +// 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 +} + +// 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 +} + +// getGeometryReply reads a byte slice into a GetGeometryReply value. +func getGeometryReply(buf []byte) *GetGeometryReply { + v := new(GetGeometryReply) + 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.Root = 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 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + 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:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// GetImageCookie is a cookie used only for GetImage requests. +type GetImageCookie 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. +// 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)) +} + +// 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 +} + +// 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 +} + +// 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] = 73 // request opcode + b += 1 + + 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(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) + b += 4 + + return buf +} + +// GetInputFocusCookie is a cookie used only for GetInputFocus requests. +type GetInputFocusCookie 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 { + cookie := c.NewCookie(true, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{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} +} + +// 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 +} + +// 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 + } + if buf == nil { + return nil, nil + } + return getInputFocusReply(buf), nil +} + +// getInputFocusReply reads a byte slice into a GetInputFocusReply value. +func getInputFocusReply(buf []byte) *GetInputFocusReply { + v := new(GetInputFocusReply) + b := 1 // skip reply determinant + + v.RevertTo = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Focus = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetInputFocus +// getInputFocusRequest writes a GetInputFocus request to a byte slice. +func getInputFocusRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + 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 + + return buf +} + +// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. +type GetKeyboardControlCookie struct { + *xgb.Cookie +} + +// GetKeyboardControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() +func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +// GetKeyboardControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +// GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. +type GetKeyboardControlReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + GlobalAutoRepeat byte + LedMask uint32 + KeyClickPercent byte + BellPercent byte + BellPitch uint16 + BellDuration uint16 + // padding: 2 bytes + AutoRepeats []byte // size: 32 +} + +// Reply blocks and returns the reply data for a GetKeyboardControl request. +func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardControlReply(buf), nil +} + +// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. +func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { + v := new(GetKeyboardControlReply) + b := 1 // skip reply determinant + + v.GlobalAutoRepeat = buf[b] + b += 1 + + 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 + + v.KeyClickPercent = buf[b] + b += 1 + + v.BellPercent = buf[b] + b += 1 + + v.BellPitch = xgb.Get16(buf[b:]) + b += 2 + + v.BellDuration = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v +} + +// Write request to wire for GetKeyboardControl +// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. +func getKeyboardControlRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 103 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. +type GetKeyboardMappingCookie 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. +// 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)) +} + +// 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 +} + +// 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] = 101 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + + return buf +} + +// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. +type GetModifierMappingCookie 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. +// 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)) +} + +// 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 +} + +// 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 +} + +// Write request to wire for GetModifierMapping +// getModifierMappingRequest writes a GetModifierMapping request to a byte slice. +func getModifierMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 119 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// GetMotionEventsCookie is a cookie used only for GetMotionEvents requests. +type GetMotionEventsCookie struct { + *xgb.Cookie +} + +// GetMotionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMotionEventsCookie.Reply() +func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} +} + +// GetMotionEventsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} +} + +// GetMotionEventsReply represents the data returned from a GetMotionEvents request. +type GetMotionEventsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + EventsLen uint32 + // padding: 20 bytes + Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) +} + +// Reply blocks and returns the reply data for a GetMotionEvents request. +func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMotionEventsReply(buf), nil +} + +// getMotionEventsReply reads a byte slice into a GetMotionEventsReply value. +func getMotionEventsReply(buf []byte) *GetMotionEventsReply { + v := new(GetMotionEventsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.EventsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Events = make([]Timecoord, v.EventsLen) + b += TimecoordReadList(buf[b:], v.Events) + + return v +} + +// Write request to wire for GetMotionEvents +// getMotionEventsRequest writes a GetMotionEvents request to a byte slice. +func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 39 // 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 + + xgb.Put32(buf[b:], uint32(Start)) + b += 4 + + xgb.Put32(buf[b:], uint32(Stop)) + b += 4 + + return buf +} + +// GetPointerControlCookie is a cookie used only for GetPointerControl requests. +type GetPointerControlCookie 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 { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} +} + +// GetPointerControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} +} + +// 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 GetPointerControl request. +func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerControlReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + 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 + 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 +} + +// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. +type GetPointerMappingCookie 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. +// 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)) +} + +// 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 +} + +// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. +func getPointerMappingReply(buf []byte) *GetPointerMappingReply { + v := new(GetPointerMappingReply) + b := 1 // skip reply determinant + + v.MapLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Map = make([]byte, v.MapLen) + copy(v.Map[:v.MapLen], buf[b:]) + b += xgb.Pad(int(v.MapLen)) + + return v +} + +// Write request to wire for GetPointerMapping +// getPointerMappingRequest writes a GetPointerMapping request to a byte slice. +func getPointerMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 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 +} + +// GetPropertyCookie is a cookie used only for GetProperty requests. +type GetPropertyCookie struct { + *xgb.Cookie +} + +// GetProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyCookie.Reply() +func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} +} + +// GetPropertyUnchecked sends an unchecked request. +// 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} +} + +// 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 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 +} + +// getPropertyReply reads a byte slice into a GetPropertyReply value. +func getPropertyReply(buf []byte) *GetPropertyReply { + v := new(GetPropertyReply) + b := 1 // skip reply determinant + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + 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 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] = 20 // request opcode + b += 1 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + 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 +} + +// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. +type GetScreenSaverCookie 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. +// 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} +} + +// 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 +} + +// 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 +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + 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 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] = 108 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. +type GetSelectionOwnerCookie struct { + *xgb.Cookie +} + +// GetSelectionOwner sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() +func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +// GetSelectionOwnerUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +// GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. +type GetSelectionOwnerReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Owner Window +} + +// Reply blocks and returns the reply data for a GetSelectionOwner request. +func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionOwnerReply(buf), nil +} + +// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. +func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { + v := new(GetSelectionOwnerReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetSelectionOwner +// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. +func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 23 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + return buf +} + // GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. type GetWindowAttributesCookie struct { *xgb.Cookie @@ -6690,784 +10369,44 @@ func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { return buf } -// DestroyWindowCookie is a cookie used only for DestroyWindow requests. -type DestroyWindowCookie struct { +// GrabButtonCookie is a cookie used only for GrabButton requests. +type GrabButtonCookie struct { *xgb.Cookie } -// DestroyWindow 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 DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { +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(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{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 { +// 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(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyWindowCookie) Check() error { +func (cook GrabButtonCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyWindow -// destroyWindowRequest writes a DestroyWindow request to a byte slice. -func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for GrabButton +// grabButtonRequest writes a GrabButton request to a byte slice. +func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 4 // request opcode + buf[b] = 28 // 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 -} - -// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. -type DestroySubwindowsCookie struct { - *xgb.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} -} - -// 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 -} - -// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. -type ChangeSaveSetCookie struct { - *xgb.Cookie -} - -// ChangeSaveSet 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) - return ChangeSaveSetCookie{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 { - cookie := c.NewCookie(true, false) - 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 ChangeSaveSetCookie) 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 6 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// ReparentWindowCookie is a cookie used only for ReparentWindow requests. -type ReparentWindowCookie struct { - *xgb.Cookie -} - -// ReparentWindow 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} -} - -// 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} -} - -// Check returns an error if one occurred 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 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] = 7 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Parent)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - return buf -} - -// MapWindowCookie is a cookie used only for MapWindow requests. -type MapWindowCookie struct { - *xgb.Cookie -} - -// MapWindow 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook MapWindowCookie) 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 8 // 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 -} - -// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. -type MapSubwindowsCookie struct { - *xgb.Cookie -} - -// MapSubwindows 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(mapSubwindowsRequest(c, Window), cookie) - return MapSubwindowsCookie{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 { - cookie := c.NewCookie(true, false) - 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 MapSubwindowsCookie) 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 - b := 0 - buf := make([]byte, size) - - buf[b] = 9 // 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 -} - -// UnmapWindowCookie is a cookie used only for UnmapWindow requests. -type UnmapWindowCookie struct { - *xgb.Cookie -} - -// UnmapWindow sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{cookie} -} - -// UnmapWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using UnmapWindowCookie.Check() -func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UnmapWindowCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for UnmapWindow -// unmapWindowRequest writes a UnmapWindow request to a byte slice. -func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 10 // request opcode - b += 1 - - 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 -} - -// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. -type UnmapSubwindowsCookie struct { - *xgb.Cookie -} - -// UnmapSubwindows 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 11 // 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 -} - -// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. -type ConfigureWindowCookie struct { - *xgb.Cookie -} - -// ConfigureWindow 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{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 { - cookie := c.NewCookie(true, false) - 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 ConfigureWindowCookie) 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))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 12 // 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 - - 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 -} - -// CirculateWindowCookie is a cookie used only for CirculateWindow requests. -type CirculateWindowCookie struct { - *xgb.Cookie -} - -// CirculateWindow 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) - return CirculateWindowCookie{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 { - cookie := c.NewCookie(true, false) - 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 CirculateWindowCookie) 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 - b := 0 - buf := make([]byte, size) - - buf[b] = 13 // request opcode - b += 1 - - buf[b] = Direction - 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 -} - -// GetGeometryCookie is a cookie used only for GetGeometry requests. -type GetGeometryCookie 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. -// 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} -} - -// 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 -} - -// 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 -} - -// getGeometryReply reads a byte slice into a GetGeometryReply value. -func getGeometryReply(buf []byte) *GetGeometryReply { - v := new(GetGeometryReply) - 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.Root = 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 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.BorderWidth = xgb.Get16(buf[b:]) - 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:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// QueryTreeCookie is a cookie used only for QueryTree requests. -type QueryTreeCookie 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. -// 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 - - 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 -} - -// 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] = 15 // 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 -} - -// InternAtomCookie is a cookie used only for InternAtom requests. -type InternAtomCookie 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. -// 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} -} - -// 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 -} - -// 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 -} - -// 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] = 16 // request opcode - b += 1 - - if OnlyIfExists { + if OwnerEvents { buf[b] = 1 } else { buf[b] = 0 @@ -7477,374 +10416,132 @@ func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name stri xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - - return buf -} - -// GetAtomNameCookie is a cookie used only for GetAtomName requests. -type GetAtomNameCookie 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. -// 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} -} - -// 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)) -} - -// 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 -} - -// getAtomNameReply reads a byte slice into a GetAtomNameReply value. -func getAtomNameReply(buf []byte) *GetAtomNameReply { - v := new(GetAtomNameReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - v.NameLen = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], EventMask) b += 2 - b += 22 // padding + buf[b] = PointerMode + b += 1 - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } + buf[b] = KeyboardMode + b += 1 - return v -} + xgb.Put32(buf[b:], uint32(ConfineTo)) + b += 4 -// 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) + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 - buf[b] = 17 // request opcode + buf[b] = Button 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(Atom)) - b += 4 - return buf } -// ChangePropertyCookie is a cookie used only for ChangeProperty requests. -type ChangePropertyCookie struct { +// GrabKeyCookie is a cookie used only for GrabKey requests. +type GrabKeyCookie struct { *xgb.Cookie } -// ChangeProperty 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 ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { +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(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{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 { +// 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(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangePropertyCookie) Check() error { +func (cook GrabKeyCookie) 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 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] = 18 // request opcode + buf[b] = 33 // request opcode b += 1 - buf[b] = Mode + 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(Window)) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - xgb.Put32(buf[b:], uint32(Property)) - b += 4 + xgb.Put16(buf[b:], Modifiers) + b += 2 - xgb.Put32(buf[b:], uint32(Type)) - b += 4 + buf[b] = byte(Key) + b += 1 - buf[b] = Format + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode 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 } -// DeletePropertyCookie is a cookie used only for DeleteProperty requests. -type DeletePropertyCookie struct { +// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. +type GrabKeyboardCookie struct { *xgb.Cookie } -// DeleteProperty sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DeleteProperty(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) - return DeletePropertyCookie{cookie} -} - -// DeletePropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using DeletePropertyCookie.Check() -func DeletePropertyChecked(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) - return DeletePropertyCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DeletePropertyCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for DeleteProperty -// deletePropertyRequest writes a DeleteProperty request to a byte slice. -func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 19 // 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 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// GetPropertyCookie is a cookie used only for GetProperty requests. -type GetPropertyCookie 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 { +// 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(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} } -// GetPropertyUnchecked 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 GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { +func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{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)) -} - -// 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 -} - -// getPropertyReply reads a byte slice into a GetPropertyReply value. -func getPropertyReply(buf []byte) *GetPropertyReply { - v := new(GetPropertyReply) - b := 1 // skip reply determinant - - v.Format = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - 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 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] = 20 // request opcode - b += 1 - - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - xgb.Put32(buf[b:], uint32(Type)) - b += 4 - - xgb.Put32(buf[b:], LongOffset) - b += 4 - - xgb.Put32(buf[b:], LongLength) - b += 4 - - return buf -} - -// ListPropertiesCookie is a cookie used only for ListProperties requests. -type ListPropertiesCookie struct { - *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. -// 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 { +// 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 - // padding: 1 bytes - AtomsLen uint16 - // padding: 22 bytes - Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) + Status byte } -// 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 GrabKeyboard request. +func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -7852,15 +10549,16 @@ func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { if buf == nil { return nil, nil } - return listPropertiesReply(buf), nil + return grabKeyboardReply(buf), nil } -// listPropertiesReply reads a byte slice into a ListPropertiesReply value. -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) +// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. +func grabKeyboardReply(buf []byte) *GrabKeyboardReply { + v := new(GrabKeyboardReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -7868,275 +10566,20 @@ func listPropertiesReply(buf []byte) *ListPropertiesReply { 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 } -// 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] = 21 // 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 -} - -// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. -type SetSelectionOwnerCookie struct { - *xgb.Cookie -} - -// SetSelectionOwner 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} -} - -// Check returns an error if one occurred 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() -} - -// 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 { +// 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] = 22 // request opcode + buf[b] = 31 // 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(Owner)) - b += 4 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. -type GetSelectionOwnerCookie struct { - *xgb.Cookie -} - -// GetSelectionOwner sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() -func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -// GetSelectionOwnerUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -// GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. -type GetSelectionOwnerReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Owner Window -} - -// Reply blocks and returns the reply data for a GetSelectionOwner request. -func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectionOwnerReply(buf), nil -} - -// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. -func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { - v := new(GetSelectionOwnerReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Owner = Window(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for GetSelectionOwner -// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. -func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 23 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - return buf -} - -// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. -type ConvertSelectionCookie struct { - *xgb.Cookie -} - -// ConvertSelection 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{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 { - cookie := c.NewCookie(true, false) - 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 ConvertSelectionCookie) 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 - b := 0 - buf := make([]byte, size) - - buf[b] = 24 // 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(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 -} - -// SendEventCookie is a cookie used only for SendEvent requests. -type SendEventCookie struct { - *xgb.Cookie -} - -// 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} -} - -// Check returns an error if one occurred 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 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] = 25 // request opcode - b += 1 - - if Propagate { + if OwnerEvents { buf[b] = 1 } else { buf[b] = 0 @@ -8146,14 +10589,19 @@ func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - xgb.Put32(buf[b:], EventMask) + xgb.Put32(buf[b:], uint32(Time)) b += 4 - copy(buf[b:], Event[:32]) - b += xgb.Pad(int(32)) + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 2 // padding return buf } @@ -8259,552 +10707,6 @@ func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventM return buf } -// UngrabPointerCookie is a cookie used only for UngrabPointer requests. -type UngrabPointerCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 27 // 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(Time)) - b += 4 - - return buf -} - -// GrabButtonCookie is a cookie used only for GrabButton requests. -type GrabButtonCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for GrabButton -// grabButtonRequest writes a GrabButton request to a byte slice. -func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 28 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], EventMask) - b += 2 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - xgb.Put32(buf[b:], uint32(ConfineTo)) - b += 4 - - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 - - buf[b] = Button - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - return buf -} - -// UngrabButtonCookie is a cookie used only for UngrabButton requests. -type UngrabButtonCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 29 // 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 - - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - - return buf -} - -// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. -type ChangeActivePointerGrabCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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) - - buf[b] = 30 // 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(Cursor)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) - 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 { - *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 { - cookie := c.NewCookie(true, true) - c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} -} - -// GrabKeyboardUnchecked 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 { - cookie := c.NewCookie(false, true) - c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} -} - -// 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 GrabKeyboard request. -func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return grabKeyboardReply(buf), nil -} - -// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. -func grabKeyboardReply(buf []byte) *GrabKeyboardReply { - v := new(GrabKeyboardReply) - 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 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] = 31 // 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.Put32(buf[b:], uint32(Time)) - 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) - - buf[b] = 32 // 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(Time)) - b += 4 - - return buf -} - -// GrabKeyCookie is a cookie used only for GrabKey requests. -type GrabKeyCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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 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 - } - 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 - - b += 3 // padding - - return buf -} - -// UngrabKeyCookie is a cookie used only for UngrabKey requests. -type UngrabKeyCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 34 // request opcode - b += 1 - - buf[b] = byte(Key) - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - - return buf -} - -// AllowEventsCookie is a cookie used only for AllowEvents requests. -type AllowEventsCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for AllowEvents -// allowEventsRequest writes a AllowEvents request to a byte slice. -func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 35 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - // GrabServerCookie is a cookie used only for GrabServer requests. type GrabServerCookie struct { *xgb.Cookie @@ -8849,150 +10751,162 @@ func grabServerRequest(c *xgb.Conn) []byte { return buf } -// UngrabServerCookie is a cookie used only for UngrabServer requests. -type UngrabServerCookie struct { +// ImageText16Cookie is a cookie used only for ImageText16 requests. +type ImageText16Cookie struct { *xgb.Cookie } -// UngrabServer 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 UngrabServer(c *xgb.Conn) UngrabServerCookie { +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(ungrabServerRequest(c), cookie) - return UngrabServerCookie{cookie} + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} } -// UngrabServerChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabServerCookie.Check() -func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { +// 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(ungrabServerRequest(c), cookie) - return UngrabServerCookie{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 UngrabServerCookie) Check() error { +func (cook ImageText16Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UngrabServer -// ungrabServerRequest writes a UngrabServer request to a byte slice. -func ungrabServerRequest(c *xgb.Conn) []byte { - size := 4 +// 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] = 37 // request opcode + buf[b] = 77 // 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 + 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 + + b += Char2bListBytes(buf[b:], String) + return buf } -// QueryPointerCookie is a cookie used only for QueryPointer requests. -type QueryPointerCookie struct { +// ImageText8Cookie is a cookie used only for ImageText8 requests. +type ImageText8Cookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} -} - -// QueryPointerUnchecked 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 QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} +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(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{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 +// 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(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} } -// 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 - } - if buf == nil { - return nil, nil - } - return queryPointerReply(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 ImageText8Cookie) Check() error { + return cook.Cookie.Check() } -// queryPointerReply reads a byte slice into a QueryPointerReply value. -func queryPointerReply(buf []byte) *QueryPointerReply { - v := new(QueryPointerReply) - b := 1 // skip reply determinant +// 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) - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } + buf[b] = 76 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = StringLen + 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(Drawable)) b += 4 - v.Root = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - v.Child = Window(xgb.Get32(buf[b:])) - b += 4 - - v.RootX = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(X)) b += 2 - v.RootY = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(Y)) b += 2 - v.WinX = int16(xgb.Get16(buf[b:])) - b += 2 + copy(buf[b:], String[:StringLen]) + b += xgb.Pad(int(StringLen)) - v.WinY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Mask = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v + return buf } -// Write request to wire for QueryPointer -// queryPointerRequest writes a QueryPointer request to a byte slice. -func queryPointerRequest(c *xgb.Conn, Window Window) []byte { +// InstallColormapCookie is a cookie used only for InstallColormap requests. +type InstallColormapCookie struct { + *xgb.Cookie +} + +// InstallColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} +} + +// InstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using InstallColormapCookie.Check() +func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook InstallColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for InstallColormap +// installColormapRequest writes a InstallColormap request to a byte slice. +func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 38 // request opcode + buf[b] = 81 // request opcode b += 1 b += 1 // padding @@ -9000,45 +10914,43 @@ func queryPointerRequest(c *xgb.Conn, Window Window) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 return buf } -// GetMotionEventsCookie is a cookie used only for GetMotionEvents requests. -type GetMotionEventsCookie struct { +// InternAtomCookie is a cookie used only for InternAtom requests. +type InternAtomCookie struct { *xgb.Cookie } -// GetMotionEvents sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMotionEventsCookie.Reply() -func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { +// 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(getMotionEventsRequest(c, Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} } -// GetMotionEventsUnchecked sends an unchecked request. +// InternAtomUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { +func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} } -// GetMotionEventsReply represents the data returned from a GetMotionEvents request. -type GetMotionEventsReply struct { +// InternAtomReply represents the data returned from a InternAtom request. +type InternAtomReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - EventsLen uint32 - // padding: 20 bytes - Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) + Atom Atom } -// Reply blocks and returns the reply data for a GetMotionEvents request. -func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { +// Reply blocks and returns the reply data for a InternAtom request. +func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9046,12 +10958,12 @@ func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { if buf == nil { return nil, nil } - return getMotionEventsReply(buf), nil + return internAtomReply(buf), nil } -// getMotionEventsReply reads a byte slice into a GetMotionEventsReply value. -func getMotionEventsReply(buf []byte) *GetMotionEventsReply { - v := new(GetMotionEventsReply) +// 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 @@ -9062,469 +10974,32 @@ func getMotionEventsReply(buf []byte) *GetMotionEventsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.EventsLen = xgb.Get32(buf[b:]) + v.Atom = Atom(xgb.Get32(buf[b:])) b += 4 - b += 20 // padding - - v.Events = make([]Timecoord, v.EventsLen) - b += TimecoordReadList(buf[b:], v.Events) - return v } -// Write request to wire for GetMotionEvents -// getMotionEventsRequest writes a GetMotionEvents request to a byte slice. -func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { - size := 16 +// 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] = 39 // request opcode + buf[b] = 16 // 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 - - xgb.Put32(buf[b:], uint32(Start)) - b += 4 - - xgb.Put32(buf[b:], uint32(Stop)) - b += 4 - - return buf -} - -// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. -type TranslateCoordinatesCookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} -} - -// TranslateCoordinatesUnchecked 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 { - cookie := c.NewCookie(false, true) - c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{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 -} - -// 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 - } - 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 + if OnlyIfExists { + buf[b] = 1 } else { - v.SameScreen = false + buf[b] = 0 } 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() -} - -// 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 - - 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 -} - -// SetInputFocusCookie is a cookie used only for SetInputFocus requests. -type SetInputFocusCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 42 // request opcode - b += 1 - - 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 -} - -// GetInputFocusCookie is a cookie used only for GetInputFocus requests. -type GetInputFocusCookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(getInputFocusRequest(c), cookie) - return GetInputFocusCookie{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} -} - -// 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 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return getInputFocusReply(buf), nil -} - -// getInputFocusReply reads a byte slice into a GetInputFocusReply value. -func getInputFocusReply(buf []byte) *GetInputFocusReply { - v := new(GetInputFocusReply) - b := 1 // skip reply determinant - - v.RevertTo = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Focus = Window(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for GetInputFocus -// getInputFocusRequest writes a GetInputFocus request to a byte slice. -func getInputFocusRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - 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 - - return buf -} - -// QueryKeymapCookie is a cookie used only for QueryKeymap requests. -type QueryKeymapCookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} -} - -// QueryKeymapUnchecked 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 { - cookie := c.NewCookie(false, true) - c.NewRequest(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} -} - -// 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 - Keys []byte // size: 32 -} - -// 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 - } - if buf == nil { - return nil, nil - } - return queryKeymapReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += xgb.Pad(int(32)) - - return v -} - -// Write request to wire for QueryKeymap -// queryKeymapRequest writes a QueryKeymap request to a byte slice. -func queryKeymapRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 44 // request opcode - b += 1 - - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// OpenFontCookie is a cookie used only for OpenFont requests. -type OpenFontCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 45 // 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(Fid)) - b += 4 - xgb.Put16(buf[b:], NameLen) b += 2 @@ -9536,41 +11011,41 @@ func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte return buf } -// CloseFontCookie is a cookie used only for CloseFont requests. -type CloseFontCookie struct { +// KillClientCookie is a cookie used only for KillClient requests. +type KillClientCookie struct { *xgb.Cookie } -// CloseFont 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 CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { +func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { cookie := c.NewCookie(false, false) - c.NewRequest(closeFontRequest(c, Font), cookie) - return CloseFontCookie{cookie} + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{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 { +// 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(closeFontRequest(c, Font), cookie) - return CloseFontCookie{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 CloseFontCookie) Check() error { +func (cook KillClientCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CloseFont -// closeFontRequest writes a CloseFont request to a byte slice. -func closeFontRequest(c *xgb.Conn, Font Font) []byte { +// Write request to wire for 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] = 46 // request opcode + buf[b] = 113 // request opcode b += 1 b += 1 // padding @@ -9578,59 +11053,44 @@ 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:], Resource) b += 4 return buf } -// QueryFontCookie is a cookie used only for QueryFont requests. -type QueryFontCookie struct { +// ListExtensionsCookie is a cookie used only for ListExtensions requests. +type ListExtensionsCookie 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 { +// 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(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} } -// QueryFontUnchecked sends an unchecked request. +// ListExtensionsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { +func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} } -// QueryFontReply represents the data returned from a QueryFont request. -type QueryFontReply struct { +// 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 - // 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)) + NamesLen byte + // padding: 24 bytes + Names []Str // size: StrListSize(Names) } -// 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 ListExtensions request. +func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9638,152 +11098,15 @@ func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { if buf == nil { return nil, nil } - return queryFontReply(buf), nil + return listExtensionsReply(buf), nil } -// queryFontReply reads a byte slice into a QueryFontReply value. -func queryFontReply(buf []byte) *QueryFontReply { - v := new(QueryFontReply) +// listExtensionsReply reads a byte slice into a ListExtensionsReply value. +func listExtensionsReply(buf []byte) *ListExtensionsReply { + v := new(ListExtensionsReply) 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.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.CharInfosLen = xgb.Get32(buf[b:]) - b += 4 - - v.Properties = make([]Fontprop, v.PropertiesLen) - b += FontpropReadList(buf[b:], v.Properties) - - v.CharInfos = make([]Charinfo, v.CharInfosLen) - b += CharinfoReadList(buf[b:], v.CharInfos) - - return v -} - -// Write request to wire for 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] = 47 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Font)) - b += 4 - - return buf -} - -// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. -type QueryTextExtentsCookie 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. -// 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} -} - -// QueryTextExtentsReply represents the data returned from a QueryTextExtents request. -type QueryTextExtentsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - DrawDirection byte - FontAscent int16 - FontDescent int16 - OverallAscent int16 - OverallDescent int16 - OverallWidth int32 - OverallLeft int32 - OverallRight int32 -} - -// Reply blocks and returns the reply data for a 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 -} - -// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. -func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { - v := new(QueryTextExtentsReply) - b := 1 // skip reply determinant - - v.DrawDirection = buf[b] + v.NamesLen = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -9792,53 +11115,28 @@ func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.FontAscent = int16(xgb.Get16(buf[b:])) - b += 2 + b += 24 // padding - v.FontDescent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.OverallAscent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.OverallDescent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.OverallWidth = int32(xgb.Get32(buf[b:])) - b += 4 - - v.OverallLeft = int32(xgb.Get32(buf[b:])) - b += 4 - - v.OverallRight = int32(xgb.Get32(buf[b:])) - b += 4 + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) return v } -// Write request to wire for QueryTextExtents -// queryTextExtentsRequest writes a QueryTextExtents request to a byte slice. -func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { - size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) +// Write request to wire for ListExtensions +// listExtensionsRequest writes a ListExtensions request to a byte slice. +func listExtensionsRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 48 // request opcode - b += 1 - - buf[b] = byte((int(StringLen) & 1)) + buf[b] = 99 // request opcode b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Font)) - b += 4 - - b += Char2bListBytes(buf[b:], String) - - // skip writing local field: StringLen (2) :: uint16 - return buf } @@ -10094,91 +11392,39 @@ func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, P return buf } -// SetFontPathCookie is a cookie used only for SetFontPath requests. -type SetFontPathCookie struct { +// ListHostsCookie is a cookie used only for ListHosts requests. +type ListHostsCookie struct { *xgb.Cookie } -// SetFontPath sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -// SetFontPathChecked sends a checked request. -// If an error occurs, it can be retrieved using SetFontPathCookie.Check() -func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetFontPathCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetFontPath -// setFontPathRequest writes a SetFontPath request to a byte slice. -func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { - size := xgb.Pad((8 + StrListSize(Font))) - b := 0 - buf := make([]byte, size) - - buf[b] = 51 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], FontQty) - b += 2 - - b += 2 // padding - - b += StrListBytes(buf[b:], Font) - - return buf -} - -// GetFontPathCookie is a cookie used only for GetFontPath requests. -type GetFontPathCookie struct { - *xgb.Cookie -} - -// GetFontPath sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply() -func GetFontPath(c *xgb.Conn) GetFontPathCookie { +// ListHosts sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply() +func ListHosts(c *xgb.Conn) ListHostsCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} } -// GetFontPathUnchecked sends an unchecked request. +// ListHostsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { +func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} } -// GetFontPathReply represents the data returned from a GetFontPath request. -type GetFontPathReply struct { +// ListHostsReply represents the data returned from a ListHosts request. +type ListHostsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - // padding: 1 bytes - PathLen uint16 + Mode byte + HostsLen uint16 // padding: 22 bytes - Path []Str // size: StrListSize(Path) + Hosts []Host // size: HostListSize(Hosts) } -// Reply blocks and returns the reply data for a GetFontPath request. -func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { +// Reply blocks and returns the reply data for a ListHosts request. +func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -10186,15 +11432,16 @@ func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { if buf == nil { return nil, nil } - return getFontPathReply(buf), nil + return listHostsReply(buf), nil } -// getFontPathReply reads a byte slice into a GetFontPathReply value. -func getFontPathReply(buf []byte) *GetFontPathReply { - v := new(GetFontPathReply) +// listHostsReply reads a byte slice into a ListHostsReply value. +func listHostsReply(buf []byte) *ListHostsReply { + v := new(ListHostsReply) b := 1 // skip reply determinant - b += 1 // padding + v.Mode = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -10202,25 +11449,25 @@ func getFontPathReply(buf []byte) *GetFontPathReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PathLen = xgb.Get16(buf[b:]) + v.HostsLen = xgb.Get16(buf[b:]) b += 2 b += 22 // padding - v.Path = make([]Str, v.PathLen) - b += StrReadList(buf[b:], v.Path) + v.Hosts = make([]Host, v.HostsLen) + b += HostReadList(buf[b:], v.Hosts) return v } -// Write request to wire for GetFontPath -// getFontPathRequest writes a GetFontPath request to a byte slice. -func getFontPathRequest(c *xgb.Conn) []byte { +// Write request to wire for ListHosts +// listHostsRequest writes a ListHosts request to a byte slice. +func listHostsRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 52 // request opcode + buf[b] = 110 // request opcode b += 1 b += 1 // padding @@ -10230,1761 +11477,6 @@ func getFontPathRequest(c *xgb.Conn) []byte { 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() -} - -// Write request to wire for CreatePixmap -// createPixmapRequest writes a CreatePixmap request to a byte slice. -func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 53 // request opcode - b += 1 - - buf[b] = Depth - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Pid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - return buf -} - -// FreePixmapCookie is a cookie used only for FreePixmap requests. -type FreePixmapCookie struct { - *xgb.Cookie -} - -// FreePixmap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} -} - -// FreePixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using FreePixmapCookie.Check() -func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreePixmapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FreePixmap -// freePixmapRequest writes a FreePixmap request to a byte slice. -func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 54 // request opcode - b += 1 - - 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 { - *xgb.Cookie -} - -// CreateGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} -} - -// CreateGCChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateGCCookie.Check() -func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateGCCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateGC -// createGCRequest writes a CreateGC request to a byte slice. -func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 55 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - 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 -} - -// ChangeGCCookie is a cookie used only for ChangeGC requests. -type ChangeGCCookie struct { - *xgb.Cookie -} - -// ChangeGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} -} - -// ChangeGCChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeGCCookie.Check() -func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeGCCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ChangeGC -// changeGCRequest writes a ChangeGC request to a byte slice. -func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 56 // 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(Gc)) - 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 -} - -// CopyGCCookie is a cookie used only for CopyGC requests. -type CopyGCCookie struct { - *xgb.Cookie -} - -// CopyGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -// CopyGCChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyGCCookie.Check() -func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyGCCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CopyGC -// copyGCRequest writes a CopyGC request to a byte slice. -func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 57 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(SrcGc)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstGc)) - b += 4 - - xgb.Put32(buf[b:], ValueMask) - b += 4 - - return buf -} - -// SetDashesCookie is a cookie used only for SetDashes requests. -type SetDashesCookie struct { - *xgb.Cookie -} - -// SetDashes 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for SetDashes -// setDashesRequest writes a SetDashes request to a byte slice. -func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { - size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 58 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], DashOffset) - b += 2 - - xgb.Put16(buf[b:], DashesLen) - b += 2 - - copy(buf[b:], Dashes[:DashesLen]) - b += xgb.Pad(int(DashesLen)) - - return buf -} - -// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. -type SetClipRectanglesCookie struct { - *xgb.Cookie -} - -// SetClipRectangles sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} -} - -// SetClipRectanglesChecked sends a checked request. -// If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() -func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetClipRectanglesCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetClipRectangles -// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. -func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 59 // request opcode - b += 1 - - buf[b] = Ordering - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Gc)) - 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 { - *xgb.Cookie -} - -// FreeGC sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeGCRequest(c, Gc), cookie) - return FreeGCCookie{cookie} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 60 // 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(Gc)) - b += 4 - - return buf -} - -// ClearAreaCookie is a cookie used only for ClearArea requests. -type ClearAreaCookie struct { - *xgb.Cookie -} - -// ClearArea sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} -} - -// ClearAreaChecked sends a checked request. -// If an error occurs, it can be retrieved using ClearAreaCookie.Check() -func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ClearAreaCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ClearArea -// clearAreaRequest writes a ClearArea request to a byte slice. -func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 61 // request opcode - b += 1 - - if Exposures { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - return buf -} - -// CopyAreaCookie is a cookie used only for CopyArea requests. -type CopyAreaCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// Write request to wire for CopyArea -// copyAreaRequest writes a CopyArea request to a byte slice. -func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = 62 // request opcode - b += 1 - - b += 1 // padding - - 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)) - b += 2 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - return buf -} - -// CopyPlaneCookie is a cookie used only for CopyPlane requests. -type CopyPlaneCookie struct { - *xgb.Cookie -} - -// CopyPlane sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} -} - -// CopyPlaneChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyPlaneCookie.Check() -func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyPlaneCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CopyPlane -// copyPlaneRequest writes a CopyPlane request to a byte slice. -func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = 63 // request opcode - b += 1 - - b += 1 // padding - - 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)) - b += 2 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - xgb.Put32(buf[b:], BitPlane) - b += 4 - - return buf -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 64 // request opcode - b += 1 - - 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// PolyLineCookie is a cookie used only for PolyLine requests. -type PolyLineCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 65 // request opcode - b += 1 - - 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// PolySegmentCookie is a cookie used only for PolySegment requests. -type PolySegmentCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += SegmentListBytes(buf[b:], Segments) - - return buf -} - -// PolyRectangleCookie is a cookie used only for PolyRectangle requests. -type PolyRectangleCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyRectangleCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for 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] = 67 // 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// PolyArcCookie is a cookie used only for PolyArc requests. -type PolyArcCookie 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 68 // 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// FillPolyCookie is a cookie used only for FillPoly requests. -type FillPolyCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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 FillPoly -// fillPolyRequest writes a FillPoly request to a byte slice. -func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 69 // request opcode - b += 1 - - b += 1 // padding - - 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 - - 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 { - *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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 70 // 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// PolyFillArcCookie is a cookie used only for PolyFillArc requests. -type PolyFillArcCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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] = 71 // 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { - *xgb.Cookie -} - -// 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] = 72 // request opcode - b += 1 - - 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(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstY)) - b += 2 - - buf[b] = LeftPad - b += 1 - - buf[b] = Depth - b += 1 - - b += 2 // padding - - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) - - return buf -} - -// GetImageCookie is a cookie used only for GetImage requests. -type GetImageCookie 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. -// 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)) -} - -// 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 -} - -// 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 -} - -// 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] = 73 // request opcode - b += 1 - - 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(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) - b += 4 - - return buf -} - -// PolyText8Cookie is a cookie used only for PolyText8 requests. -type PolyText8Cookie struct { - *xgb.Cookie -} - -// PolyText8 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyText8Cookie) 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 74 // 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(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 { - *xgb.Cookie -} - -// PolyText16 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 75 // 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(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 -} - -// ImageText8Cookie is a cookie used only for ImageText8 requests. -type ImageText8Cookie struct { - *xgb.Cookie -} - -// ImageText8 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{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 { - cookie := c.NewCookie(true, false) - 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 ImageText8Cookie) 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 76 // request opcode - b += 1 - - buf[b] = StringLen - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], String[:StringLen]) - b += xgb.Pad(int(StringLen)) - - return buf -} - -// ImageText16Cookie is a cookie used only for ImageText16 requests. -type ImageText16Cookie struct { - *xgb.Cookie -} - -// ImageText16 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{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 { - cookie := c.NewCookie(true, false) - 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 ImageText16Cookie) 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 77 // request opcode - b += 1 - - buf[b] = StringLen - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - b += Char2bListBytes(buf[b:], String) - - return buf -} - -// CreateColormapCookie is a cookie used only for CreateColormap requests. -type CreateColormapCookie struct { - *xgb.Cookie -} - -// CreateColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} -} - -// CreateColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateColormapCookie.Check() -func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateColormapCookie) Check() error { - return cook.Cookie.Check() -} - -// 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] = 78 // request opcode - b += 1 - - 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 -} - -// FreeColormapCookie is a cookie used only for FreeColormap requests. -type FreeColormapCookie struct { - *xgb.Cookie -} - -// FreeColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{cookie} -} - -// FreeColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeColormapCookie.Check() -func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeColormapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for FreeColormap -// freeColormapRequest writes a FreeColormap request to a byte slice. -func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 79 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. -type CopyColormapAndFreeCookie struct { - *xgb.Cookie -} - -// CopyColormapAndFree sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} -} - -// CopyColormapAndFreeChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() -func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyColormapAndFreeCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CopyColormapAndFree -// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. -func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 80 // 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(Mid)) - b += 4 - - xgb.Put32(buf[b:], uint32(SrcCmap)) - b += 4 - - return buf -} - -// InstallColormapCookie is a cookie used only for InstallColormap requests. -type InstallColormapCookie struct { - *xgb.Cookie -} - -// InstallColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} -} - -// InstallColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using InstallColormapCookie.Check() -func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook InstallColormapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for InstallColormap -// installColormapRequest writes a InstallColormap request to a byte slice. -func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 81 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// UninstallColormapCookie is a cookie used only for UninstallColormap requests. -type UninstallColormapCookie struct { - *xgb.Cookie -} - -// UninstallColormap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -// UninstallColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using UninstallColormapCookie.Check() -func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UninstallColormapCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for UninstallColormap -// uninstallColormapRequest writes a UninstallColormap request to a byte slice. -func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 82 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - // ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. type ListInstalledColormapsCookie struct { *xgb.Cookie @@ -12077,41 +11569,39 @@ func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { return buf } -// AllocColorCookie is a cookie used only for AllocColor requests. -type AllocColorCookie struct { +// ListPropertiesCookie is a cookie used only for ListProperties requests. +type ListPropertiesCookie 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 { +// 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(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// AllocColorUnchecked 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 AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { +func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// AllocColorReply represents the data returned from a AllocColor request. -type AllocColorReply 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 - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes - Pixel uint32 + AtomsLen uint16 + // padding: 22 bytes + Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) } -// Reply blocks and returns the reply data for a AllocColor request. -func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { +// Reply blocks and returns the reply data for a ListProperties request. +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12119,12 +11609,12 @@ func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { if buf == nil { return nil, nil } - return allocColorReply(buf), nil + return listPropertiesReply(buf), nil } -// allocColorReply reads a byte slice into a AllocColorReply value. -func allocColorReply(buf []byte) *AllocColorReply { - v := new(AllocColorReply) +// 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 @@ -12135,31 +11625,29 @@ func allocColorReply(buf []byte) *AllocColorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Red = xgb.Get16(buf[b:]) + v.AtomsLen = xgb.Get16(buf[b:]) b += 2 - v.Green = xgb.Get16(buf[b:]) - b += 2 + b += 22 // padding - v.Blue = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Pixel = xgb.Get32(buf[b:]) - b += 4 + 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 } -// Write request to wire for AllocColor -// allocColorRequest writes a AllocColor request to a byte slice. -func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { - size := 16 +// Write request to wire for 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] = 84 // request opcode + buf[b] = 21 // request opcode b += 1 b += 1 // padding @@ -12167,50 +11655,38 @@ func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blu xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Window)) 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 } -// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. -type AllocNamedColorCookie struct { +// LookupColorCookie is a cookie used only for LookupColor requests. +type LookupColorCookie 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 { +// 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(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} } -// AllocNamedColorUnchecked sends an unchecked request. +// LookupColorUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { +func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} } -// AllocNamedColorReply represents the data returned from a AllocNamedColor request. -type AllocNamedColorReply struct { +// 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 - Pixel uint32 ExactRed uint16 ExactGreen uint16 ExactBlue uint16 @@ -12219,8 +11695,8 @@ type AllocNamedColorReply struct { VisualBlue 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 LookupColor request. +func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12228,12 +11704,12 @@ func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { if buf == nil { return nil, nil } - return allocNamedColorReply(buf), nil + return lookupColorReply(buf), nil } -// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. -func allocNamedColorReply(buf []byte) *AllocNamedColorReply { - v := new(AllocNamedColorReply) +// 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 @@ -12244,9 +11720,6 @@ 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 @@ -12268,14 +11741,14 @@ func allocNamedColorReply(buf []byte) *AllocNamedColorReply { 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 { +// 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] = 85 // request opcode + buf[b] = 92 // request opcode b += 1 b += 1 // padding @@ -12297,280 +11770,937 @@ func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name str return buf } -// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. -type AllocColorCellsCookie struct { +// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. +type MapSubwindowsCookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} -} - -// AllocColorCellsUnchecked 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 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)) -} - -// 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 -} - -// 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.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.PixelsLen = xgb.Get16(buf[b:]) - b += 2 - - v.MasksLen = xgb.Get16(buf[b:]) - b += 2 - - b += 20 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - v.Masks = make([]uint32, v.MasksLen) - for i := 0; i < int(v.MasksLen); i++ { - v.Masks[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = 86 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put16(buf[b:], Colors) - b += 2 - - xgb.Put16(buf[b:], Planes) - b += 2 - - return buf -} - -// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. -type AllocColorPlanesCookie struct { - *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 { - cookie := c.NewCookie(true, true) - c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} -} - -// 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} -} - -// 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)) -} - -// 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 -} - -// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. -func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { - v := new(AllocColorPlanesReply) - 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.PixelsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.RedMask = xgb.Get32(buf[b:]) - b += 4 - - v.GreenMask = xgb.Get32(buf[b:]) - b += 4 - - v.BlueMask = xgb.Get32(buf[b:]) - b += 4 - - b += 8 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for AllocColorPlanes -// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. -func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 87 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put16(buf[b:], Colors) - b += 2 - - xgb.Put16(buf[b:], Reds) - b += 2 - - xgb.Put16(buf[b:], Greens) - b += 2 - - xgb.Put16(buf[b:], Blues) - b += 2 - - return buf -} - -// FreeColorsCookie is a cookie used only for FreeColors requests. -type FreeColorsCookie struct { - *xgb.Cookie -} - -// FreeColors sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { +func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { cookie := c.NewCookie(false, false) - c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{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 { +// 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(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{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 FreeColorsCookie) Check() error { +func (cook MapSubwindowsCookie) 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)))) +// 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] = 88 // request opcode + buf[b] = 9 // 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 +} + +// MapWindowCookie is a cookie used only for MapWindow requests. +type MapWindowCookie struct { + *xgb.Cookie +} + +// MapWindow 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook MapWindowCookie) 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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 8 // 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 +} + +// NoOperationCookie is a cookie used only for NoOperation requests. +type NoOperationCookie struct { + *xgb.Cookie +} + +// NoOperation sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func NoOperation(c *xgb.Conn) NoOperationCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} +} + +// NoOperationChecked sends a checked request. +// If an error occurs, it can be retrieved using NoOperationCookie.Check() +func NoOperationChecked(c *xgb.Conn) NoOperationCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook NoOperationCookie) Check() error { + return cook.Cookie.Check() +} + +// 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] = 127 // 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 +} + +// OpenFontCookie is a cookie used only for OpenFont requests. +type OpenFontCookie 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 45 // 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(Fid)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// PolyArcCookie is a cookie used only for PolyArc requests. +type PolyArcCookie 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 68 // 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += ArcListBytes(buf[b:], Arcs) + + return buf +} + +// PolyFillArcCookie is a cookie used only for PolyFillArc requests. +type PolyFillArcCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 71 // 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += ArcListBytes(buf[b:], Arcs) + + return buf +} + +// PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests. +type PolyFillRectangleCookie 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 70 // 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// PolyLineCookie is a cookie used only for PolyLine requests. +type PolyLineCookie 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 65 // request opcode + b += 1 + + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += PointListBytes(buf[b:], Points) + + 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 64 // request opcode + b += 1 + + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// PolyRectangleCookie is a cookie used only for PolyRectangle requests. +type PolyRectangleCookie struct { + *xgb.Cookie +} + +// 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} +} + +// 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} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PolyRectangleCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for 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] = 67 // 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// PolySegmentCookie is a cookie used only for PolySegment requests. +type PolySegmentCookie 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += SegmentListBytes(buf[b:], Segments) + + return buf +} + +// PolyText16Cookie is a cookie used only for PolyText16 requests. +type PolyText16Cookie struct { + *xgb.Cookie +} + +// PolyText16 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 75 // 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(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 +} + +// PolyText8Cookie is a cookie used only for PolyText8 requests. +type PolyText8Cookie struct { + *xgb.Cookie +} + +// PolyText8 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PolyText8Cookie) 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)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 74 // 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(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 +} + +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { + *xgb.Cookie +} + +// 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] = 72 // request opcode + b += 1 + + 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(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + buf[b] = LeftPad + b += 1 + + buf[b] = Depth + b += 1 + + b += 2 // padding + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. +type QueryBestSizeCookie 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. +// 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 +} + +// 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 +} + +// 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 +} + +// 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] = 97 // request opcode + b += 1 + + 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(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// QueryColorsCookie is a cookie used only for QueryColors requests. +type QueryColorsCookie 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 { + cookie := c.NewCookie(true, true) + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} +} + +// QueryColorsUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} +} + +// QueryColorsReply represents the data returned from a QueryColors request. +type QueryColorsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ColorsLen uint16 + // padding: 22 bytes + Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) +} + +// 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 + } + if buf == nil { + return nil, nil + } + return queryColorsReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + 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) + + 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)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 91 // request opcode b += 1 b += 1 // padding @@ -12581,9 +12711,6 @@ func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []ui xgb.Put32(buf[b:], uint32(Cmap)) b += 4 - xgb.Put32(buf[b:], PlaneMask) - b += 4 - for i := 0; i < int(len(Pixels)); i++ { xgb.Put32(buf[b:], Pixels[i]) b += 4 @@ -12593,6 +12720,1481 @@ func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []ui return buf } +// QueryExtensionCookie is a cookie used only for QueryExtension requests. +type QueryExtensionCookie 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. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} +} + +// QueryExtensionReply represents the data returned from a QueryExtension request. +type QueryExtensionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Present bool + MajorOpcode byte + FirstEvent byte + FirstError byte +} + +// 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 +} + +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 + + v.MajorOpcode = buf[b] + b += 1 + + v.FirstEvent = buf[b] + b += 1 + + v.FirstError = buf[b] + b += 1 + + return v +} + +// 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] = 98 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// QueryFontCookie is a cookie used only for QueryFont requests. +type QueryFontCookie 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 { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{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} +} + +// 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)) +} + +// 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 +} + +// 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 + + 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 // 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.CharInfosLen = xgb.Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) + + v.CharInfos = make([]Charinfo, v.CharInfosLen) + b += CharinfoReadList(buf[b:], v.CharInfos) + + return v +} + +// Write request to wire for 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] = 47 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + return buf +} + +// QueryKeymapCookie is a cookie used only for QueryKeymap requests. +type QueryKeymapCookie 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 { + cookie := c.NewCookie(true, true) + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} +} + +// QueryKeymapUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} +} + +// 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 + Keys []byte // size: 32 +} + +// 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 + } + if buf == nil { + return nil, nil + } + return queryKeymapReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v +} + +// Write request to wire for QueryKeymap +// queryKeymapRequest writes a QueryKeymap request to a byte slice. +func queryKeymapRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 44 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// QueryPointerCookie is a cookie used only for QueryPointer requests. +type QueryPointerCookie 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 { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} +} + +// QueryPointerUnchecked 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 { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{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 +} + +// 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 + } + if buf == nil { + return nil, nil + } + return queryPointerReply(buf), nil +} + +// queryPointerReply reads a byte slice into a QueryPointerReply value. +func queryPointerReply(buf []byte) *QueryPointerReply { + v := new(QueryPointerReply) + 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.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 += 2 // padding + + 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 + b := 0 + buf := make([]byte, size) + + buf[b] = 38 // 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 +} + +// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. +type QueryTextExtentsCookie 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. +// 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} +} + +// QueryTextExtentsReply represents the data returned from a QueryTextExtents request. +type QueryTextExtentsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + DrawDirection byte + FontAscent int16 + FontDescent int16 + OverallAscent int16 + OverallDescent int16 + OverallWidth int32 + OverallLeft int32 + OverallRight int32 +} + +// Reply blocks and returns the reply data for a 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 +} + +// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. +func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { + v := new(QueryTextExtentsReply) + b := 1 // skip reply determinant + + v.DrawDirection = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallWidth = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallLeft = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallRight = int32(xgb.Get32(buf[b:])) + 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 + b += 1 + + 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(Font)) + b += 4 + + b += Char2bListBytes(buf[b:], String) + + // skip writing local field: StringLen (2) :: uint16 + + return buf +} + +// QueryTreeCookie is a cookie used only for QueryTree requests. +type QueryTreeCookie 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. +// 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 + + 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 +} + +// 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] = 15 // 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 +} + +// RecolorCursorCookie is a cookie used only for RecolorCursor requests. +type RecolorCursorCookie struct { + *xgb.Cookie +} + +// RecolorCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{cookie} +} + +// RecolorCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using RecolorCursorCookie.Check() +func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook RecolorCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RecolorCursor +// recolorCursorRequest writes a RecolorCursor request to a byte slice. +func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = 96 // 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(Cursor)) + 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 + + return buf +} + +// ReparentWindowCookie is a cookie used only for ReparentWindow requests. +type ReparentWindowCookie struct { + *xgb.Cookie +} + +// ReparentWindow 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} +} + +// 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} +} + +// Check returns an error if one occurred 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 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] = 7 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + return buf +} + +// RotatePropertiesCookie is a cookie used only for RotateProperties requests. +type RotatePropertiesCookie struct { + *xgb.Cookie +} + +// RotateProperties 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook RotatePropertiesCookie) 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)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 114 // 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 + + 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 +} + +// SendEventCookie is a cookie used only for SendEvent requests. +type SendEventCookie struct { + *xgb.Cookie +} + +// 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} +} + +// Check returns an error if one occurred 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 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] = 25 // request opcode + b += 1 + + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + copy(buf[b:], Event[:32]) + b += xgb.Pad(int(32)) + + 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) + + buf[b] = 111 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. +type SetClipRectanglesCookie struct { + *xgb.Cookie +} + +// SetClipRectangles sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} +} + +// SetClipRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() +func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetClipRectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClipRectangles +// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. +func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 59 // request opcode + b += 1 + + buf[b] = Ordering + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + 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 +} + +// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. +type SetCloseDownModeCookie struct { + *xgb.Cookie +} + +// SetCloseDownMode 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 112 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// SetDashesCookie is a cookie used only for SetDashes requests. +type SetDashesCookie struct { + *xgb.Cookie +} + +// SetDashes 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// Write request to wire for SetDashes +// setDashesRequest writes a SetDashes request to a byte slice. +func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 58 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], DashOffset) + b += 2 + + xgb.Put16(buf[b:], DashesLen) + b += 2 + + copy(buf[b:], Dashes[:DashesLen]) + b += xgb.Pad(int(DashesLen)) + + return buf +} + +// SetFontPathCookie is a cookie used only for SetFontPath requests. +type SetFontPathCookie struct { + *xgb.Cookie +} + +// SetFontPath sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} +} + +// SetFontPathChecked sends a checked request. +// If an error occurs, it can be retrieved using SetFontPathCookie.Check() +func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetFontPathCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetFontPath +// setFontPathRequest writes a SetFontPath request to a byte slice. +func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { + size := xgb.Pad((8 + StrListSize(Font))) + b := 0 + buf := make([]byte, size) + + buf[b] = 51 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], FontQty) + b += 2 + + b += 2 // padding + + b += StrListBytes(buf[b:], Font) + + return buf +} + +// SetInputFocusCookie is a cookie used only for SetInputFocus requests. +type SetInputFocusCookie 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} +} + +// 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} +} + +// Check returns an error if one occurred 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() +} + +// 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] = 42 // request opcode + b += 1 + + 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 +} + +// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. +type SetModifierMappingCookie 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. +// 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 +} + +// 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 +} + +// 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 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] = 118 // request opcode + b += 1 + + buf[b] = KeycodesPerModifier + b += 1 + + 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) + + return buf +} + +// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. +type SetPointerMappingCookie 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. +// 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 +} + +// 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 +} + +// 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 +} + +// 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] = 116 // request opcode + b += 1 + + buf[b] = MapLen + b += 1 + + 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 +} + +// SetScreenSaverCookie is a cookie used only for SetScreenSaver requests. +type SetScreenSaverCookie struct { + *xgb.Cookie +} + +// SetScreenSaver sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetScreenSaver(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) + return SetScreenSaverCookie{cookie} +} + +// SetScreenSaverChecked sends a checked request. +// If an error occurs, it can be retrieved using SetScreenSaverCookie.Check() +func SetScreenSaverChecked(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) + return SetScreenSaverCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetScreenSaverCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetScreenSaver +// setScreenSaverRequest writes a SetScreenSaver request to a byte slice. +func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 107 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], uint16(Timeout)) + b += 2 + + xgb.Put16(buf[b:], uint16(Interval)) + b += 2 + + buf[b] = PreferBlanking + b += 1 + + buf[b] = AllowExposures + b += 1 + + return buf +} + +// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. +type SetSelectionOwnerCookie struct { + *xgb.Cookie +} + +// SetSelectionOwner 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} +} + +// Check returns an error if one occurred 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() +} + +// 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 + + 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)) + b += 4 + + return buf +} + // StoreColorsCookie is a cookie used only for StoreColors requests. type StoreColorsCookie struct { *xgb.Cookie @@ -12703,39 +14305,39 @@ func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32 return buf } -// QueryColorsCookie is a cookie used only for QueryColors requests. -type QueryColorsCookie struct { +// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. +type TranslateCoordinatesCookie 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 { +// 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(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} } -// QueryColorsUnchecked 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 QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { +func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} } -// QueryColorsReply represents the data returned from a QueryColors request. -type QueryColorsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ColorsLen uint16 - // padding: 22 bytes - Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) +// 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 QueryColors request. -func (cook QueryColorsCookie) Reply() (*QueryColorsReply, 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 @@ -12743,850 +14345,47 @@ func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { if buf == nil { return nil, nil } - return queryColorsReply(buf), nil + return translateCoordinatesReply(buf), nil } -// queryColorsReply reads a byte slice into a QueryColorsReply value. -func queryColorsReply(buf []byte) *QueryColorsReply { - v := new(QueryColorsReply) +// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. +func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { + v := new(TranslateCoordinatesReply) 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.ColorsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Colors = make([]Rgb, v.ColorsLen) - b += RgbReadList(buf[b:], v.Colors) - - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 91 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - 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 { - *xgb.Cookie -} - -// LookupColor sends a checked request. -// If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply() -func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} -} - -// 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} -} - -// 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 -} - -// 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 -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.ExactRed = xgb.Get16(buf[b:]) - b += 2 - - v.ExactGreen = xgb.Get16(buf[b:]) - b += 2 - - v.ExactBlue = xgb.Get16(buf[b:]) - b += 2 - - v.VisualRed = xgb.Get16(buf[b:]) - b += 2 - - v.VisualGreen = xgb.Get16(buf[b:]) - b += 2 - - v.VisualBlue = xgb.Get16(buf[b:]) - b += 2 - - 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 92 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put16(buf[b:], 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 { - *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 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mask)) - 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 -} - -// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. -type CreateGlyphCursorCookie struct { - *xgb.Cookie -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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 - - xgb.Put16(buf[b:], ForeGreen) - b += 2 - - xgb.Put16(buf[b:], ForeBlue) - b += 2 - - xgb.Put16(buf[b:], BackRed) - b += 2 - - xgb.Put16(buf[b:], BackGreen) - b += 2 - - xgb.Put16(buf[b:], BackBlue) - b += 2 - - return buf -} - -// 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] = 95 // 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(Cursor)) - b += 4 - - return buf -} - -// RecolorCursorCookie is a cookie used only for RecolorCursor requests. -type RecolorCursorCookie struct { - *xgb.Cookie -} - -// RecolorCursor sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} -} - -// RecolorCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using RecolorCursorCookie.Check() -func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook RecolorCursorCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for RecolorCursor -// recolorCursorRequest writes a RecolorCursor request to a byte slice. -func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = 96 // 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(Cursor)) - 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 - - return buf -} - -// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. -type QueryBestSizeCookie 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. -// 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 -} - -// 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 -} - -// 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 -} - -// 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] = 97 // request opcode - b += 1 - - 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(Drawable)) - b += 4 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - return buf -} - -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { - *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. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -// QueryExtensionReply represents the data returned from a QueryExtension request. -type QueryExtensionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Present bool - MajorOpcode byte - FirstEvent byte - FirstError byte -} - -// 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 -} - -// queryExtensionReply reads a byte slice into a QueryExtensionReply value. -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - if buf[b] == 1 { - v.Present = true + v.SameScreen = true } else { - v.Present = false + v.SameScreen = false } b += 1 - v.MajorOpcode = buf[b] - b += 1 - - v.FirstEvent = buf[b] - b += 1 - - v.FirstError = buf[b] - b += 1 - - return v -} - -// 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] = 98 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - - return buf -} - -// ListExtensionsCookie is a cookie used only for ListExtensions requests. -type ListExtensionsCookie 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. -// 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) -} - -// 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 -} - -// 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 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] = 99 // 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 -} - -// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. -type ChangeKeyboardMappingCookie struct { - *xgb.Cookie -} - -// ChangeKeyboardMapping sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} -} - -// ChangeKeyboardMappingChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() -func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeKeyboardMappingCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ChangeKeyboardMapping -// changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice. -func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { - size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 100 // request opcode - b += 1 - - buf[b] = KeycodeCount - 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] = KeysymsPerKeycode - b += 1 - - b += 2 // padding - - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - xgb.Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. -type GetKeyboardMappingCookie 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. -// 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)) -} - -// 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 -} - -// 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 + v.Child = Window(xgb.Get32(buf[b:])) b += 4 - b += 24 // padding + v.DstX = int16(xgb.Get16(buf[b:])) + b += 2 - 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) + v.DstY = int16(xgb.Get16(buf[b:])) + b += 2 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 +// 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] = 101 // request opcode + buf[b] = 40 // request opcode b += 1 b += 1 // padding @@ -13594,790 +14393,164 @@ func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) [] xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = byte(FirstKeycode) - b += 1 + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 - buf[b] = Count - b += 1 + 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 } -// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. -type ChangeKeyboardControlCookie struct { +// UngrabButtonCookie is a cookie used only for UngrabButton requests. +type UngrabButtonCookie struct { *xgb.Cookie } -// ChangeKeyboardControl 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 ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { +func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{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 { +// 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(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{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 ChangeKeyboardControlCookie) Check() error { +func (cook UngrabButtonCookie) 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 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) - - return buf -} - -// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. -type GetKeyboardControlCookie struct { - *xgb.Cookie -} - -// GetKeyboardControl sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() -func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getKeyboardControlRequest(c), cookie) - return GetKeyboardControlCookie{cookie} -} - -// GetKeyboardControlUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getKeyboardControlRequest(c), cookie) - return GetKeyboardControlCookie{cookie} -} - -// GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. -type GetKeyboardControlReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - GlobalAutoRepeat byte - LedMask uint32 - KeyClickPercent byte - BellPercent byte - BellPitch uint16 - BellDuration uint16 - // padding: 2 bytes - AutoRepeats []byte // size: 32 -} - -// Reply blocks and returns the reply data for a GetKeyboardControl request. -func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardControlReply(buf), nil -} - -// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. -func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { - v := new(GetKeyboardControlReply) - b := 1 // skip reply determinant - - v.GlobalAutoRepeat = buf[b] - b += 1 - - 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 - - v.KeyClickPercent = buf[b] - b += 1 - - v.BellPercent = buf[b] - b += 1 - - v.BellPitch = xgb.Get16(buf[b:]) - b += 2 - - v.BellDuration = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += xgb.Pad(int(32)) - - return v -} - -// Write request to wire for GetKeyboardControl -// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. -func getKeyboardControlRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 103 // request opcode - b += 1 - - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// BellCookie is a cookie used only for Bell requests. -type BellCookie struct { - *xgb.Cookie -} - -// Bell sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Bell(c *xgb.Conn, Percent int8) BellCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(bellRequest(c, Percent), cookie) - return BellCookie{cookie} -} - -// BellChecked sends a checked request. -// If an error occurs, it can be retrieved using BellCookie.Check() -func BellChecked(c *xgb.Conn, Percent int8) BellCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(bellRequest(c, Percent), cookie) - return BellCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook BellCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for Bell -// bellRequest writes a Bell request to a byte slice. -func bellRequest(c *xgb.Conn, Percent int8) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 104 // request opcode - b += 1 - - buf[b] = byte(Percent) - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. -type ChangePointerControlCookie struct { - *xgb.Cookie -} - -// ChangePointerControl sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} -} - -// ChangePointerControlChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangePointerControlCookie.Check() -func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangePointerControlCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for ChangePointerControl -// changePointerControlRequest writes a ChangePointerControl request to a byte slice. -func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { +// 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] = 105 // request opcode + buf[b] = 29 // request opcode b += 1 - b += 1 // padding + buf[b] = Button + 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 - } - b += 1 - - return buf -} - -// GetPointerControlCookie is a cookie used only for GetPointerControl requests. -type GetPointerControlCookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(getPointerControlRequest(c), cookie) - return GetPointerControlCookie{cookie} -} - -// GetPointerControlUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getPointerControlRequest(c), cookie) - return GetPointerControlCookie{cookie} -} - -// 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 GetPointerControl request. -func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPointerControlReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - v.AccelerationNumerator = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Modifiers) 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 - 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 + b += 2 // padding return buf } -// SetScreenSaverCookie is a cookie used only for SetScreenSaver requests. -type SetScreenSaverCookie struct { +// UngrabKeyCookie is a cookie used only for UngrabKey requests. +type UngrabKeyCookie struct { *xgb.Cookie } -// SetScreenSaver 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 SetScreenSaver(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { +func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) - return SetScreenSaverCookie{cookie} + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} } -// SetScreenSaverChecked sends a checked request. -// If an error occurs, it can be retrieved using SetScreenSaverCookie.Check() -func SetScreenSaverChecked(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { +// 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(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) - return SetScreenSaverCookie{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 SetScreenSaverCookie) Check() error { +func (cook UngrabKeyCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetScreenSaver -// setScreenSaverRequest writes a SetScreenSaver request to a byte slice. -func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { +// 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] = 107 // 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.Put16(buf[b:], uint16(Timeout)) - b += 2 - - xgb.Put16(buf[b:], uint16(Interval)) - b += 2 - - buf[b] = PreferBlanking - b += 1 - - buf[b] = AllowExposures - b += 1 - - return buf -} - -// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. -type GetScreenSaverCookie 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. -// 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} -} - -// 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 -} - -// 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 -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 - v.Timeout = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Modifiers) 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 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] = 108 // request opcode - b += 1 - - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + b += 2 // padding return buf } -// ChangeHostsCookie is a cookie used only for ChangeHosts requests. -type ChangeHostsCookie struct { +// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. +type UngrabKeyboardCookie struct { *xgb.Cookie } -// ChangeHosts 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 ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { +func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{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 { +// 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(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{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 ChangeHostsCookie) Check() error { +func (cook UngrabKeyboardCookie) 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)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 109 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Family - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], AddressLen) - b += 2 - - copy(buf[b:], Address[:AddressLen]) - b += xgb.Pad(int(AddressLen)) - - return buf -} - -// ListHostsCookie is a cookie used only for ListHosts requests. -type ListHostsCookie 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 { - cookie := c.NewCookie(true, true) - c.NewRequest(listHostsRequest(c), cookie) - return ListHostsCookie{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} -} - -// 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) -} - -// 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 -} - -// listHostsReply reads a byte slice into a ListHostsReply value. -func listHostsReply(buf []byte) *ListHostsReply { - v := new(ListHostsReply) - b := 1 // skip reply determinant - - v.Mode = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.HostsLen = xgb.Get16(buf[b:]) - b += 2 - - 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 -} - -// 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) - - buf[b] = 111 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. -type SetCloseDownModeCookie struct { - *xgb.Cookie -} - -// SetCloseDownMode 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 { - cookie := c.NewCookie(false, false) - c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{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 { - cookie := c.NewCookie(true, false) - c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{cookie} -} - -// Check returns an error if one occurred 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 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] = 112 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// KillClientCookie is a cookie used only for KillClient requests. -type KillClientCookie struct { - *xgb.Cookie -} - -// KillClient sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(killClientRequest(c, Resource), cookie) - return KillClientCookie{cookie} -} - -// KillClientChecked sends a checked request. -// If an error occurs, it can be retrieved using KillClientCookie.Check() -func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(killClientRequest(c, Resource), cookie) - return KillClientCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook KillClientCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for KillClient -// killClientRequest writes a KillClient request to a byte slice. -func killClientRequest(c *xgb.Conn, Resource uint32) []byte { +// Write request to wire for UngrabKeyboard +// ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice. +func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 113 // request opcode + buf[b] = 32 // request opcode b += 1 b += 1 // padding @@ -14385,47 +14558,187 @@ func killClientRequest(c *xgb.Conn, Resource uint32) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Resource) + xgb.Put32(buf[b:], uint32(Time)) b += 4 return buf } -// RotatePropertiesCookie is a cookie used only for RotateProperties requests. -type RotatePropertiesCookie struct { +// UngrabPointerCookie is a cookie used only for UngrabPointer requests. +type UngrabPointerCookie struct { *xgb.Cookie } -// RotateProperties sends an unchecked request. +// UngrabPointer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { +func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} } -// RotatePropertiesChecked sends a checked request. -// If an error occurs, it can be retrieved using RotatePropertiesCookie.Check() -func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { +// UngrabPointerChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPointerCookie.Check() +func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(true, false) - c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook RotatePropertiesCookie) Check() error { +func (cook UngrabPointerCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RotateProperties -// rotatePropertiesRequest writes a RotateProperties request to a byte slice. -func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { - size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) +// Write request to wire for UngrabPointer +// ungrabPointerRequest writes a UngrabPointer request to a byte slice. +func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 114 // request opcode + buf[b] = 27 // request opcode + b += 1 + + b += 1 // padding + + 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 +} + +// UngrabServerCookie is a cookie used only for UngrabServer requests. +type UngrabServerCookie struct { + *xgb.Cookie +} + +// UngrabServer 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} +} + +// 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} +} + +// Check returns an error if one occurred 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 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] = 37 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// UninstallColormapCookie is a cookie used only for UninstallColormap requests. +type UninstallColormapCookie struct { + *xgb.Cookie +} + +// UninstallColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} +} + +// UninstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using UninstallColormapCookie.Check() +func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UninstallColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UninstallColormap +// uninstallColormapRequest writes a UninstallColormap request to a byte slice. +func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 82 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. +type UnmapSubwindowsCookie struct { + *xgb.Cookie +} + +// UnmapSubwindows 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 { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{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 { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} +} + +// Check returns an error if one occurred 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 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] = 11 // request opcode b += 1 b += 1 // padding @@ -14436,435 +14749,122 @@ func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], AtomsLen) - b += 2 - - xgb.Put16(buf[b:], uint16(Delta)) - b += 2 - - for i := 0; i < int(AtomsLen); i++ { - xgb.Put32(buf[b:], uint32(Atoms[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. -type ForceScreenSaverCookie struct { +// UnmapWindowCookie is a cookie used only for UnmapWindow requests. +type UnmapWindowCookie struct { *xgb.Cookie } -// ForceScreenSaver 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 ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { +func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{cookie} + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{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 { +// 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(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{cookie} + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ForceScreenSaverCookie) Check() error { +func (cook UnmapWindowCookie) 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 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] = 115 // request opcode + buf[b] = 10 // 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 -} - -// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. -type SetPointerMappingCookie 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. -// 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 -} - -// 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 -} - -// 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 + xgb.Put32(buf[b:], uint32(Window)) b += 4 - return v -} - -// 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] = 116 // request opcode - b += 1 - - buf[b] = MapLen - b += 1 - - 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 { +// WarpPointerCookie is a cookie used only for WarpPointer requests. +type WarpPointerCookie 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. +// WarpPointer 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)) -} - -// 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 -} - -// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. -func getPointerMappingReply(buf []byte) *GetPointerMappingReply { - v := new(GetPointerMappingReply) - b := 1 // skip reply determinant - - v.MapLen = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Map = make([]byte, v.MapLen) - copy(v.Map[:v.MapLen], buf[b:]) - b += xgb.Pad(int(v.MapLen)) - - return v -} - -// Write request to wire for GetPointerMapping -// getPointerMappingRequest writes a GetPointerMapping request to a byte slice. -func getPointerMappingRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 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 -} - -// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. -type SetModifierMappingCookie 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. -// 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 -} - -// 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 -} - -// 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 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] = 118 // request opcode - b += 1 - - buf[b] = KeycodesPerModifier - b += 1 - - 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) - - return buf -} - -// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. -type GetModifierMappingCookie 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. -// 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)) -} - -// 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 -} - -// 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 -} - -// Write request to wire for GetModifierMapping -// getModifierMappingRequest writes a GetModifierMapping request to a byte slice. -func getModifierMappingRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 119 // request opcode - b += 1 - - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// NoOperationCookie is a cookie used only for NoOperation requests. -type NoOperationCookie struct { - *xgb.Cookie -} - -// NoOperation sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func NoOperation(c *xgb.Conn) NoOperationCookie { +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,188 +132,59 @@ 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 { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 -} - -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryVersionReply(buf), nil -} - -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajor = xgb.Get16(buf[b:]) - b += 2 - - v.ServerMinor = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = ClientMajor - b += 1 - - buf[b] = ClientMinor - b += 1 - - return buf -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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] = 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:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetDeviceCreateContextCookie is a cookie used only for GetDeviceCreateContext requests. -type GetDeviceCreateContextCookie struct { - *xgb.Cookie -} - -// GetDeviceCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceCreateContextCookie.Reply() -func GetDeviceCreateContext(c *xgb.Conn) GetDeviceCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceCreateContextRequest(c), cookie) - return GetDeviceCreateContextCookie{cookie} -} - -// GetDeviceCreateContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceCreateContextUnchecked(c *xgb.Conn) GetDeviceCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceCreateContextRequest(c), cookie) - return GetDeviceCreateContextCookie{cookie} -} - -// GetDeviceCreateContextReply represents the data returned from a GetDeviceCreateContext request. -type GetDeviceCreateContextReply struct { +// GetClientContextReply represents the data returned from a GetClientContext request. +type GetClientContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -346,8 +193,8 @@ type GetDeviceCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceCreateContext request. -func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetClientContext request. +func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -355,12 +202,12 @@ func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, if buf == nil { return nil, nil } - return getDeviceCreateContextReply(buf), nil + return getClientContextReply(buf), nil } -// getDeviceCreateContextReply reads a byte slice into a GetDeviceCreateContextReply value. -func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { - v := new(GetDeviceCreateContextReply) +// getClientContextReply reads a byte slice into a GetClientContextReply value. +func getClientContextReply(buf []byte) *GetClientContextReply { + v := new(GetClientContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -386,83 +233,25 @@ func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { return v } -// Write request to wire for GetDeviceCreateContext -// getDeviceCreateContextRequest writes a GetDeviceCreateContext request to a byte slice. -func getDeviceCreateContextRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GetClientContext +// getClientContextRequest writes a GetClientContext request to a byte slice. +func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 2 // 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 - return buf -} - -// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. -type SetDeviceContextCookie struct { - *xgb.Cookie -} - -// SetDeviceContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{cookie} -} - -// SetDeviceContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDeviceContextCookie.Check() -func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetDeviceContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetDeviceContext -// setDeviceContextRequest writes a SetDeviceContext request to a byte slice. -func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Device) + xgb.Put32(buf[b:], Resource) b += 4 - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } @@ -565,93 +354,35 @@ func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { return buf } -// SetWindowCreateContextCookie is a cookie used only for SetWindowCreateContext requests. -type SetWindowCreateContextCookie struct { +// GetDeviceCreateContextCookie is a cookie used only for GetDeviceCreateContext requests. +type GetDeviceCreateContextCookie 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 { +// GetDeviceCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceCreateContextCookie.Reply() +func GetDeviceCreateContext(c *xgb.Conn) GetDeviceCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) - return SetWindowCreateContextCookie{cookie} -} - -// SetWindowCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetWindowCreateContextCookie.Check() -func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) - return SetWindowCreateContextCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetWindowCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetWindowCreateContext -// setWindowCreateContextRequest writes a SetWindowCreateContext request to a byte slice. -func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. -type GetWindowCreateContextCookie struct { - *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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getWindowCreateContextRequest(c), cookie) - return GetWindowCreateContextCookie{cookie} + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} } -// GetWindowCreateContextUnchecked sends an unchecked request. +// GetDeviceCreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { +func GetDeviceCreateContextUnchecked(c *xgb.Conn) GetDeviceCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getWindowCreateContextRequest(c), cookie) - return GetWindowCreateContextCookie{cookie} + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} } -// GetWindowCreateContextReply represents the data returned from a GetWindowCreateContext request. -type GetWindowCreateContextReply struct { +// GetDeviceCreateContextReply represents the data returned from a GetDeviceCreateContext request. +type GetDeviceCreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -660,8 +391,8 @@ type GetWindowCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetWindowCreateContext request. -func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetDeviceCreateContext request. +func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -669,12 +400,12 @@ func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, if buf == nil { return nil, nil } - return getWindowCreateContextReply(buf), nil + return getDeviceCreateContextReply(buf), nil } -// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. -func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { - v := new(GetWindowCreateContextReply) +// getDeviceCreateContextReply reads a byte slice into a GetDeviceCreateContextReply value. +func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { + v := new(GetDeviceCreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -700,9 +431,9 @@ func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { return v } -// Write request to wire for GetWindowCreateContext -// getWindowCreateContextRequest writes a GetWindowCreateContext request to a byte slice. -func getWindowCreateContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetDeviceCreateContext +// getDeviceCreateContextRequest writes a GetDeviceCreateContext request to a byte slice. +func getDeviceCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -710,414 +441,7 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { 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 -} - -// GetWindowContextCookie is a cookie used only for GetWindowContext requests. -type GetWindowContextCookie 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowContext' 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} -} - -// GetWindowContextUnchecked 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowContext' 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} -} - -// 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 - ContextLen uint32 - // padding: 20 bytes - 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) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getWindowContextReply(buf), nil -} - -// 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 - - 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 GetWindowContext -// getWindowContextRequest writes a GetWindowContext request to a byte slice. -func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. -type SetPropertyCreateContextCookie struct { - *xgb.Cookie -} - -// SetPropertyCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) - return SetPropertyCreateContextCookie{cookie} -} - -// SetPropertyCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPropertyCreateContextCookie.Check() -func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) - return SetPropertyCreateContextCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetPropertyCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPropertyCreateContext -// setPropertyCreateContextRequest writes a SetPropertyCreateContext request to a byte slice. -func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyCreateContext' 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} -} - -// GetPropertyCreateContextUnchecked 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyCreateContext' 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} -} - -// 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 - ContextLen uint32 - // padding: 20 bytes - 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) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPropertyCreateContextReply(buf), nil -} - -// 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 - - 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 GetPropertyCreateContext -// getPropertyCreateContextRequest writes a GetPropertyCreateContext request to a byte slice. -func getPropertyCreateContextRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - 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 - - return buf -} - -// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. -type SetPropertyUseContextCookie struct { - *xgb.Cookie -} - -// SetPropertyUseContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) - return SetPropertyUseContextCookie{cookie} -} - -// SetPropertyUseContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPropertyUseContextCookie.Check() -func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) - return SetPropertyUseContextCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetPropertyUseContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPropertyUseContext -// setPropertyUseContextRequest writes a SetPropertyUseContext request to a byte slice. -func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetPropertyUseContextCookie is a cookie used only for GetPropertyUseContext requests. -type GetPropertyUseContextCookie 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyUseContext' 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} -} - -// GetPropertyUseContextUnchecked 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyUseContext' 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} -} - -// 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 - ContextLen uint32 - // padding: 20 bytes - 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) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPropertyUseContextReply(buf), nil -} - -// 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 - - 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 GetPropertyUseContext -// getPropertyUseContextRequest writes a GetPropertyUseContext request to a byte slice. -func getPropertyUseContextRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 11 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1228,6 +552,102 @@ func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xprot 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetPropertyCreateContext' 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} +} + +// GetPropertyCreateContextUnchecked 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetPropertyCreateContext' 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} +} + +// 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 + ContextLen uint32 + // padding: 20 bytes + 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) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyCreateContextReply(buf), nil +} + +// 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 + + 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 GetPropertyCreateContext +// getPropertyCreateContextRequest writes a GetPropertyCreateContext request to a byte slice. +func getPropertyCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + 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 + + return buf +} + // GetPropertyDataContextCookie is a cookie used only for GetPropertyDataContext requests. type GetPropertyDataContextCookie struct { *xgb.Cookie @@ -1330,188 +750,35 @@ func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property x return buf } -// ListPropertiesCookie is a cookie used only for ListProperties requests. -type ListPropertiesCookie struct { +// GetPropertyUseContextCookie is a cookie used only for GetPropertyUseContext requests. +type GetPropertyUseContextCookie 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 { +// 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 'ListProperties' 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(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} } -// ListPropertiesUnchecked 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 ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { +func GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { 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 'GetPropertyUseContext' 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(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{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 - PropertiesLen uint32 - // padding: 20 bytes - Properties []ListItem // size: ListItemListSize(Properties) -} - -// 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 -} - -// 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.PropertiesLen = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Properties = make([]ListItem, v.PropertiesLen) - b += ListItemReadList(buf[b:], v.Properties) - - 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 { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. -type SetSelectionCreateContextCookie struct { - *xgb.Cookie -} - -// SetSelectionCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{cookie} -} - -// SetSelectionCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionCreateContextCookie.Check() -func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetSelectionCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetSelectionCreateContext -// setSelectionCreateContextRequest writes a SetSelectionCreateContext request to a byte slice. -func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 15 // request opcode - 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 -} - -// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. -type GetSelectionCreateContextCookie 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionCreateContext' 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} -} - -// GetSelectionCreateContextUnchecked 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionCreateContext' 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} -} - -// GetSelectionCreateContextReply represents the data returned from a GetSelectionCreateContext request. -type GetSelectionCreateContextReply 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 @@ -1520,8 +787,8 @@ type GetSelectionCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetSelectionCreateContext request. -func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetPropertyUseContext request. +func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1529,12 +796,12 @@ func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextR if buf == nil { return nil, nil } - return getSelectionCreateContextReply(buf), nil + return getPropertyUseContextReply(buf), nil } -// getSelectionCreateContextReply reads a byte slice into a GetSelectionCreateContextReply value. -func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { - v := new(GetSelectionCreateContextReply) +// 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 @@ -1560,9 +827,9 @@ func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply return v } -// Write request to wire for GetSelectionCreateContext -// getSelectionCreateContextRequest writes a GetSelectionCreateContext request to a byte slice. -func getSelectionCreateContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetPropertyUseContext +// getPropertyUseContextRequest writes a GetPropertyUseContext request to a byte slice. +func getPropertyUseContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -1570,161 +837,7 @@ func getSelectionCreateContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 16 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// SetSelectionUseContextCookie is a cookie used only for SetSelectionUseContext requests. -type SetSelectionUseContextCookie struct { - *xgb.Cookie -} - -// SetSelectionUseContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) - return SetSelectionUseContextCookie{cookie} -} - -// SetSelectionUseContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionUseContextCookie.Check() -func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) - return SetSelectionUseContextCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetSelectionUseContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetSelectionUseContext -// setSelectionUseContextRequest writes a SetSelectionUseContext request to a byte slice. -func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. -type GetSelectionUseContextCookie struct { - *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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionUseContext' 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} -} - -// GetSelectionUseContextUnchecked 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 { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionUseContext' 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} -} - -// 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 - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) -} - -// Reply blocks and returns the reply data for a GetSelectionUseContext request. -func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectionUseContextReply(buf), nil -} - -// 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 - - 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 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] = 18 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1832,6 +945,102 @@ func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { return buf } +// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. +type GetSelectionCreateContextCookie 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetSelectionCreateContext' 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} +} + +// GetSelectionCreateContextUnchecked 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetSelectionCreateContext' 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} +} + +// 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 + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Reply blocks and returns the reply data for a GetSelectionCreateContext request. +func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionCreateContextReply(buf), nil +} + +// 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 + + 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 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 +} + // GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. type GetSelectionDataContextCookie struct { *xgb.Cookie @@ -1931,6 +1140,392 @@ func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { return buf } +// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. +type GetSelectionUseContextCookie 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetSelectionUseContext' 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} +} + +// GetSelectionUseContextUnchecked 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetSelectionUseContext' 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} +} + +// 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 + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Reply blocks and returns the reply data for a GetSelectionUseContext request. +func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionUseContextReply(buf), nil +} + +// 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 + + 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 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] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// GetWindowContextCookie is a cookie used only for GetWindowContext requests. +type GetWindowContextCookie 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetWindowContext' 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} +} + +// GetWindowContextUnchecked 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetWindowContext' 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} +} + +// 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 + ContextLen uint32 + // padding: 20 bytes + 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) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowContextReply(buf), nil +} + +// 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 + + 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 GetWindowContext +// getWindowContextRequest writes a GetWindowContext request to a byte slice. +func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. +type GetWindowCreateContextCookie 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 { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'GetWindowCreateContext' 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} +} + +// 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 'GetWindowCreateContext' 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} +} + +// 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)) +} + +// 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 +} + +// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. +func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { + v := new(GetWindowCreateContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + 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 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 +} + +// 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 'ListProperties' 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} +} + +// 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 xproto.Window) ListPropertiesCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'ListProperties' 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} +} + +// 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 + PropertiesLen uint32 + // padding: 20 bytes + Properties []ListItem // size: ListItemListSize(Properties) +} + +// 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 +} + +// 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.PropertiesLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Properties = make([]ListItem, v.PropertiesLen) + b += ListItemReadList(buf[b:], v.Properties) + + 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 { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + // ListSelectionsCookie is a cookie used only for ListSelections requests. type ListSelectionsCookie struct { *xgb.Cookie @@ -2023,45 +1618,44 @@ func listSelectionsRequest(c *xgb.Conn) []byte { return buf } -// GetClientContextCookie is a cookie used only for GetClientContext requests. -type GetClientContextCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// GetClientContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetClientContextCookie.Reply() -func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getClientContextRequest(c, Resource), cookie) - return GetClientContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetClientContextUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getClientContextRequest(c, Resource), cookie) - return GetClientContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetClientContextReply represents the data returned from a GetClientContext request. -type GetClientContextReply struct { +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) + ServerMajor uint16 + ServerMinor uint16 } -// Reply blocks and returns the reply data for a GetClientContext request. -func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2069,12 +1663,12 @@ func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { if buf == nil { return nil, nil } - return getClientContextReply(buf), nil + return queryVersionReply(buf), nil } -// getClientContextReply reads a byte slice into a GetClientContextReply value. -func getClientContextReply(buf []byte) *GetClientContextReply { - v := new(GetClientContextReply) +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) b := 1 // skip reply determinant b += 1 // padding @@ -2085,24 +1679,18 @@ func getClientContextReply(buf []byte) *GetClientContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) - b += 4 + v.ServerMajor = 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)) - } + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for GetClientContext -// getClientContextRequest writes a GetClientContext request to a byte slice. -func getClientContextRequest(c *xgb.Conn, Resource 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) @@ -2110,14 +1698,426 @@ func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 22 // 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:], Resource) - b += 4 + buf[b] = ClientMajor + b += 1 + + buf[b] = ClientMinor + b += 1 + + return buf +} + +// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. +type SetDeviceContextCookie struct { + *xgb.Cookie +} + +// SetDeviceContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} +} + +// SetDeviceContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceContextCookie.Check() +func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetDeviceContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceContext +// setDeviceContextRequest writes a SetDeviceContext request to a byte slice. +func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Device) + b += 4 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetDeviceCreateContextCookie is a cookie used only for SetDeviceCreateContext requests. +type SetDeviceCreateContextCookie struct { + *xgb.Cookie +} + +// SetDeviceCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} +} + +// 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} +} + +// Check returns an error if one occurred 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] = 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:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. +type SetPropertyCreateContextCookie struct { + *xgb.Cookie +} + +// SetPropertyCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} +} + +// SetPropertyCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyCreateContextCookie.Check() +func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetPropertyCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyCreateContext +// setPropertyCreateContextRequest writes a SetPropertyCreateContext request to a byte slice. +func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. +type SetPropertyUseContextCookie struct { + *xgb.Cookie +} + +// SetPropertyUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} +} + +// SetPropertyUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyUseContextCookie.Check() +func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetPropertyUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyUseContext +// setPropertyUseContextRequest writes a SetPropertyUseContext request to a byte slice. +func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. +type SetSelectionCreateContextCookie struct { + *xgb.Cookie +} + +// SetSelectionCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} +} + +// SetSelectionCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionCreateContextCookie.Check() +func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetSelectionCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionCreateContext +// setSelectionCreateContextRequest writes a SetSelectionCreateContext request to a byte slice. +func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetSelectionUseContextCookie is a cookie used only for SetSelectionUseContext requests. +type SetSelectionUseContextCookie struct { + *xgb.Cookie +} + +// SetSelectionUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +// SetSelectionUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionUseContextCookie.Check() +func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetSelectionUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionUseContext +// setSelectionUseContextRequest writes a SetSelectionUseContext request to a byte slice. +func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetWindowCreateContextCookie is a cookie used only for SetWindowCreateContext requests. +type SetWindowCreateContextCookie struct { + *xgb.Cookie +} + +// SetWindowCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} + +// SetWindowCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetWindowCreateContextCookie.Check() +func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetWindowCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetWindowCreateContext +// setWindowCreateContextRequest writes a SetWindowCreateContext request to a byte slice. +func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) return buf } diff --git a/nexgb/xtest/xtest.go b/nexgb/xtest/xtest.go index 30d96ec..505622a 100644 --- a/nexgb/xtest/xtest.go +++ b/nexgb/xtest/xtest.go @@ -2,7 +2,7 @@ package xtest /* - This file was generated by xtest.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xtest.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,128 +40,34 @@ func init() { xgb.NewExtErrorFuncs["XTEST"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Void' - -// 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' - const ( CursorNone = 0 CursorCurrent = 1 ) -// GetVersionCookie is a cookie used only for GetVersion requests. -type GetVersionCookie struct { - *xgb.Cookie -} +// Skipping definition for base type 'Bool' -// 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} -} +// Skipping definition for base type 'Byte' -// 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} -} +// Skipping definition for base type 'Card8' -// 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 -} +// Skipping definition for base type 'Char' -// 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 -} +// Skipping definition for base type 'Void' -// getVersionReply reads a byte slice into a GetVersionReply value. -func getVersionReply(buf []byte) *GetVersionReply { - v := new(GetVersionReply) - b := 1 // skip reply determinant +// Skipping definition for base type 'Double' - v.MajorVersion = buf[b] - b += 1 +// Skipping definition for base type 'Float' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Int32' - v.MinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int8' - return v -} +// Skipping definition for base type 'Card16' -// 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 -} +// 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,6 +147,247 @@ func AdaptorInfoListSize(list []AdaptorInfo) int { return size } +const ( + AttributeFlagGettable = 1 + AttributeFlagSettable = 2 +) + +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 +} + +// 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 @@ -452,6 +491,74 @@ func EncodingInfoListSize(list []EncodingInfo) int { return size } +type Format struct { + Visual xproto.Visualid + Depth byte + // padding: 3 bytes +} + +// FormatRead reads a byte slice into a Format value. +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// FormatReadList reads a byte slice into a list of Format values. +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Format value to a byte slice. +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + return buf +} + +// FormatListBytes writes a list of Format values to a byte slice. +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + GrabPortStatusSuccess = 0 + GrabPortStatusBadExtension = 1 + GrabPortStatusAlreadyGrabbed = 2 + GrabPortStatusInvalidTime = 3 + GrabPortStatusBadReply = 4 + GrabPortStatusBadAlloc = 5 +) + type Image struct { Id uint32 Width uint16 @@ -572,94 +679,6 @@ func ImageListSize(list []Image) int { return size } -type AttributeInfo struct { - Flags uint32 - Min int32 - Max int32 - Size uint32 - Name string // size: xgb.Pad((int(Size) * 1)) -} - -// AttributeInfoRead reads a byte slice into a AttributeInfo value. -func AttributeInfoRead(buf []byte, v *AttributeInfo) int { - b := 0 - - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - v.Min = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Max = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Size = xgb.Get32(buf[b:]) - b += 4 - - { - byteString := make([]byte, v.Size) - copy(byteString[:v.Size], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Size)) - } - - return b -} - -// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values. -func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = AttributeInfo{} - b += AttributeInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a AttributeInfo value to a byte slice. -func (v AttributeInfo) Bytes() []byte { - buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) - b := 0 - - xgb.Put32(buf[b:], v.Flags) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Min)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Max)) - b += 4 - - xgb.Put32(buf[b:], v.Size) - b += 4 - - copy(buf[b:], v.Name[:v.Size]) - b += xgb.Pad(int(v.Size)) - - return buf -} - -// AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice. -func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. -func AttributeInfoListSize(list []AttributeInfo) int { - size := 0 - for _, item := range list { - size += (16 + xgb.Pad((int(item.Size) * 1))) - } - return size -} - type ImageFormatInfo struct { Id uint32 Type byte @@ -890,86 +909,24 @@ func ImageFormatInfoListSize(list []ImageFormatInfo) int { return size } -// VideoNotify is the event number for a VideoNotifyEvent. -const VideoNotify = 0 +const ( + ImageFormatInfoFormatPacked = 0 + ImageFormatInfoFormatPlanar = 1 +) -type VideoNotifyEvent struct { - Sequence uint16 - Reason byte - Time xproto.Timestamp - Drawable xproto.Drawable - Port Port -} +const ( + ImageFormatInfoTypeRgb = 0 + ImageFormatInfoTypeYuv = 1 +) -// 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 +type Port uint32 - v.Reason = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) - b += 4 - - v.Port = Port(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Bytes writes a VideoNotifyEvent value to a byte slice. -func (v VideoNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Reason - b += 1 - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Port)) - b += 4 - - return buf -} - -// 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 -} - -// 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.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew +func NewPortId(c *xgb.Conn) (Port, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Port(id), nil } // PortNotify is the event number for a PortNotifyEvent. @@ -1059,182 +1016,224 @@ func init() { xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew } -// BadBadPort is the error number for a BadBadPort. -const BadBadPort = 0 - -type BadPortError struct { - Sequence uint16 - NiceName string +type Rational struct { + Numerator int32 + Denominator int32 } -// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. -func BadPortErrorNew(buf []byte) xgb.Error { - v := BadPortError{} - v.NiceName = "BadPort" +// RationalRead reads a byte slice into a Rational value. +func RationalRead(buf []byte, v *Rational) int { + b := 0 - b := 1 // skip error determinant - b += 1 // don't read error number + v.Numerator = int32(xgb.Get32(buf[b:])) + b += 4 + + v.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 +} + +const ( + ScanlineOrderTopToBottom = 0 + ScanlineOrderBottomToTop = 1 +) + +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 + 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 - return v -} + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// SequenceId returns the sequence id attached to the BadBadPort error. -// This is mostly used internally. -func (err BadPortError) SequenceId() uint16 { - return err.Sequence -} + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 -// 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 -} - -// 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 + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 return v } -// SequenceId returns the sequence id attached to the BadBadEncoding error. +// Bytes writes a VideoNotifyEvent value to a byte slice. +func (v VideoNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Reason + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + return buf +} + +// SequenceId returns the sequence id attached to the VideoNotify event. +// Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (err BadEncodingError) SequenceId() uint16 { - return err.Sequence +func (v VideoNotifyEvent) SequenceId() uint16 { + return v.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, ", ") + "}" +// String is a rudimentary string representation of VideoNotifyEvent. +func (v VideoNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew + xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew } -// BadBadControl is the error number for a BadBadControl. -const BadBadControl = 2 +const ( + VideoNotifyReasonStarted = 0 + VideoNotifyReasonStopped = 1 + VideoNotifyReasonBusy = 2 + VideoNotifyReasonPreempted = 3 + VideoNotifyReasonHardError = 4 +) -type BadControlError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Bool' -// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. -func BadControlErrorNew(buf []byte) xgb.Error { - v := BadControlError{} - v.NiceName = "BadControl" +// Skipping definition for base type 'Byte' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Card8' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Char' - return v -} +// Skipping definition for base type 'Void' -// SequenceId returns the sequence id attached to the BadBadControl error. -// This is mostly used internally. -func (err BadControlError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Double' -// BadId returns the 'BadValue' number if one exists for the BadBadControl error. If no bad value exists, 0 is returned. -func (err BadControlError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Float' -// Error returns a rudimentary string representation of the BadBadControl error. +// Skipping definition for base type 'Int16' -func (err BadControlError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Int32' -func init() { - xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew -} +// Skipping definition for base type 'Int8' -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests. +type GetPortAttributeCookie struct { *xgb.Cookie } -// QueryExtension sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() -func QueryExtension(c *xgb.Conn) QueryExtensionCookie { +// GetPortAttribute sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() +func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryExtensionRequest(c), cookie) - return QueryExtensionCookie{cookie} + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} } -// QueryExtensionUnchecked sends an unchecked request. +// GetPortAttributeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { +func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionRequest(c), cookie) - return QueryExtensionCookie{cookie} + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} } -// QueryExtensionReply represents the data returned from a QueryExtension request. -type QueryExtensionReply struct { +// GetPortAttributeReply represents the data returned from a GetPortAttribute request. +type GetPortAttributeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Major uint16 - Minor uint16 + Value int32 } -// Reply blocks and returns the reply data for a QueryExtension request. -func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { +// Reply blocks and returns the reply data for a GetPortAttribute request. +func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1242,12 +1241,12 @@ func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { if buf == nil { return nil, nil } - return queryExtensionReply(buf), nil + return getPortAttributeReply(buf), nil } -// queryExtensionReply reads a byte slice into a QueryExtensionReply value. -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) +// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. +func getPortAttributeReply(buf []byte) *GetPortAttributeReply { + v := new(GetPortAttributeReply) b := 1 // skip reply determinant b += 1 // padding @@ -1258,290 +1257,15 @@ 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 - - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - 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 -} - -// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. -type QueryAdaptorsCookie 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. -// 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 'QueryAdaptors' 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) -} - -// Reply blocks and returns the reply data for a QueryAdaptors request. -func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryAdaptorsReply(buf), nil -} - -// 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 -} - -// 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] = 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 -} - -// 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} -} - -// 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} -} - -// 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) -} - -// 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 -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumEncodings = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Info = make([]EncodingInfo, v.NumEncodings) - b += EncodingInfoReadList(buf[b:], v.Info) - - return v -} - -// 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) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - - return buf -} - -// GrabPortCookie is a cookie used only for GrabPort requests. -type GrabPortCookie struct { - *xgb.Cookie -} - -// GrabPort sends a checked request. -// If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply() -func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(grabPortRequest(c, Port, Time), cookie) - return GrabPortCookie{cookie} -} - -// GrabPortUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(grabPortRequest(c, Port, Time), cookie) - return GrabPortCookie{cookie} -} - -// GrabPortReply represents the data returned from a GrabPort request. -type GrabPortReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Result byte -} - -// Reply blocks and returns the reply data for a GrabPort request. -func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return grabPortReply(buf), nil -} - -// grabPortReply reads a byte slice into a GrabPortReply value. -func grabPortReply(buf []byte) *GrabPortReply { - v := new(GrabPortReply) - b := 1 // skip reply determinant - - v.Result = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + v.Value = int32(xgb.Get32(buf[b:])) b += 4 return v } -// Write request to wire for GrabPort -// grabPortRequest writes a GrabPort request to a byte slice. -func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { +// 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) @@ -1549,7 +1273,7 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { buf[b] = c.Extensions["XVIDEO"] 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 @@ -1558,106 +1282,48 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { xgb.Put32(buf[b:], uint32(Port)) b += 4 - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Attribute)) b += 4 return buf } -// UngrabPortCookie is a cookie used only for UngrabPort requests. -type UngrabPortCookie struct { +// GetStillCookie is a cookie used only for GetStill requests. +type GetStillCookie struct { *xgb.Cookie } -// UngrabPort 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 UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { +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 'UngrabPort' 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, false) - c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) - return UngrabPortCookie{cookie} + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{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 { +// 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 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) - return UngrabPortCookie{cookie} + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabPortCookie) Check() error { +func (cook GetStillCookie) 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 -} - -// 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} -} - -// 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} -} - -// Check returns an error if one occurred 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() -} - -// 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 { +// 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) @@ -1665,92 +1331,7 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto buf[b] = c.Extensions["XVIDEO"] 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(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 { - *xgb.Cookie -} - -// PutStill 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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutStill' 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} -} - -// 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 'PutStill' 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} -} - -// Check returns an error if one occurred 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 { - 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 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - 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 @@ -1877,42 +1458,322 @@ 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 { +// GrabPortCookie is a cookie used only for GrabPort requests. +type GrabPortCookie struct { *xgb.Cookie } -// GetStill sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { +// GrabPort sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply() +func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { 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 'GrabPort' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{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 { +// GrabPortUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { 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 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{cookie} +} + +// GrabPortReply represents the data returned from a GrabPort request. +type GrabPortReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Result byte +} + +// Reply blocks and returns the reply data for a GrabPort request. +func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabPortReply(buf), nil +} + +// grabPortReply reads a byte slice into a GrabPortReply value. +func grabPortReply(buf []byte) *GrabPortReply { + v := new(GrabPortReply) + b := 1 // skip reply determinant + + v.Result = 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 GrabPort +// grabPortRequest writes a GrabPort request to a byte slice. +func grabPortRequest(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] = 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// ListImageFormatsCookie is a cookie used only for ListImageFormats requests. +type ListImageFormatsCookie 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 { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'ListImageFormats' 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} +} + +// 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 'ListImageFormats' 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} +} + +// 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) +} + +// Reply blocks and returns the reply data for a ListImageFormats request. +func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listImageFormatsReply(buf), nil +} + +// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. +func listImageFormatsReply(buf []byte) *ListImageFormatsReply { + v := new(ListImageFormatsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Format = make([]ImageFormatInfo, v.NumFormats) + b += ImageFormatInfoReadList(buf[b:], v.Format) + + return v +} + +// Write request to wire for ListImageFormats +// listImageFormatsRequest writes a ListImageFormats request to a byte slice. +func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 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(Port)) + b += 4 + + return buf +} + +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { + *xgb.Cookie +} + +// 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, 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 'PutImage' 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} +} + +// 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 'PutImage' 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(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 GetStillCookie) Check() error { +func (cook PutImageCookie) 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 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] = 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(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcW) + b += 2 + + xgb.Put16(buf[b:], SrcH) + 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 + + 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 +} + +// PutStillCookie is a cookie used only for PutStill requests. +type PutStillCookie struct { + *xgb.Cookie +} + +// PutStill 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 { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'PutStill' 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} +} + +// 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 'PutStill' 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} +} + +// Check returns an error if one occurred 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 { + 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 b := 0 buf := make([]byte, size) @@ -1920,7 +1781,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] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1962,50 +1823,50 @@ 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 { +// PutVideoCookie is a cookie used only for PutVideo requests. +type PutVideoCookie struct { *xgb.Cookie } -// StopVideo 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 StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { +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 'StopVideo' 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(stopVideoRequest(c, Port, Drawable), cookie) - return StopVideoCookie{cookie} + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{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 { +// 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 'StopVideo' 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(stopVideoRequest(c, Port, Drawable), cookie) - return StopVideoCookie{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 StopVideoCookie) Check() error { +func (cook PutVideoCookie) 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 +// 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) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2017,134 +1878,128 @@ func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { 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 } -// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. -type SelectVideoNotifyCookie struct { +// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. +type QueryAdaptorsCookie struct { *xgb.Cookie } -// SelectVideoNotify sends an unchecked request. +// 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. // 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 { +func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectVideoNotify' 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(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) - return SelectVideoNotifyCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{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.") +// 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) +} + +// 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(true, false) - c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) - return SelectVideoNotifyCookie{cookie} + if buf == nil { + return nil, nil + } + return queryAdaptorsReply(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 SelectVideoNotifyCookie) Check() error { - return cook.Cookie.Check() +// 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 } -// 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 +// 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] = 10 // 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(Drawable)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests. -type SelectPortNotifyCookie struct { - *xgb.Cookie -} - -// 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 - b += 2 - - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - return buf } @@ -2261,104 +2116,45 @@ func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW return buf } -// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests. -type SetPortAttributeCookie struct { +// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. +type QueryEncodingsCookie 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 { +// 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 '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.") + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) - return GetPortAttributeCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// GetPortAttributeUnchecked sends an unchecked request. +// QueryEncodingsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { +func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) - return GetPortAttributeCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// GetPortAttributeReply represents the data returned from a GetPortAttribute request. -type GetPortAttributeReply struct { +// QueryEncodingsReply represents the data returned from a QueryEncodings request. +type QueryEncodingsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Value int32 + NumEncodings uint16 + // padding: 22 bytes + Info []EncodingInfo // size: EncodingInfoListSize(Info) } -// Reply blocks and returns the reply data for a GetPortAttribute request. -func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { +// Reply blocks and returns the reply data for a QueryEncodings request. +func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2366,12 +2162,12 @@ func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { if buf == nil { return nil, nil } - return getPortAttributeReply(buf), nil + return queryEncodingsReply(buf), nil } -// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. -func getPortAttributeReply(buf []byte) *GetPortAttributeReply { - v := new(GetPortAttributeReply) +// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. +func queryEncodingsReply(buf []byte) *QueryEncodingsReply { + v := new(QueryEncodingsReply) b := 1 // skip reply determinant b += 1 // padding @@ -2382,117 +2178,20 @@ func getPortAttributeReply(buf []byte) *GetPortAttributeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Value = int32(xgb.Get32(buf[b:])) - b += 4 + v.NumEncodings = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Info = make([]EncodingInfo, v.NumEncodings) + b += EncodingInfoReadList(buf[b:], v.Info) return v } -// Write request to wire for GetPortAttribute -// getPortAttributeRequest writes a GetPortAttribute request to a byte slice. -func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Attribute)) - b += 4 - - return buf -} - -// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. -type QueryPortAttributesCookie struct { - *xgb.Cookie -} - -// QueryPortAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() -func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} -} - -// QueryPortAttributesUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} -} - -// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. -type QueryPortAttributesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumAttributes uint32 - TextSize uint32 - // padding: 16 bytes - Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) -} - -// Reply blocks and returns the reply data for a QueryPortAttributes request. -func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryPortAttributesReply(buf), nil -} - -// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. -func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { - v := new(QueryPortAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - 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 { +// 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 + v.Major = xgb.Get16(buf[b:]) + b += 2 - b += 20 // padding - - v.Format = make([]ImageFormatInfo, v.NumFormats) - b += ImageFormatInfoReadList(buf[b:], v.Format) + v.Minor = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for ListImageFormats -// listImageFormatsRequest writes a ListImageFormats request to a byte slice. -func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { - size := 8 +// Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. +func queryExtensionRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 16 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - return buf } @@ -2735,50 +2428,94 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. +type QueryPortAttributesCookie struct { *xgb.Cookie } -// PutImage sends an unchecked request. +// QueryPortAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() +func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// QueryPortAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { +func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return PutImageCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{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 { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") +// 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 } - 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} + if buf == nil { + return nil, nil + } + return queryPortAttributesReply(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 PutImageCookie) Check() error { - return cook.Cookie.Check() +// 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 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 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] = 18 // request opcode + buf[b] = 15 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2787,47 +2524,194 @@ func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto 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 + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. +type SelectVideoNotifyCookie struct { + *xgb.Cookie +} + +// SelectVideoNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +// SelectVideoNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() +func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SelectVideoNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectVideoNotify +// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice. +func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Gc)) + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + 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:], Id) + xgb.Put32(buf[b:], uint32(Attribute)) b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - xgb.Put16(buf[b:], SrcW) - b += 2 - - xgb.Put16(buf[b:], SrcH) - 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 - - 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))) + 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,16 +51,6 @@ func NewContextId(c *xgb.Conn) (Context, error) { return Context(id), nil } -type Surface uint32 - -func NewSurfaceId(c *xgb.Conn) (Surface, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Surface(id), nil -} - type Subpicture uint32 func NewSubpictureId(c *xgb.Conn) (Subpicture, error) { @@ -95,6 +61,16 @@ func NewSubpictureId(c *xgb.Conn) (Subpicture, error) { return Subpicture(id), nil } +type Surface uint32 + +func NewSurfaceId(c *xgb.Conn) (Surface, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Surface(id), nil +} + type SurfaceInfo struct { Id Surface ChromaFormat uint16 @@ -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 -} +// Skipping definition for base type 'Bool' -// 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} -} +// Skipping definition for base type 'Byte' -// 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} -} +// Skipping definition for base type 'Card8' -// 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 -} +// Skipping definition for base type 'Char' -// 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 -} +// Skipping definition for base type 'Void' -// 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 'Double' - b += 1 // padding +// Skipping definition for base type 'Float' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Int16' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Int32' - v.Major = xgb.Get32(buf[b:]) - b += 4 +// Skipping definition for base type 'Int8' - v.Minor = xgb.Get32(buf[b:]) - b += 4 +// Skipping definition for base type 'Card16' - 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 - - 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) - - buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] - 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(PortId)) - b += 4 - - return buf -} +// Skipping definition for base type 'Card32' // CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { @@ -504,214 +320,6 @@ 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 { - *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 -} - -// CreateSurfaceCookie is a cookie used only for CreateSurface requests. -type CreateSurfaceCookie struct { - *xgb.Cookie -} - -// CreateSurface sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateSurfaceCookie.Reply() -func CreateSurface(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { - if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) - return CreateSurfaceCookie{cookie} -} - -// CreateSurfaceUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateSurfaceUnchecked(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { - if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) - return CreateSurfaceCookie{cookie} -} - -// CreateSurfaceReply represents the data returned from a CreateSurface request. -type CreateSurfaceReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - // padding: 24 bytes - PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) -} - -// Reply blocks and returns the reply data for a CreateSurface request. -func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return createSurfaceReply(buf), nil -} - -// createSurfaceReply reads a byte slice into a CreateSurfaceReply value. -func createSurfaceReply(buf []byte) *CreateSurfaceReply { - v := new(CreateSurfaceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.PrivData = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PrivData[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for CreateSurface -// createSurfaceRequest writes a CreateSurface request to a byte slice. -func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 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(SurfaceId)) - b += 4 - - xgb.Put32(buf[b:], uint32(ContextId)) - b += 4 - - return buf -} - -// DestroySurfaceCookie is a cookie used only for DestroySurface requests. -type DestroySurfaceCookie struct { - *xgb.Cookie -} - -// DestroySurface sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroySurface(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { - if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'DestroySurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) - return DestroySurfaceCookie{cookie} -} - -// DestroySurfaceChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroySurfaceCookie.Check() -func DestroySurfaceChecked(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { - if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { - panic("Cannot issue request 'DestroySurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) - return DestroySurfaceCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroySurfaceCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for DestroySurface -// destroySurfaceRequest writes a DestroySurface request to a byte slice. -func destroySurfaceRequest(c *xgb.Conn, SurfaceId Surface) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] - 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(SurfaceId)) - b += 4 - - return buf -} - // CreateSubpictureCookie is a cookie used only for CreateSubpicture requests. type CreateSubpictureCookie struct { *xgb.Cookie @@ -840,6 +448,159 @@ func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Conte return buf } +// CreateSurfaceCookie is a cookie used only for CreateSurface requests. +type CreateSurfaceCookie struct { + *xgb.Cookie +} + +// CreateSurface sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateSurfaceCookie.Reply() +func CreateSurface(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { + if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { + panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) + return CreateSurfaceCookie{cookie} +} + +// CreateSurfaceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateSurfaceUnchecked(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { + if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { + panic("Cannot issue request 'CreateSurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) + return CreateSurfaceCookie{cookie} +} + +// CreateSurfaceReply represents the data returned from a CreateSurface request. +type CreateSurfaceReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + // padding: 24 bytes + PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Reply blocks and returns the reply data for a CreateSurface request. +func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createSurfaceReply(buf), nil +} + +// createSurfaceReply reads a byte slice into a CreateSurfaceReply value. +func createSurfaceReply(buf []byte) *CreateSurfaceReply { + v := new(CreateSurfaceReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.PrivData = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PrivData[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for CreateSurface +// createSurfaceRequest writes a CreateSurface request to a byte slice. +func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 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(SurfaceId)) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextId)) + b += 4 + + return buf +} + +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { + *xgb.Cookie +} + +// DestroyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroyContext(c *xgb.Conn, 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 @@ -895,6 +656,61 @@ func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte { return buf } +// DestroySurfaceCookie is a cookie used only for DestroySurface requests. +type DestroySurfaceCookie struct { + *xgb.Cookie +} + +// DestroySurface sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroySurface(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { + if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { + panic("Cannot issue request 'DestroySurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) + return DestroySurfaceCookie{cookie} +} + +// DestroySurfaceChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroySurfaceCookie.Check() +func DestroySurfaceChecked(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { + if _, ok := c.Extensions["XVIDEO-MOTIONCOMPENSATION"]; !ok { + panic("Cannot issue request 'DestroySurface' using the uninitialized extension 'XVideo-MotionCompensation'. xvmc.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) + return DestroySurfaceCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroySurfaceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroySurface +// destroySurfaceRequest writes a DestroySurface request to a byte slice. +func destroySurfaceRequest(c *xgb.Conn, SurfaceId Surface) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + 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(SurfaceId)) + b += 4 + + return buf +} + // ListSubpictureTypesCookie is a cookie used only for ListSubpictureTypes requests. type ListSubpictureTypesCookie struct { *xgb.Cookie @@ -992,3 +808,187 @@ func listSubpictureTypesRequest(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) 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 + + 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) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + 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(PortId)) + b += 4 + + return buf +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn) 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 +}