diff options
author | Andrew Gallant <jamslam@gmail.com> | 2013-08-11 20:43:26 -0400 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-09-08 16:49:17 +0200 |
commit | 0685fb57e14104ee4ad9f70ec94f787a9a22c028 (patch) | |
tree | c52429c82379c154c95dbfafcfc52460ec9168c0 /nexgb/xfixes/xfixes.go | |
parent | 4b20ffaf4f4cc756832a6d064d5dfe182f16b0e9 (diff) | |
download | haven-0685fb57e14104ee4ad9f70ec94f787a9a22c028.tar.gz haven-0685fb57e14104ee4ad9f70ec94f787a9a22c028.tar.xz haven-0685fb57e14104ee4ad9f70ec94f787a9a22c028.zip |
Update to latest xproto XML.
Diffstat (limited to 'nexgb/xfixes/xfixes.go')
-rw-r--r-- | nexgb/xfixes/xfixes.go | 2212 |
1 files changed, 1106 insertions, 1106 deletions
diff --git a/nexgb/xfixes/xfixes.go b/nexgb/xfixes/xfixes.go index 42e9e99..76ffddf 100644 --- a/nexgb/xfixes/xfixes.go +++ b/nexgb/xfixes/xfixes.go @@ -2,7 +2,7 @@ package xfixes /* - This file was generated by xfixes.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xfixes.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -42,79 +42,196 @@ func init() { xgb.NewExtErrorFuncs["XFIXES"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int16' +// BadBadRegion is the error number for a BadBadRegion. +const BadBadRegion = 0 -// Skipping definition for base type 'Int32' +type BadRegionError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Void' +// BadRegionErrorNew constructs a BadRegionError value that implements xgb.Error from a byte slice. +func BadRegionErrorNew(buf []byte) xgb.Error { + v := BadRegionError{} + v.NiceName = "BadRegion" -// Skipping definition for base type 'Byte' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Int8' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Card16' + return v +} -// Skipping definition for base type 'Char' +// SequenceId returns the sequence id attached to the BadBadRegion error. +// This is mostly used internally. +func (err BadRegionError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Card32' +// BadId returns the 'BadValue' number if one exists for the BadBadRegion error. If no bad value exists, 0 is returned. +func (err BadRegionError) BadId() uint32 { + return 0 +} -// Skipping definition for base type 'Double' +// Error returns a rudimentary string representation of the BadBadRegion error. -// Skipping definition for base type 'Bool' +func (err BadRegionError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Float' +func init() { + xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew +} -// Skipping definition for base type 'Card8' +// CursorNotify is the event number for a CursorNotifyEvent. +const CursorNotify = 1 + +type CursorNotifyEvent struct { + Sequence uint16 + Subtype byte + Window xproto.Window + CursorSerial uint32 + Timestamp xproto.Timestamp + Name xproto.Atom + // padding: 12 bytes +} + +// CursorNotifyEventNew constructs a CursorNotifyEvent value that implements xgb.Event from a byte slice. +func CursorNotifyEventNew(buf []byte) xgb.Event { + v := CursorNotifyEvent{} + b := 1 // don't read event number + + v.Subtype = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Name = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + return v +} + +// Bytes writes a CursorNotifyEvent value to a byte slice. +func (v CursorNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Subtype + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], v.CursorSerial) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + b += 12 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the CursorNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CursorNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of CursorNotifyEvent. +func (v CursorNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("CursorSerial: %d", v.CursorSerial)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Name: %d", v.Name)) + return "CursorNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew +} const ( - SaveSetModeInsert = 0 - SaveSetModeDelete = 1 + CursorNotifyDisplayCursor = 0 ) const ( - SaveSetTargetNearest = 0 - SaveSetTargetRoot = 1 + CursorNotifyMaskDisplayCursor = 1 ) +type Region uint32 + +func NewRegionId(c *xgb.Conn) (Region, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Region(id), nil +} + const ( - SaveSetMappingMap = 0 - SaveSetMappingUnmap = 1 + RegionNone = 0 ) const ( - SelectionEventSetSelectionOwner = 0 - SelectionEventSelectionWindowDestroy = 1 - SelectionEventSelectionClientClose = 2 + SaveSetMappingMap = 0 + SaveSetMappingUnmap = 1 ) const ( - SelectionEventMaskSetSelectionOwner = 1 - SelectionEventMaskSelectionWindowDestroy = 2 - SelectionEventMaskSelectionClientClose = 4 + SaveSetModeInsert = 0 + SaveSetModeDelete = 1 ) const ( - CursorNotifyDisplayCursor = 0 + SaveSetTargetNearest = 0 + SaveSetTargetRoot = 1 ) const ( - CursorNotifyMaskDisplayCursor = 1 + SelectionEventSetSelectionOwner = 0 + SelectionEventSelectionWindowDestroy = 1 + SelectionEventSelectionClientClose = 2 ) const ( - RegionNone = 0 + SelectionEventMaskSetSelectionOwner = 1 + SelectionEventMaskSelectionWindowDestroy = 2 + SelectionEventMaskSelectionClientClose = 4 ) -type Region uint32 - -func NewRegionId(c *xgb.Conn) (Region, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Region(id), nil -} - // SelectionNotify is the event number for a SelectionNotifyEvent. const SelectionNotify = 0 @@ -218,241 +335,147 @@ func init() { xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew } -// CursorNotify is the event number for a CursorNotifyEvent. -const CursorNotify = 1 - -type CursorNotifyEvent struct { - Sequence uint16 - Subtype byte - Window xproto.Window - CursorSerial uint32 - Timestamp xproto.Timestamp - Name xproto.Atom - // padding: 12 bytes -} - -// CursorNotifyEventNew constructs a CursorNotifyEvent value that implements xgb.Event from a byte slice. -func CursorNotifyEventNew(buf []byte) xgb.Event { - v := CursorNotifyEvent{} - b := 1 // don't read event number - - v.Subtype = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - v.CursorSerial = xgb.Get32(buf[b:]) - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Name = xproto.Atom(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Bool' - b += 12 // padding +// Skipping definition for base type 'Byte' - return v -} +// Skipping definition for base type 'Card8' -// Bytes writes a CursorNotifyEvent value to a byte slice. -func (v CursorNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 +// Skipping definition for base type 'Char' - // write event number - buf[b] = 1 - b += 1 +// Skipping definition for base type 'Void' - buf[b] = v.Subtype - b += 1 +// Skipping definition for base type 'Double' - b += 2 // skip sequence number +// Skipping definition for base type 'Float' - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 +// Skipping definition for base type 'Int16' - xgb.Put32(buf[b:], v.CursorSerial) - b += 4 +// Skipping definition for base type 'Int32' - xgb.Put32(buf[b:], uint32(v.Timestamp)) - b += 4 +// Skipping definition for base type 'Int8' - xgb.Put32(buf[b:], uint32(v.Name)) - b += 4 +// Skipping definition for base type 'Card16' - b += 12 // padding +// Skipping definition for base type 'Card32' - return buf +// ChangeCursorCookie is a cookie used only for ChangeCursor requests. +type ChangeCursorCookie struct { + *xgb.Cookie } -// 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 +// 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} } -// String is a rudimentary string representation of CursorNotifyEvent. -func (v CursorNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("CursorSerial: %d", v.CursorSerial)) - fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, xgb.Sprintf("Name: %d", v.Name)) - return "CursorNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCursorCookie.Check() +func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} } -func init() { - xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeCursorCookie) Check() error { + return cook.Cookie.Check() } -// BadBadRegion is the error number for a BadBadRegion. -const BadBadRegion = 0 - -type BadRegionError struct { - Sequence uint16 - NiceName string -} +// Write request to wire for ChangeCursor +// changeCursorRequest writes a ChangeCursor request to a byte slice. +func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { + size := 12 + b := 0 + buf := make([]byte, size) -// BadRegionErrorNew constructs a BadRegionError value that implements xgb.Error from a byte slice. -func BadRegionErrorNew(buf []byte) xgb.Error { - v := BadRegionError{} - v.NiceName = "BadRegion" + buf[b] = c.Extensions["XFIXES"] + b += 1 - b := 1 // skip error determinant - b += 1 // don't read error number + buf[b] = 26 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return v -} - -// SequenceId returns the sequence id attached to the BadBadRegion error. -// This is mostly used internally. -func (err BadRegionError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadBadRegion error. If no bad value exists, 0 is returned. -func (err BadRegionError) BadId() uint32 { - return 0 -} - -// Error returns a rudimentary string representation of the BadBadRegion error. + xgb.Put32(buf[b:], uint32(Source)) + b += 4 -func (err BadRegionError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 -func init() { - xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew + return buf } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests. +type ChangeCursorByNameCookie struct { *xgb.Cookie } -// QueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() -func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionUnchecked sends an unchecked request. +// ChangeCursorByName sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { +func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} } -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// ChangeCursorByNameChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCursorByNameCookie.Check() +func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - return queryVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeCursorByNameCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 +// Write request to wire for ChangeCursorByName +// changeCursorByNameRequest writes a ChangeCursorByName request to a byte slice. +func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 27 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ClientMajorVersion) + xgb.Put32(buf[b:], uint32(Src)) b += 4 - xgb.Put32(buf[b:], ClientMinorVersion) - b += 4 + xgb.Put16(buf[b:], Nbytes) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) return buf } @@ -523,103 +546,42 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window return buf } -// SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests. -type SelectSelectionInputCookie struct { - *xgb.Cookie -} - -// SelectSelectionInput sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) - return SelectSelectionInputCookie{cookie} -} - -// SelectSelectionInputChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectSelectionInputCookie.Check() -func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) - return SelectSelectionInputCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SelectSelectionInputCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SelectSelectionInput -// selectSelectionInputRequest writes a SelectSelectionInput request to a byte slice. -func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. -type SelectCursorInputCookie struct { +// CopyRegionCookie is a cookie used only for CopyRegion requests. +type CopyRegionCookie struct { *xgb.Cookie } -// SelectCursorInput sends an unchecked request. +// CopyRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { +func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) - return SelectCursorInputCookie{cookie} + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{cookie} } -// SelectCursorInputChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectCursorInputCookie.Check() -func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { +// 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 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) - return SelectCursorInputCookie{cookie} + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SelectCursorInputCookie) Check() error { +func (cook CopyRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SelectCursorInput -// selectCursorInputRequest writes a SelectCursorInput request to a byte slice. -func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { +// Write request to wire for CopyRegion +// copyRegionRequest writes a CopyRegion request to a byte slice. +func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -627,138 +589,18 @@ func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint3 buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - xgb.Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// GetCursorImageCookie is a cookie used only for GetCursorImage requests. -type GetCursorImageCookie struct { - *xgb.Cookie -} - -// GetCursorImage sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCursorImageCookie.Reply() -func GetCursorImage(c *xgb.Conn) GetCursorImageCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCursorImageRequest(c), cookie) - return GetCursorImageCookie{cookie} -} - -// GetCursorImageUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getCursorImageRequest(c), cookie) - return GetCursorImageCookie{cookie} -} - -// GetCursorImageReply represents the data returned from a GetCursorImage request. -type GetCursorImageReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - // padding: 8 bytes - CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) -} - -// Reply blocks and returns the reply data for a GetCursorImage request. -func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getCursorImageReply(buf), nil -} - -// getCursorImageReply reads a byte slice into a GetCursorImageReply value. -func getCursorImageReply(buf []byte) *GetCursorImageReply { - v := new(GetCursorImageReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Source)) 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:]) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - b += 8 // padding - - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) - - return v -} - -// Write request to wire for GetCursorImage -// getCursorImageRequest writes a GetCursorImage request to a byte slice. -func getCursorImageRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - return buf } @@ -877,69 +719,6 @@ func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pix return buf } -// CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests. -type CreateRegionFromWindowCookie struct { - *xgb.Cookie -} - -// CreateRegionFromWindow sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) - return CreateRegionFromWindowCookie{cookie} -} - -// CreateRegionFromWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateRegionFromWindowCookie.Check() -func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) - return CreateRegionFromWindowCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateRegionFromWindowCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CreateRegionFromWindow -// createRegionFromWindowRequest writes a CreateRegionFromWindow request to a byte slice. -func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFIXES"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Region)) - b += 4 - - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = byte(Kind) - b += 1 - - b += 3 // padding - - return buf -} - // CreateRegionFromGCCookie is a cookie used only for CreateRegionFromGC requests. type CreateRegionFromGCCookie struct { *xgb.Cookie @@ -1056,6 +835,69 @@ func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.P return buf } +// CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests. +type CreateRegionFromWindowCookie struct { + *xgb.Cookie +} + +// CreateRegionFromWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} +} + +// CreateRegionFromWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromWindowCookie.Check() +func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'CreateRegionFromWindow' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateRegionFromWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromWindow +// createRegionFromWindowRequest writes a CreateRegionFromWindow request to a byte slice. +func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = byte(Kind) + b += 1 + + b += 3 // padding + + return buf +} + // DestroyRegionCookie is a cookie used only for DestroyRegion requests. type DestroyRegionCookie struct { *xgb.Cookie @@ -1111,473 +953,690 @@ func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { return buf } -// SetRegionCookie is a cookie used only for SetRegion requests. -type SetRegionCookie struct { +// ExpandRegionCookie is a cookie used only for ExpandRegion requests. +type ExpandRegionCookie struct { *xgb.Cookie } -// SetRegion sends an unchecked request. +// ExpandRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { +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 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) - return SetRegionCookie{cookie} + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{cookie} } -// SetRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetRegionCookie.Check() -func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { +// 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 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) - return SetRegionCookie{cookie} + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetRegionCookie) Check() error { +func (cook ExpandRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetRegion -// setRegionRequest writes a SetRegion request to a byte slice. -func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +// Write request to wire for ExpandRegion +// expandRegionRequest writes a ExpandRegion request to a byte slice. +func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 28 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - b += xproto.RectangleListBytes(buf[b:], Rectangles) + 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 } -// CopyRegionCookie is a cookie used only for CopyRegion requests. -type CopyRegionCookie struct { +// FetchRegionCookie is a cookie used only for FetchRegion requests. +type FetchRegionCookie struct { *xgb.Cookie } -// CopyRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { +// 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 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) - return CopyRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{cookie} } -// CopyRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyRegionCookie.Check() -func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { +// 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 'CopyRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) - return CopyRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyRegionCookie) Check() error { - return cook.Cookie.Check() +// FetchRegionReply represents the data returned from a FetchRegion request. +type FetchRegionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Extents xproto.Rectangle + // padding: 16 bytes + Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Write request to wire for CopyRegion -// copyRegionRequest writes a CopyRegion request to a byte slice. -func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { - size := 12 +// Reply blocks and returns the reply data for a FetchRegion request. +func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return fetchRegionReply(buf), nil +} + +// fetchRegionReply reads a byte slice into a FetchRegionReply value. +func fetchRegionReply(buf []byte) *FetchRegionReply { + v := new(FetchRegionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Extents = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Extents) + + b += 16 // padding + + v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for FetchRegion +// fetchRegionRequest writes a FetchRegion request to a byte slice. +func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf } -// UnionRegionCookie is a cookie used only for UnionRegion requests. -type UnionRegionCookie struct { +// GetCursorImageCookie is a cookie used only for GetCursorImage requests. +type GetCursorImageCookie struct { *xgb.Cookie } -// UnionRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { +// 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 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) - return UnionRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{cookie} } -// UnionRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using UnionRegionCookie.Check() -func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { +// 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 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImage' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) - return UnionRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UnionRegionCookie) Check() error { - return cook.Cookie.Check() +// GetCursorImageReply represents the data returned from a GetCursorImage request. +type GetCursorImageReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + // padding: 8 bytes + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) } -// Write request to wire for UnionRegion -// unionRegionRequest writes a UnionRegion request to a byte slice. -func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { - size := 16 +// Reply blocks and returns the reply data for a GetCursorImage request. +func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageReply(buf), nil +} + +// getCursorImageReply reads a byte slice into a GetCursorImageReply value. +func getCursorImageReply(buf []byte) *GetCursorImageReply { + v := new(GetCursorImageReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + b += 2 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) + for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { + v.CursorImage[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCursorImage +// getCursorImageRequest writes a GetCursorImage request to a byte slice. +func getCursorImageRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Source1)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - return buf } -// IntersectRegionCookie is a cookie used only for IntersectRegion requests. -type IntersectRegionCookie struct { +// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. +type GetCursorImageAndNameCookie struct { *xgb.Cookie } -// IntersectRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { +// 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 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) - return IntersectRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{cookie} } -// IntersectRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using IntersectRegionCookie.Check() -func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { +// 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 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) - return IntersectRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook IntersectRegionCookie) Check() error { - return cook.Cookie.Check() +// GetCursorImageAndNameReply represents the data returned from a GetCursorImageAndName request. +type GetCursorImageAndNameReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + CursorAtom xproto.Atom + Nbytes uint16 + // padding: 2 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) } -// Write request to wire for IntersectRegion -// intersectRegionRequest writes a IntersectRegion request to a byte slice. -func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { - size := 16 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetCursorImageAndName request. +func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageAndNameReply(buf), nil +} - buf[b] = c.Extensions["XFIXES"] - b += 1 +// getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value. +func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { + v := new(GetCursorImageAndNameReply) + b := 1 // skip reply determinant - buf[b] = 14 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Source1)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Source2)) + 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 - xgb.Put32(buf[b:], uint32(Destination)) + 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 +// 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 } -// SubtractRegionCookie is a cookie used only for SubtractRegion requests. -type SubtractRegionCookie struct { +// GetCursorNameCookie is a cookie used only for GetCursorName requests. +type GetCursorNameCookie struct { *xgb.Cookie } -// SubtractRegion sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { +// 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 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) - return SubtractRegionCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} } -// SubtractRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SubtractRegionCookie.Check() -func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { +// 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 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) - return SubtractRegionCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} } -// Check returns an error if one occurred 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() +// GetCursorNameReply represents the data returned from a GetCursorName request. +type GetCursorNameReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Atom xproto.Atom + Nbytes uint16 + // padding: 18 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) } -// Write request to wire for SubtractRegion -// subtractRegionRequest writes a SubtractRegion request to a byte slice. -func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { - size := 16 +// Reply blocks and returns the reply data for a GetCursorName request. +func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorNameReply(buf), nil +} + +// getCursorNameReply reads a byte slice into a GetCursorNameReply value. +func getCursorNameReply(buf []byte) *GetCursorNameReply { + v := new(GetCursorNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + return v +} + +// Write request to wire for GetCursorName +// getCursorNameRequest writes a GetCursorName request to a byte slice. +func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 15 // request opcode + buf[b] = 24 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Source1)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source2)) - b += 4 - - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 return buf } -// InvertRegionCookie is a cookie used only for InvertRegion requests. -type InvertRegionCookie struct { +// HideCursorCookie is a cookie used only for HideCursor requests. +type HideCursorCookie struct { *xgb.Cookie } -// InvertRegion sends an unchecked request. +// HideCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { +func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) - return InvertRegionCookie{cookie} + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{cookie} } -// InvertRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using InvertRegionCookie.Check() -func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { +// 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 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) - return InvertRegionCookie{cookie} + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook InvertRegionCookie) Check() error { +func (cook HideCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for InvertRegion -// invertRegionRequest writes a InvertRegion request to a byte slice. -func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { - size := 20 +// Write request to wire for HideCursor +// hideCursorRequest writes a HideCursor request to a byte slice. +func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 16 // request opcode + buf[b] = 29 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Source)) - b += 4 - - { - structBytes := Bounds.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// TranslateRegionCookie is a cookie used only for TranslateRegion requests. -type TranslateRegionCookie struct { +// IntersectRegionCookie is a cookie used only for IntersectRegion requests. +type IntersectRegionCookie struct { *xgb.Cookie } -// TranslateRegion sends an unchecked request. +// IntersectRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { +func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'IntersectRegion' 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} + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{cookie} } -// TranslateRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using TranslateRegionCookie.Check() -func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { +// 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 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'IntersectRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) - return TranslateRegionCookie{cookie} + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook TranslateRegionCookie) Check() error { +func (cook IntersectRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for TranslateRegion -// translateRegionRequest writes a TranslateRegion request to a byte slice. -func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { - size := 12 +// Write request to wire for IntersectRegion +// intersectRegionRequest writes a IntersectRegion request to a byte slice. +func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 17 // request opcode + buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Source1)) b += 4 - xgb.Put16(buf[b:], uint16(Dx)) - b += 2 + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 - xgb.Put16(buf[b:], uint16(Dy)) - b += 2 + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 return buf } -// RegionExtentsCookie is a cookie used only for RegionExtents requests. -type RegionExtentsCookie struct { +// InvertRegionCookie is a cookie used only for InvertRegion requests. +type InvertRegionCookie struct { *xgb.Cookie } -// RegionExtents sends an unchecked request. +// InvertRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { +func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) - return RegionExtentsCookie{cookie} + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{cookie} } -// RegionExtentsChecked sends a checked request. -// If an error occurs, it can be retrieved using RegionExtentsCookie.Check() -func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { +// 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 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'InvertRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) - return RegionExtentsCookie{cookie} + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook RegionExtentsCookie) Check() error { +func (cook InvertRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RegionExtents -// regionExtentsRequest writes a RegionExtents request to a byte slice. -func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { - size := 12 +// Write request to wire for InvertRegion +// invertRegionRequest writes a InvertRegion request to a byte slice. +func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1586,51 +1645,57 @@ func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte 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 } -// FetchRegionCookie is a cookie used only for FetchRegion requests. -type FetchRegionCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// FetchRegion sends a checked request. -// If an error occurs, it will be returned with the reply by calling FetchRegionCookie.Reply() -func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie { +// 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 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(fetchRegionRequest(c, Region), cookie) - return FetchRegionCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// FetchRegionUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'FetchRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(fetchRegionRequest(c, Region), cookie) - return FetchRegionCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} } -// FetchRegionReply represents the data returned from a FetchRegion request. -type FetchRegionReply struct { +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Extents xproto.Rectangle + MajorVersion uint32 + MinorVersion uint32 // padding: 16 bytes - Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Reply blocks and returns the reply data for a FetchRegion request. -func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { +// 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 @@ -1638,12 +1703,12 @@ func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { if buf == nil { return nil, nil } - return fetchRegionReply(buf), nil + return queryVersionReply(buf), nil } -// fetchRegionReply reads a byte slice into a FetchRegionReply value. -func fetchRegionReply(buf []byte) *FetchRegionReply { - v := new(FetchRegionReply) +// 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 @@ -1654,208 +1719,194 @@ func fetchRegionReply(buf []byte) *FetchRegionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Extents = xproto.Rectangle{} - b += xproto.RectangleRead(buf[b:], &v.Extents) + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 - b += 16 // padding + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 - v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) - b += xproto.RectangleReadList(buf[b:], v.Rectangles) + b += 16 // padding return v } -// Write request to wire for FetchRegion -// fetchRegionRequest writes a FetchRegion request to a byte slice. -func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { - size := 8 +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) b += 4 return buf } -// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests. -type SetGCClipRegionCookie struct { +// RegionExtentsCookie is a cookie used only for RegionExtents requests. +type RegionExtentsCookie struct { *xgb.Cookie } -// SetGCClipRegion sends an unchecked request. +// RegionExtents sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { +func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) - return SetGCClipRegionCookie{cookie} + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} } -// SetGCClipRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetGCClipRegionCookie.Check() -func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { +// 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 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'RegionExtents' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) - return SetGCClipRegionCookie{cookie} + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetGCClipRegionCookie) Check() error { +func (cook RegionExtentsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetGCClipRegion -// setGCClipRegionRequest writes a SetGCClipRegion request to a byte slice. -func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { - size := 16 +// Write request to wire for RegionExtents +// regionExtentsRequest writes a RegionExtents request to a byte slice. +func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Destination)) b += 4 - xgb.Put16(buf[b:], uint16(XOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOrigin)) - b += 2 - return buf } -// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests. -type SetWindowShapeRegionCookie struct { +// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. +type SelectCursorInputCookie struct { *xgb.Cookie } -// SetWindowShapeRegion sends an unchecked request. +// SelectCursorInput sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { +func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) - return SetWindowShapeRegionCookie{cookie} + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{cookie} } -// SetWindowShapeRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetWindowShapeRegionCookie.Check() -func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { +// 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 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectCursorInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) - return SetWindowShapeRegionCookie{cookie} + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetWindowShapeRegionCookie) Check() error { +func (cook SelectCursorInputCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetWindowShapeRegion -// setWindowShapeRegionRequest writes a SetWindowShapeRegion request to a byte slice. -func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { - size := 20 +// Write request to wire for SelectCursorInput +// selectCursorInputRequest writes a SelectCursorInput request to a byte slice. +func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 21 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Dest)) + xgb.Put32(buf[b:], uint32(Window)) 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)) + xgb.Put32(buf[b:], EventMask) b += 4 return buf } -// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests. -type SetPictureClipRegionCookie struct { +// SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests. +type SelectSelectionInputCookie struct { *xgb.Cookie } -// SetPictureClipRegion sends an unchecked request. +// SelectSelectionInput sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { +func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) - return SetPictureClipRegionCookie{cookie} + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{cookie} } -// SetPictureClipRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPictureClipRegionCookie.Check() -func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { +// 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 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectSelectionInput' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) - return SetPictureClipRegionCookie{cookie} + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetPictureClipRegionCookie) Check() error { +func (cook SelectSelectionInputCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetPictureClipRegion -// setPictureClipRegionRequest writes a SetPictureClipRegion request to a byte slice. -func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { +// Write request to wire for SelectSelectionInput +// selectSelectionInputRequest writes a SelectSelectionInput request to a byte slice. +func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte { size := 16 b := 0 buf := make([]byte, size) @@ -1863,23 +1914,20 @@ func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Reg buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 22 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Picture)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Region)) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 - xgb.Put16(buf[b:], uint16(XOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(YOrigin)) - b += 2 + xgb.Put32(buf[b:], EventMask) + b += 4 return buf } @@ -1947,541 +1995,493 @@ func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name return buf } -// GetCursorNameCookie is a cookie used only for GetCursorName requests. -type GetCursorNameCookie struct { +// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests. +type SetGCClipRegionCookie struct { *xgb.Cookie } -// GetCursorName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCursorNameCookie.Reply() -func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { - if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getCursorNameRequest(c, Cursor), cookie) - return GetCursorNameCookie{cookie} -} - -// GetCursorNameUnchecked sends an unchecked request. +// SetGCClipRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { +func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'GetCursorName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetGCClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getCursorNameRequest(c, Cursor), cookie) - return GetCursorNameCookie{cookie} -} - -// GetCursorNameReply represents the data returned from a GetCursorName request. -type GetCursorNameReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Atom xproto.Atom - Nbytes uint16 - // padding: 18 bytes - Name string // size: xgb.Pad((int(Nbytes) * 1)) + cookie := c.NewCookie(false, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} } -// 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 +// 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.") } - return getCursorNameReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} } -// 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 +// Check returns an error if one occurred 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 GetCursorName -// getCursorNameRequest writes a GetCursorName request to a byte slice. -func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { - size := 8 +// Write request to wire for SetGCClipRegion +// setGCClipRegionRequest writes a SetGCClipRegion request to a byte slice. +func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 24 // request opcode + buf[b] = 20 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) + 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 } -// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. -type GetCursorImageAndNameCookie struct { +// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests. +type SetPictureClipRegionCookie struct { *xgb.Cookie } -// GetCursorImageAndName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetCursorImageAndNameCookie.Reply() -func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie { +// 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 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureClipRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getCursorImageAndNameRequest(c), cookie) - return GetCursorImageAndNameCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} } -// GetCursorImageAndNameUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie { +// 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 'GetCursorImageAndName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPictureClipRegion' 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} + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} } -// GetCursorImageAndNameReply represents the data returned from a GetCursorImageAndName request. -type GetCursorImageAndNameReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - CursorAtom xproto.Atom - Nbytes uint16 - // padding: 2 bytes - Name string // size: xgb.Pad((int(Nbytes) * 1)) - CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) +// Check returns an error if one occurred 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() } -// 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 -} +// Write request to wire for SetPictureClipRegion +// setPictureClipRegionRequest writes a SetPictureClipRegion request to a byte slice. +func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) -// getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value. -func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { - v := new(GetCursorImageAndNameReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["XFIXES"] + b += 1 - b += 1 // padding + buf[b] = 22 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Picture)) b += 4 - v.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 + xgb.Put32(buf[b:], uint32(Region)) + b += 4 - v.Xhot = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(XOrigin)) b += 2 - v.Yhot = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(YOrigin)) 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 + return buf +} - b += 2 // padding +// SetRegionCookie is a cookie used only for SetRegion requests. +type SetRegionCookie struct { + *xgb.Cookie +} - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Nbytes)) +// SetRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } + cookie := c.NewCookie(false, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = xgb.Get32(buf[b:]) - b += 4 +// SetRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetRegionCookie.Check() +func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + if _, ok := c.Extensions["XFIXES"]; !ok { + panic("Cannot issue request 'SetRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetRegionCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetCursorImageAndName -// getCursorImageAndNameRequest writes a GetCursorImageAndName request to a byte slice. -func getCursorImageAndNameRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for SetRegion +// setRegionRequest writes a SetRegion request to a byte slice. +func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 25 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + return buf } -// ChangeCursorCookie is a cookie used only for ChangeCursor requests. -type ChangeCursorCookie struct { +// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests. +type SetWindowShapeRegionCookie struct { *xgb.Cookie } -// ChangeCursor sends an unchecked request. +// SetWindowShapeRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { +func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) - return ChangeCursorCookie{cookie} + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{cookie} } -// ChangeCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeCursorCookie.Check() -func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { +// SetWindowShapeRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetWindowShapeRegionCookie.Check() +func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SetWindowShapeRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) - return ChangeCursorCookie{cookie} + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeCursorCookie) Check() error { +func (cook SetWindowShapeRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeCursor -// changeCursorRequest writes a ChangeCursor request to a byte slice. -func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { - size := 12 +// Write request to wire for SetWindowShapeRegion +// setWindowShapeRegionRequest writes a SetWindowShapeRegion request to a byte slice. +func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Source)) + xgb.Put32(buf[b:], uint32(Dest)) b += 4 - xgb.Put32(buf[b:], uint32(Destination)) + buf[b] = byte(DestKind) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf } -// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests. -type ChangeCursorByNameCookie struct { +// ShowCursorCookie is a cookie used only for ShowCursor requests. +type ShowCursorCookie struct { *xgb.Cookie } -// ChangeCursorByName sends an unchecked request. +// ShowCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { +func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) - return ChangeCursorByNameCookie{cookie} + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{cookie} } -// ChangeCursorByNameChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeCursorByNameCookie.Check() -func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { +// ShowCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using ShowCursorCookie.Check() +func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ChangeCursorByName' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) - return ChangeCursorByNameCookie{cookie} + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeCursorByNameCookie) Check() error { +func (cook ShowCursorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeCursorByName -// changeCursorByNameRequest writes a ChangeCursorByName request to a byte slice. -func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +// Write request to wire for ShowCursor +// showCursorRequest writes a ShowCursor request to a byte slice. +func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 27 // request opcode + buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Src)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Nbytes) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:Nbytes]) - b += xgb.Pad(int(Nbytes)) - return buf } -// ExpandRegionCookie is a cookie used only for ExpandRegion requests. -type ExpandRegionCookie struct { +// SubtractRegionCookie is a cookie used only for SubtractRegion requests. +type SubtractRegionCookie struct { *xgb.Cookie } -// ExpandRegion sends an unchecked request. +// SubtractRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { +func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) - return ExpandRegionCookie{cookie} + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{cookie} } -// ExpandRegionChecked sends a checked request. -// If an error occurs, it can be retrieved using ExpandRegionCookie.Check() -func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { +// SubtractRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SubtractRegionCookie.Check() +func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ExpandRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'SubtractRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) - return ExpandRegionCookie{cookie} + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ExpandRegionCookie) Check() error { +func (cook SubtractRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ExpandRegion -// expandRegionRequest writes a ExpandRegion request to a byte slice. -func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { - size := 20 +// Write request to wire for SubtractRegion +// subtractRegionRequest writes a SubtractRegion request to a byte slice. +func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 28 // request opcode + buf[b] = 15 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Source)) + xgb.Put32(buf[b:], uint32(Source1)) b += 4 - xgb.Put32(buf[b:], uint32(Destination)) + xgb.Put32(buf[b:], uint32(Source2)) b += 4 - xgb.Put16(buf[b:], Left) - b += 2 - - xgb.Put16(buf[b:], Right) - b += 2 - - xgb.Put16(buf[b:], Top) - b += 2 - - xgb.Put16(buf[b:], Bottom) - b += 2 + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 return buf } -// HideCursorCookie is a cookie used only for HideCursor requests. -type HideCursorCookie struct { +// TranslateRegionCookie is a cookie used only for TranslateRegion requests. +type TranslateRegionCookie struct { *xgb.Cookie } -// HideCursor sends an unchecked request. +// TranslateRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { +func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(hideCursorRequest(c, Window), cookie) - return HideCursorCookie{cookie} + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{cookie} } -// HideCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using HideCursorCookie.Check() -func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie { +// TranslateRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using TranslateRegionCookie.Check() +func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'HideCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'TranslateRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(hideCursorRequest(c, Window), cookie) - return HideCursorCookie{cookie} + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook HideCursorCookie) Check() error { +func (cook TranslateRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for HideCursor -// hideCursorRequest writes a HideCursor request to a byte slice. -func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for TranslateRegion +// translateRegionRequest writes a TranslateRegion request to a byte slice. +func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 29 // request opcode + buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Region)) b += 4 + xgb.Put16(buf[b:], uint16(Dx)) + b += 2 + + xgb.Put16(buf[b:], uint16(Dy)) + b += 2 + return buf } -// ShowCursorCookie is a cookie used only for ShowCursor requests. -type ShowCursorCookie struct { +// UnionRegionCookie is a cookie used only for UnionRegion requests. +type UnionRegionCookie struct { *xgb.Cookie } -// ShowCursor sends an unchecked request. +// UnionRegion sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { +func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(showCursorRequest(c, Window), cookie) - return ShowCursorCookie{cookie} + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{cookie} } -// ShowCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using ShowCursorCookie.Check() -func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { +// UnionRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using UnionRegionCookie.Check() +func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { if _, ok := c.Extensions["XFIXES"]; !ok { - panic("Cannot issue request 'ShowCursor' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") + panic("Cannot issue request 'UnionRegion' using the uninitialized extension 'XFIXES'. xfixes.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(showCursorRequest(c, Window), cookie) - return ShowCursorCookie{cookie} + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ShowCursorCookie) Check() error { +func (cook UnionRegionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ShowCursor -// showCursorRequest writes a ShowCursor request to a byte slice. -func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for UnionRegion +// unionRegionRequest writes a UnionRegion request to a byte slice. +func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 - buf[b] = 30 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf |