haven/nexgb/xfixes/xfixes.go

2489 lines
77 KiB
Go
Raw Normal View History

2012-05-11 02:06:22 +02:00
// Package xfixes is the X client API for the XFIXES extension.
package xfixes
/*
This file was generated by xfixes.xml on May 26 2012 6:23:13pm EDT.
This file is automatically generated. Edit at your peril!
*/
import (
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/render"
"github.com/BurntSushi/xgb/shape"
"github.com/BurntSushi/xgb/xproto"
)
// Init must be called before using the XFIXES extension.
func Init(c *xgb.Conn) error {
reply, err := xproto.QueryExtension(c, 6, "XFIXES").Reply()
switch {
case err != nil:
return err
case !reply.Present:
return xgb.Errorf("No extension named XFIXES could be found on on the server.")
}
xgb.ExtLock.Lock()
c.Extensions["XFIXES"] = reply.MajorOpcode
for evNum, fun := range xgb.NewExtEventFuncs["XFIXES"] {
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
}
for errNum, fun := range xgb.NewExtErrorFuncs["XFIXES"] {
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
}
xgb.ExtLock.Unlock()
return nil
}
func init() {
xgb.NewExtEventFuncs["XFIXES"] = make(map[int]xgb.NewEventFun)
xgb.NewExtErrorFuncs["XFIXES"] = 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'
2012-05-11 05:57:34 +02:00
// Skipping definition for base type 'Card8'
const (
SaveSetModeInsert = 0
SaveSetModeDelete = 1
)
const (
SaveSetTargetNearest = 0
SaveSetTargetRoot = 1
)
const (
SaveSetMappingMap = 0
SaveSetMappingUnmap = 1
)
const (
SelectionEventSetSelectionOwner = 0
SelectionEventSelectionWindowDestroy = 1
SelectionEventSelectionClientClose = 2
)
const (
SelectionEventMaskSetSelectionOwner = 1
SelectionEventMaskSelectionWindowDestroy = 2
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
}
2012-05-11 05:57:34 +02:00
// SelectionNotify is the event number for a SelectionNotifyEvent.
const SelectionNotify = 0
type SelectionNotifyEvent struct {
Sequence uint16
Subtype byte
Window xproto.Window
Owner xproto.Window
Selection xproto.Atom
Timestamp xproto.Timestamp
SelectionTimestamp xproto.Timestamp
// padding: 8 bytes
}
2012-05-11 05:57:34 +02:00
// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice.
func SelectionNotifyEventNew(buf []byte) xgb.Event {
v := SelectionNotifyEvent{}
b := 1 // don't read event number
v.Subtype = buf[b]
b += 1
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Window = xproto.Window(xgb.Get32(buf[b:]))
b += 4
v.Owner = xproto.Window(xgb.Get32(buf[b:]))
b += 4
v.Selection = xproto.Atom(xgb.Get32(buf[b:]))
b += 4
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
b += 4
v.SelectionTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
b += 4
b += 8 // padding
return v
}
2012-05-11 05:57:34 +02:00
// 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] = 0
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:], uint32(v.Owner))
b += 4
xgb.Put32(buf[b:], uint32(v.Selection))
b += 4
xgb.Put32(buf[b:], uint32(v.Timestamp))
b += 4
xgb.Put32(buf[b:], uint32(v.SelectionTimestamp))
b += 4
b += 8 // padding
return buf
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// String is a rudimentary string representation of SelectionNotifyEvent.
func (v SelectionNotifyEvent) String() string {
fieldVals := make([]string, 0, 7)
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("Owner: %d", v.Owner))
fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection))
fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp))
fieldVals = append(fieldVals, xgb.Sprintf("SelectionTimestamp: %d", v.SelectionTimestamp))
return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// BadBadRegion is the error number for a BadBadRegion.
const BadBadRegion = 0
type BadRegionError struct {
Sequence uint16
NiceName string
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SequenceId returns the sequence id attached to the BadBadRegion error.
// This is mostly used internally.
func (err BadRegionError) SequenceId() uint16 {
return err.Sequence
}
2012-05-11 07:58:52 +02:00
// 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
}
2012-05-11 07:58:52 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// QueryVersionCookie is a cookie used only for QueryVersion requests.
type QueryVersionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// QueryVersionReply represents the data returned from a QueryVersion request.
type QueryVersionReply 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
// padding: 1 bytes
MajorVersion uint32
MinorVersion uint32
// padding: 16 bytes
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests.
type ChangeSaveSetCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'ChangeSaveSet' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie)
return ChangeSaveSetCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// ChangeSaveSetChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check()
func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'ChangeSaveSet' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie)
return ChangeSaveSetCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice.
func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) []byte {
size := 12
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["XFIXES"]
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] = Mode
b += 1
buf[b] = Target
b += 1
buf[b] = Map
b += 1
b += 1 // padding
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2012-05-11 05:57:34 +02:00
// SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests.
type SelectSelectionInputCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests.
type SelectCursorInputCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// GetCursorImageCookie is a cookie used only for GetCursorImage requests.
type GetCursorImageCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// GetCursorImage sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetCursorImageCookie.Reply()
func GetCursorImage(c *xgb.Conn) GetCursorImageCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(getCursorImageRequest(c), cookie)
return GetCursorImageCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// GetCursorImageUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(getCursorImageRequest(c), cookie)
return GetCursorImageCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// GetCursorImageReply represents the data returned from a GetCursorImage request.
type GetCursorImageReply 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
// padding: 1 bytes
X int16
Y int16
Width uint16
Height uint16
Xhot uint16
Yhot uint16
CursorSerial uint32
// padding: 8 bytes
CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4))
}
2012-05-11 05:57:34 +02:00
// Reply blocks and returns the reply data for a GetCursorImage request.
func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return getCursorImageReply(buf), nil
}
2012-05-11 05:57:34 +02:00
// getCursorImageReply reads a byte slice into a GetCursorImageReply value.
func getCursorImageReply(buf []byte) *GetCursorImageReply {
v := new(GetCursorImageReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.X = int16(xgb.Get16(buf[b:]))
b += 2
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
v.Width = xgb.Get16(buf[b:])
b += 2
v.Height = xgb.Get16(buf[b:])
b += 2
v.Xhot = xgb.Get16(buf[b:])
b += 2
v.Yhot = xgb.Get16(buf[b:])
b += 2
v.CursorSerial = xgb.Get32(buf[b:])
b += 4
b += 8 // padding
v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height)))
for i := 0; i < int((int(v.Width) * int(v.Height))); i++ {
v.CursorImage[i] = xgb.Get32(buf[b:])
b += 4
}
b = xgb.Pad(b)
return v
}
// Write request to wire for GetCursorImage
2012-05-11 05:57:34 +02:00
// getCursorImageRequest writes a GetCursorImage request to a byte slice.
func getCursorImageRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["XFIXES"]
b += 1
buf[b] = 4 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2012-05-11 05:57:34 +02:00
// CreateRegionCookie is a cookie used only for CreateRegion requests.
type CreateRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// CreateRegionFromBitmapCookie is a cookie used only for CreateRegionFromBitmap requests.
type CreateRegionFromBitmapCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests.
type CreateRegionFromWindowCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// CreateRegionFromGCCookie is a cookie used only for CreateRegionFromGC requests.
type CreateRegionFromGCCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// CreateRegionFromPictureCookie is a cookie used only for CreateRegionFromPicture requests.
type CreateRegionFromPictureCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// DestroyRegionCookie is a cookie used only for DestroyRegion requests.
type DestroyRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SetRegionCookie is a cookie used only for SetRegion requests.
type SetRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// CopyRegionCookie is a cookie used only for CopyRegion requests.
type CopyRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// UnionRegionCookie is a cookie used only for UnionRegion requests.
type UnionRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// IntersectRegionCookie is a cookie used only for IntersectRegion requests.
type IntersectRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SubtractRegionCookie is a cookie used only for SubtractRegion requests.
type SubtractRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// InvertRegionCookie is a cookie used only for InvertRegion requests.
type InvertRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// TranslateRegionCookie is a cookie used only for TranslateRegion requests.
type TranslateRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// RegionExtentsCookie is a cookie used only for RegionExtents requests.
type RegionExtentsCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// FetchRegionCookie is a cookie used only for FetchRegion requests.
type FetchRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// FetchRegionReply represents the data returned from a FetchRegion request.
type FetchRegionReply 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
// padding: 1 bytes
Extents xproto.Rectangle
// padding: 16 bytes
Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8))
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests.
type SetGCClipRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests.
type SetWindowShapeRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests.
type SetPictureClipRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// SetCursorNameCookie is a cookie used only for SetCursorName requests.
type SetCursorNameCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// GetCursorNameCookie is a cookie used only for GetCursorName requests.
type GetCursorNameCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// GetCursorNameReply represents the data returned from a GetCursorName request.
type GetCursorNameReply 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
// padding: 1 bytes
Atom xproto.Atom
Nbytes uint16
// padding: 18 bytes
Name string // size: xgb.Pad((int(Nbytes) * 1))
}
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests.
type GetCursorImageAndNameCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// GetCursorImageAndName sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetCursorImageAndNameCookie.Reply()
func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(getCursorImageAndNameRequest(c), cookie)
return GetCursorImageAndNameCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// GetCursorImageAndNameUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(getCursorImageAndNameRequest(c), cookie)
return GetCursorImageAndNameCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// GetCursorImageAndNameReply represents the data returned from a GetCursorImageAndName request.
type GetCursorImageAndNameReply 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
// padding: 1 bytes
X int16
Y int16
Width uint16
Height uint16
Xhot uint16
Yhot uint16
CursorSerial uint32
CursorAtom xproto.Atom
Nbytes uint16
// padding: 2 bytes
Name string // size: xgb.Pad((int(Nbytes) * 1))
CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4))
}
2012-05-11 05:57:34 +02:00
// Reply blocks and returns the reply data for a GetCursorImageAndName request.
func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return getCursorImageAndNameReply(buf), nil
}
2012-05-11 05:57:34 +02:00
// getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value.
func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply {
v := new(GetCursorImageAndNameReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.X = int16(xgb.Get16(buf[b:]))
b += 2
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
v.Width = xgb.Get16(buf[b:])
b += 2
v.Height = xgb.Get16(buf[b:])
b += 2
v.Xhot = xgb.Get16(buf[b:])
b += 2
v.Yhot = xgb.Get16(buf[b:])
b += 2
v.CursorSerial = xgb.Get32(buf[b:])
b += 4
v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:]))
b += 4
v.Nbytes = xgb.Get16(buf[b:])
b += 2
b += 2 // padding
{
byteString := make([]byte, v.Nbytes)
copy(byteString[:v.Nbytes], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.Nbytes))
}
v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height)))
for i := 0; i < int((int(v.Width) * int(v.Height))); i++ {
v.CursorImage[i] = xgb.Get32(buf[b:])
b += 4
}
b = xgb.Pad(b)
return v
}
// Write request to wire for GetCursorImageAndName
2012-05-11 05:57:34 +02:00
// getCursorImageAndNameRequest writes a GetCursorImageAndName request to a byte slice.
func getCursorImageAndNameRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["XFIXES"]
b += 1
buf[b] = 25 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2012-05-11 05:57:34 +02:00
// ChangeCursorCookie is a cookie used only for ChangeCursor requests.
type ChangeCursorCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// ChangeCursor sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(changeCursorRequest(c, Source, Destination), cookie)
return ChangeCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// ChangeCursorChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeCursorCookie.Check()
func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(changeCursorRequest(c, Source, Destination), cookie)
return ChangeCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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 ChangeCursor
2012-05-11 05:57:34 +02:00
// 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)
buf[b] = c.Extensions["XFIXES"]
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(Source))
b += 4
xgb.Put32(buf[b:], uint32(Destination))
b += 4
return buf
}
2012-05-11 05:57:34 +02:00
// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests.
type ChangeCursorByNameCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// ExpandRegionCookie is a cookie used only for ExpandRegion requests.
type ExpandRegionCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// 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}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred 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
2012-05-11 05:57:34 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
// HideCursorCookie is a cookie used only for HideCursor requests.
type HideCursorCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// HideCursor sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(hideCursorRequest(c, Window), cookie)
return HideCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// HideCursorChecked sends a checked request.
// If an error occurs, it can be retrieved using HideCursorCookie.Check()
func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(hideCursorRequest(c, Window), cookie)
return HideCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook HideCursorCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for HideCursor
2012-05-11 05:57:34 +02:00
// hideCursorRequest writes a HideCursor request to a byte slice.
func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["XFIXES"]
b += 1
buf[b] = 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(Window))
b += 4
return buf
}
2012-05-11 05:57:34 +02:00
// ShowCursorCookie is a cookie used only for ShowCursor requests.
type ShowCursorCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// ShowCursor sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(showCursorRequest(c, Window), cookie)
return ShowCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// ShowCursorChecked sends a checked request.
// If an error occurs, it can be retrieved using ShowCursorCookie.Check()
func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie {
if _, ok := c.Extensions["XFIXES"]; !ok {
panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(showCursorRequest(c, Window), cookie)
return ShowCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook ShowCursorCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for ShowCursor
2012-05-11 05:57:34 +02:00
// showCursorRequest writes a ShowCursor request to a byte slice.
func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
buf[b] = c.Extensions["XFIXES"]
b += 1
buf[b] = 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
return buf
}