2012-05-11 02:06:22 +02:00
|
|
|
// Package xcmisc is the X client API for the XC-MISC extension.
|
2012-05-10 23:01:42 +02:00
|
|
|
package xcmisc
|
|
|
|
|
|
|
|
/*
|
2012-05-12 05:58:52 +02:00
|
|
|
This file was generated by xc_misc.xml on May 11 2012 11:57:19pm EDT.
|
2012-05-10 23:01:42 +02:00
|
|
|
This file is automatically generated. Edit at your peril!
|
|
|
|
*/
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/BurntSushi/xgb"
|
|
|
|
|
|
|
|
"github.com/BurntSushi/xgb/xproto"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Init must be called before using the XC-MISC extension.
|
|
|
|
func Init(c *xgb.Conn) error {
|
|
|
|
reply, err := xproto.QueryExtension(c, 7, "XC-MISC").Reply()
|
|
|
|
switch {
|
|
|
|
case err != nil:
|
|
|
|
return err
|
|
|
|
case !reply.Present:
|
|
|
|
return xgb.Errorf("No extension named XC-MISC could be found on on the server.")
|
|
|
|
}
|
|
|
|
|
|
|
|
xgb.ExtLock.Lock()
|
|
|
|
c.Extensions["XC-MISC"] = reply.MajorOpcode
|
|
|
|
for evNum, fun := range xgb.NewExtEventFuncs["XC-MISC"] {
|
|
|
|
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
|
|
|
}
|
|
|
|
for errNum, fun := range xgb.NewExtErrorFuncs["XC-MISC"] {
|
|
|
|
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
|
|
|
}
|
|
|
|
xgb.ExtLock.Unlock()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtEventFuncs["XC-MISC"] = make(map[int]xgb.NewEventFun)
|
|
|
|
xgb.NewExtErrorFuncs["XC-MISC"] = 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'
|
|
|
|
|
2012-05-12 05:58:52 +02:00
|
|
|
// 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'
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetVersionCookie is a cookie used only for GetVersion requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetVersionCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetVersion sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply()
|
2012-05-10 23:01:42 +02:00
|
|
|
func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["XC-MISC"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
|
|
|
return GetVersionCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetVersionUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["XC-MISC"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
|
|
|
return GetVersionCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetVersionReply represents the data returned from a GetVersion request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetVersionReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 1 bytes
|
|
|
|
ServerMajorVersion uint16
|
|
|
|
ServerMinorVersion uint16
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a GetVersion request.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// getVersionReply reads a byte slice into a GetVersionReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func getVersionReply(buf []byte) *GetVersionReply {
|
|
|
|
v := new(GetVersionReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
b += 1 // padding
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.ServerMajorVersion = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.ServerMinorVersion = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for GetVersion
|
2012-05-11 05:57:34 +02:00
|
|
|
// getVersionRequest writes a GetVersion request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["XC-MISC"]
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDRangeCookie is a cookie used only for GetXIDRange requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetXIDRangeCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDRange sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply()
|
2012-05-10 23:01:42 +02:00
|
|
|
func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
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.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(getXIDRangeRequest(c), cookie)
|
|
|
|
return GetXIDRangeCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDRangeUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
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.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(getXIDRangeRequest(c), cookie)
|
|
|
|
return GetXIDRangeCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDRangeReply represents the data returned from a GetXIDRange request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetXIDRangeReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 1 bytes
|
|
|
|
StartId uint32
|
|
|
|
Count uint32
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a GetXIDRange request.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// getXIDRangeReply reads a byte slice into a GetXIDRangeReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
2012-05-11 05:57:34 +02:00
|
|
|
// getXIDRangeRequest writes a GetXIDRange request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDListCookie is a cookie used only for GetXIDList requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetXIDListCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDList sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply()
|
2012-05-10 23:01:42 +02:00
|
|
|
func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["XC-MISC"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(getXIDListRequest(c, Count), cookie)
|
|
|
|
return GetXIDListCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDListUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["XC-MISC"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(getXIDListRequest(c, Count), cookie)
|
|
|
|
return GetXIDListCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetXIDListReply represents the data returned from a GetXIDList request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetXIDListReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 1 bytes
|
|
|
|
IdsLen uint32
|
|
|
|
// padding: 20 bytes
|
|
|
|
Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4))
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a GetXIDList request.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getXIDListReply(buf), nil
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// getXIDListReply reads a byte slice into a GetXIDListReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func getXIDListReply(buf []byte) *GetXIDListReply {
|
|
|
|
v := new(GetXIDListReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
b += 1 // padding
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.IdsLen = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 20 // padding
|
|
|
|
|
|
|
|
v.Ids = make([]uint32, v.IdsLen)
|
|
|
|
for i := 0; i < int(v.IdsLen); i++ {
|
|
|
|
v.Ids[i] = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for GetXIDList
|
2012-05-11 05:57:34 +02:00
|
|
|
// getXIDListRequest writes a GetXIDList request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func getXIDListRequest(c *xgb.Conn, Count uint32) []byte {
|
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["XC-MISC"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 2 // request opcode
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], Count)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|