aboutsummaryrefslogtreecommitdiff
path: root/nexgb/shm/shm.go
diff options
context:
space:
mode:
Diffstat (limited to 'nexgb/shm/shm.go')
-rw-r--r--nexgb/shm/shm.go526
1 files changed, 263 insertions, 263 deletions
diff --git a/nexgb/shm/shm.go b/nexgb/shm/shm.go
index 97ce9ff..bd5d638 100644
--- a/nexgb/shm/shm.go
+++ b/nexgb/shm/shm.go
@@ -2,7 +2,7 @@
package shm
/*
- This file was generated by shm.xml on Jun 5 2012 12:11:59am EDT.
+ This file was generated by shm.xml on Aug 11 2013 8:39:43pm EDT.
This file is automatically generated. Edit at your peril!
*/
@@ -40,38 +40,42 @@ func init() {
xgb.NewExtErrorFuncs["MIT-SHM"] = make(map[int]xgb.NewErrorFun)
}
-// Skipping definition for base type 'Char'
-
-// Skipping definition for base type 'Card32'
-
-// Skipping definition for base type 'Double'
-
-// Skipping definition for base type 'Bool'
-
-// Skipping definition for base type 'Float'
-
-// Skipping definition for base type 'Card8'
-
-// Skipping definition for base type 'Int16'
-
-// Skipping definition for base type 'Int32'
+// BadBadSeg is the error number for a BadBadSeg.
+const BadBadSeg = 0
-// Skipping definition for base type 'Void'
+type BadSegError xproto.ValueError
-// Skipping definition for base type 'Byte'
+// BadSegErrorNew constructs a BadSegError value that implements xgb.Error from a byte slice.
+func BadSegErrorNew(buf []byte) xgb.Error {
+ v := BadSegError(xproto.ValueErrorNew(buf).(xproto.ValueError))
+ v.NiceName = "BadSeg"
+ return v
+}
-// Skipping definition for base type 'Int8'
+// SequenceId returns the sequence id attached to the BadBadSeg error.
+// This is mostly used internally.
+func (err BadSegError) SequenceId() uint16 {
+ return err.Sequence
+}
-// Skipping definition for base type 'Card16'
+// BadId returns the 'BadValue' number if one exists for the BadBadSeg error. If no bad value exists, 0 is returned.
+func (err BadSegError) BadId() uint32 {
+ return 0
+}
-type Seg uint32
+// Error returns a rudimentary string representation of the BadBadSeg error.
+func (err BadSegError) Error() string {
+ fieldVals := make([]string, 0, 4)
+ fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
+ fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
+ fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue))
+ fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode))
+ fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode))
+ return "BadBadSeg {" + xgb.StringsJoin(fieldVals, ", ") + "}"
+}
-func NewSegId(c *xgb.Conn) (Seg, error) {
- id, err := c.NewId()
- if err != nil {
- return 0, err
- }
- return Seg(id), nil
+func init() {
+ xgb.NewExtErrorFuncs["MIT-SHM"][0] = BadSegErrorNew
}
// Completion is the event number for a CompletionEvent.
@@ -174,152 +178,39 @@ func init() {
xgb.NewExtEventFuncs["MIT-SHM"][0] = CompletionEventNew
}
-// BadBadSeg is the error number for a BadBadSeg.
-const BadBadSeg = 0
-
-type BadSegError xproto.ValueError
-
-// BadSegErrorNew constructs a BadSegError value that implements xgb.Error from a byte slice.
-func BadSegErrorNew(buf []byte) xgb.Error {
- v := BadSegError(xproto.ValueErrorNew(buf).(xproto.ValueError))
- v.NiceName = "BadSeg"
- return v
-}
-
-// SequenceId returns the sequence id attached to the BadBadSeg error.
-// This is mostly used internally.
-func (err BadSegError) SequenceId() uint16 {
- return err.Sequence
-}
-
-// BadId returns the 'BadValue' number if one exists for the BadBadSeg error. If no bad value exists, 0 is returned.
-func (err BadSegError) BadId() uint32 {
- return 0
-}
-
-// Error returns a rudimentary string representation of the BadBadSeg error.
-func (err BadSegError) Error() string {
- fieldVals := make([]string, 0, 4)
- fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
- fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
- fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue))
- fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode))
- fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode))
- return "BadBadSeg {" + xgb.StringsJoin(fieldVals, ", ") + "}"
-}
-
-func init() {
- xgb.NewExtErrorFuncs["MIT-SHM"][0] = BadSegErrorNew
-}
-
-// QueryVersionCookie is a cookie used only for QueryVersion requests.
-type QueryVersionCookie struct {
- *xgb.Cookie
-}
-
-// QueryVersion sends a checked request.
-// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
-func QueryVersion(c *xgb.Conn) QueryVersionCookie {
- if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
- }
- cookie := c.NewCookie(true, true)
- c.NewRequest(queryVersionRequest(c), cookie)
- return QueryVersionCookie{cookie}
-}
-
-// QueryVersionUnchecked sends an unchecked request.
-// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
-func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie {
- if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
- }
- cookie := c.NewCookie(false, true)
- c.NewRequest(queryVersionRequest(c), cookie)
- return QueryVersionCookie{cookie}
-}
-
-// QueryVersionReply represents the data returned from a QueryVersion request.
-type QueryVersionReply struct {
- Sequence uint16 // sequence number of the request for this reply
- Length uint32 // number of bytes in this reply
- SharedPixmaps bool
- MajorVersion uint16
- MinorVersion uint16
- Uid uint16
- Gid uint16
- PixmapFormat byte
- // padding: 15 bytes
-}
+type Seg uint32
-// Reply blocks and returns the reply data for a QueryVersion request.
-func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
- buf, err := cook.Cookie.Reply()
+func NewSegId(c *xgb.Conn) (Seg, error) {
+ id, err := c.NewId()
if err != nil {
- return nil, err
- }
- if buf == nil {
- return nil, nil
+ return 0, err
}
- return queryVersionReply(buf), nil
+ return Seg(id), nil
}
-// queryVersionReply reads a byte slice into a QueryVersionReply value.
-func queryVersionReply(buf []byte) *QueryVersionReply {
- v := new(QueryVersionReply)
- b := 1 // skip reply determinant
-
- if buf[b] == 1 {
- v.SharedPixmaps = true
- } else {
- v.SharedPixmaps = false
- }
- b += 1
-
- v.Sequence = xgb.Get16(buf[b:])
- b += 2
-
- v.Length = xgb.Get32(buf[b:]) // 4-byte units
- b += 4
-
- v.MajorVersion = xgb.Get16(buf[b:])
- b += 2
+// Skipping definition for base type 'Bool'
- v.MinorVersion = xgb.Get16(buf[b:])
- b += 2
+// Skipping definition for base type 'Byte'
- v.Uid = xgb.Get16(buf[b:])
- b += 2
+// Skipping definition for base type 'Card8'
- v.Gid = xgb.Get16(buf[b:])
- b += 2
+// Skipping definition for base type 'Char'
- v.PixmapFormat = buf[b]
- b += 1
+// Skipping definition for base type 'Void'
- b += 15 // padding
+// Skipping definition for base type 'Double'
- return v
-}
+// Skipping definition for base type 'Float'
-// Write request to wire for QueryVersion
-// queryVersionRequest writes a QueryVersion request to a byte slice.
-func queryVersionRequest(c *xgb.Conn) []byte {
- size := 4
- b := 0
- buf := make([]byte, size)
+// Skipping definition for base type 'Int16'
- buf[b] = c.Extensions["MIT-SHM"]
- b += 1
+// Skipping definition for base type 'Int32'
- buf[b] = 0 // request opcode
- b += 1
+// Skipping definition for base type 'Int8'
- xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
- b += 2
+// Skipping definition for base type 'Card16'
- return buf
-}
+// Skipping definition for base type 'Card32'
// AttachCookie is a cookie used only for Attach requests.
type AttachCookie struct {
@@ -388,157 +279,133 @@ func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte
return buf
}
-// DetachCookie is a cookie used only for Detach requests.
-type DetachCookie struct {
+// CreatePixmapCookie is a cookie used only for CreatePixmap requests.
+type CreatePixmapCookie struct {
*xgb.Cookie
}
-// Detach sends an unchecked request.
+// CreatePixmap sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
-func Detach(c *xgb.Conn, Shmseg Seg) DetachCookie {
+func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie {
if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
- c.NewRequest(detachRequest(c, Shmseg), cookie)
- return DetachCookie{cookie}
+ c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
+ return CreatePixmapCookie{cookie}
}
-// DetachChecked sends a checked request.
-// If an error occurs, it can be retrieved using DetachCookie.Check()
-func DetachChecked(c *xgb.Conn, Shmseg Seg) DetachCookie {
+// CreatePixmapChecked sends a checked request.
+// If an error occurs, it can be retrieved using CreatePixmapCookie.Check()
+func CreatePixmapChecked(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie {
if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
- c.NewRequest(detachRequest(c, Shmseg), cookie)
- return DetachCookie{cookie}
+ c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
+ return CreatePixmapCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
-func (cook DetachCookie) Check() error {
+func (cook CreatePixmapCookie) Check() error {
return cook.Cookie.Check()
}
-// Write request to wire for Detach
-// detachRequest writes a Detach request to a byte slice.
-func detachRequest(c *xgb.Conn, Shmseg Seg) []byte {
- size := 8
+// Write request to wire for CreatePixmap
+// createPixmapRequest writes a CreatePixmap request to a byte slice.
+func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) []byte {
+ size := 28
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["MIT-SHM"]
b += 1
- buf[b] = 2 // request opcode
+ buf[b] = 5 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
+ xgb.Put32(buf[b:], uint32(Pid))
+ b += 4
+
+ xgb.Put32(buf[b:], uint32(Drawable))
+ b += 4
+
+ xgb.Put16(buf[b:], Width)
+ b += 2
+
+ xgb.Put16(buf[b:], Height)
+ b += 2
+
+ buf[b] = Depth
+ b += 1
+
+ b += 3 // padding
+
xgb.Put32(buf[b:], uint32(Shmseg))
b += 4
+ xgb.Put32(buf[b:], Offset)
+ b += 4
+
return buf
}
-// PutImageCookie is a cookie used only for PutImage requests.
-type PutImageCookie struct {
+// DetachCookie is a cookie used only for Detach requests.
+type DetachCookie struct {
*xgb.Cookie
}
-// PutImage sends an unchecked request.
+// Detach sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
-func PutImage(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie {
+func Detach(c *xgb.Conn, Shmseg Seg) DetachCookie {
if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
- c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
- return PutImageCookie{cookie}
+ c.NewRequest(detachRequest(c, Shmseg), cookie)
+ return DetachCookie{cookie}
}
-// PutImageChecked sends a checked request.
-// If an error occurs, it can be retrieved using PutImageCookie.Check()
-func PutImageChecked(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie {
+// DetachChecked sends a checked request.
+// If an error occurs, it can be retrieved using DetachCookie.Check()
+func DetachChecked(c *xgb.Conn, Shmseg Seg) DetachCookie {
if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ panic("Cannot issue request 'Detach' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
- c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
- return PutImageCookie{cookie}
+ c.NewRequest(detachRequest(c, Shmseg), cookie)
+ return DetachCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
-func (cook PutImageCookie) Check() error {
+func (cook DetachCookie) Check() error {
return cook.Cookie.Check()
}
-// Write request to wire for PutImage
-// putImageRequest writes a PutImage request to a byte slice.
-func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) []byte {
- size := 40
+// Write request to wire for Detach
+// detachRequest writes a Detach request to a byte slice.
+func detachRequest(c *xgb.Conn, Shmseg Seg) []byte {
+ size := 8
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["MIT-SHM"]
b += 1
- buf[b] = 3 // request opcode
+ buf[b] = 2 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
- xgb.Put32(buf[b:], uint32(Drawable))
- b += 4
-
- xgb.Put32(buf[b:], uint32(Gc))
- b += 4
-
- xgb.Put16(buf[b:], TotalWidth)
- b += 2
-
- xgb.Put16(buf[b:], TotalHeight)
- b += 2
-
- xgb.Put16(buf[b:], SrcX)
- b += 2
-
- xgb.Put16(buf[b:], SrcY)
- b += 2
-
- xgb.Put16(buf[b:], SrcWidth)
- b += 2
-
- xgb.Put16(buf[b:], SrcHeight)
- b += 2
-
- xgb.Put16(buf[b:], uint16(DstX))
- b += 2
-
- xgb.Put16(buf[b:], uint16(DstY))
- b += 2
-
- buf[b] = Depth
- b += 1
-
- buf[b] = Format
- b += 1
-
- buf[b] = SendEvent
- b += 1
-
- b += 1 // padding
-
xgb.Put32(buf[b:], uint32(Shmseg))
b += 4
- xgb.Put32(buf[b:], Offset)
- b += 4
-
return buf
}
@@ -661,71 +528,95 @@ func getImageRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Wi
return buf
}
-// CreatePixmapCookie is a cookie used only for CreatePixmap requests.
-type CreatePixmapCookie struct {
+// PutImageCookie is a cookie used only for PutImage requests.
+type PutImageCookie struct {
*xgb.Cookie
}
-// CreatePixmap sends an unchecked request.
+// PutImage sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
-func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie {
+func PutImage(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie {
if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
- c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
- return CreatePixmapCookie{cookie}
+ c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
+ return PutImageCookie{cookie}
}
-// CreatePixmapChecked sends a checked request.
-// If an error occurs, it can be retrieved using CreatePixmapCookie.Check()
-func CreatePixmapChecked(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie {
+// PutImageChecked sends a checked request.
+// If an error occurs, it can be retrieved using PutImageCookie.Check()
+func PutImageChecked(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie {
if _, ok := c.Extensions["MIT-SHM"]; !ok {
- panic("Cannot issue request 'CreatePixmap' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ panic("Cannot issue request 'PutImage' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
- c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
- return CreatePixmapCookie{cookie}
+ c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
+ return PutImageCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
-func (cook CreatePixmapCookie) Check() error {
+func (cook PutImageCookie) Check() error {
return cook.Cookie.Check()
}
-// Write request to wire for CreatePixmap
-// createPixmapRequest writes a CreatePixmap request to a byte slice.
-func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) []byte {
- size := 28
+// Write request to wire for PutImage
+// putImageRequest writes a PutImage request to a byte slice.
+func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) []byte {
+ size := 40
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["MIT-SHM"]
b += 1
- buf[b] = 5 // request opcode
+ buf[b] = 3 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
- xgb.Put32(buf[b:], uint32(Pid))
+ xgb.Put32(buf[b:], uint32(Drawable))
b += 4
- xgb.Put32(buf[b:], uint32(Drawable))
+ xgb.Put32(buf[b:], uint32(Gc))
b += 4
- xgb.Put16(buf[b:], Width)
+ xgb.Put16(buf[b:], TotalWidth)
b += 2
- xgb.Put16(buf[b:], Height)
+ xgb.Put16(buf[b:], TotalHeight)
+ b += 2
+
+ xgb.Put16(buf[b:], SrcX)
+ b += 2
+
+ xgb.Put16(buf[b:], SrcY)
+ b += 2
+
+ xgb.Put16(buf[b:], SrcWidth)
+ b += 2
+
+ xgb.Put16(buf[b:], SrcHeight)
+ b += 2
+
+ xgb.Put16(buf[b:], uint16(DstX))
+ b += 2
+
+ xgb.Put16(buf[b:], uint16(DstY))
b += 2
buf[b] = Depth
b += 1
- b += 3 // padding
+ buf[b] = Format
+ b += 1
+
+ buf[b] = SendEvent
+ b += 1
+
+ b += 1 // padding
xgb.Put32(buf[b:], uint32(Shmseg))
b += 4
@@ -735,3 +626,112 @@ func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawabl
return buf
}
+
+// QueryVersionCookie is a cookie used only for QueryVersion requests.
+type QueryVersionCookie struct {
+ *xgb.Cookie
+}
+
+// QueryVersion sends a checked request.
+// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
+func QueryVersion(c *xgb.Conn) QueryVersionCookie {
+ if _, ok := c.Extensions["MIT-SHM"]; !ok {
+ panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ }
+ cookie := c.NewCookie(true, true)
+ c.NewRequest(queryVersionRequest(c), cookie)
+ return QueryVersionCookie{cookie}
+}
+
+// QueryVersionUnchecked sends an unchecked request.
+// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
+func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie {
+ if _, ok := c.Extensions["MIT-SHM"]; !ok {
+ panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SHM'. shm.Init(connObj) must be called first.")
+ }
+ cookie := c.NewCookie(false, true)
+ c.NewRequest(queryVersionRequest(c), cookie)
+ return QueryVersionCookie{cookie}
+}
+
+// QueryVersionReply represents the data returned from a QueryVersion request.
+type QueryVersionReply struct {
+ Sequence uint16 // sequence number of the request for this reply
+ Length uint32 // number of bytes in this reply
+ SharedPixmaps bool
+ MajorVersion uint16
+ MinorVersion uint16
+ Uid uint16
+ Gid uint16
+ PixmapFormat byte
+ // padding: 15 bytes
+}
+
+// Reply blocks and returns the reply data for a QueryVersion request.
+func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
+ buf, err := cook.Cookie.Reply()
+ if err != nil {
+ return nil, err
+ }
+ if buf == nil {
+ return nil, nil
+ }
+ return queryVersionReply(buf), nil
+}
+
+// queryVersionReply reads a byte slice into a QueryVersionReply value.
+func queryVersionReply(buf []byte) *QueryVersionReply {
+ v := new(QueryVersionReply)
+ b := 1 // skip reply determinant
+
+ if buf[b] == 1 {
+ v.SharedPixmaps = true
+ } else {
+ v.SharedPixmaps = false
+ }
+ b += 1
+
+ v.Sequence = xgb.Get16(buf[b:])
+ b += 2
+
+ v.Length = xgb.Get32(buf[b:]) // 4-byte units
+ b += 4
+
+ v.MajorVersion = xgb.Get16(buf[b:])
+ b += 2
+
+ v.MinorVersion = xgb.Get16(buf[b:])
+ b += 2
+
+ v.Uid = xgb.Get16(buf[b:])
+ b += 2
+
+ v.Gid = xgb.Get16(buf[b:])
+ b += 2
+
+ v.PixmapFormat = buf[b]
+ b += 1
+
+ b += 15 // padding
+
+ return v
+}
+
+// Write request to wire for QueryVersion
+// queryVersionRequest writes a QueryVersion request to a byte slice.
+func queryVersionRequest(c *xgb.Conn) []byte {
+ size := 4
+ b := 0
+ buf := make([]byte, size)
+
+ buf[b] = c.Extensions["MIT-SHM"]
+ b += 1
+
+ buf[b] = 0 // request opcode
+ b += 1
+
+ xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
+ b += 2
+
+ return buf
+}