package xfixes /* This file was generated by xfixes.xml on May 10 2012 4:20:28pm EDT. This file is automatically generated. Edit at your peril! */ import ( "github.com/BurntSushi/xgb" "github.com/BurntSushi/xgb/render" "github.com/BurntSushi/xgb/shape" "github.com/BurntSushi/xgb/xproto" ) // Init must be called before using the XFIXES extension. func Init(c *xgb.Conn) error { reply, err := xproto.QueryExtension(c, 6, "XFIXES").Reply() switch { case err != nil: return err case !reply.Present: return xgb.Errorf("No extension named XFIXES could be found on on the server.") } xgb.ExtLock.Lock() c.Extensions["XFIXES"] = reply.MajorOpcode for evNum, fun := range xgb.NewExtEventFuncs["XFIXES"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["XFIXES"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } xgb.ExtLock.Unlock() return nil } func init() { xgb.NewExtEventFuncs["XFIXES"] = make(map[int]xgb.NewEventFun) xgb.NewExtErrorFuncs["XFIXES"] = make(map[int]xgb.NewErrorFun) } // Skipping definition for base type 'Int8' // Skipping definition for base type 'Card16' // Skipping definition for base type 'Char' // Skipping definition for base type 'Card32' // Skipping definition for base type 'Double' // Skipping definition for base type 'Bool' // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' // Skipping definition for base type 'Int16' // Skipping definition for base type 'Int32' // Skipping definition for base type 'Void' // Skipping definition for base type 'Byte' const ( SaveSetModeInsert = 0 SaveSetModeDelete = 1 ) const ( SaveSetTargetNearest = 0 SaveSetTargetRoot = 1 ) const ( SaveSetMappingMap = 0 SaveSetMappingUnmap = 1 ) const ( SelectionEventSetSelectionOwner = 0 SelectionEventSelectionWindowDestroy = 1 SelectionEventSelectionClientClose = 2 ) const ( SelectionEventMaskSetSelectionOwner = 1 SelectionEventMaskSelectionWindowDestroy = 2 SelectionEventMaskSelectionClientClose = 4 ) const ( CursorNotifyDisplayCursor = 0 ) const ( CursorNotifyMaskDisplayCursor = 1 ) const ( RegionNone = 0 ) type Region uint32 func NewRegionId(c *xgb.Conn) (Region, error) { id, err := c.NewId() if err != nil { return 0, err } return Region(id), nil } // Event definition SelectionNotify (0) // Size: 32 const SelectionNotify = 0 type SelectionNotifyEvent struct { Sequence uint16 Subtype byte Window xproto.Window Owner xproto.Window Selection xproto.Atom Timestamp xproto.Timestamp SelectionTimestamp xproto.Timestamp // padding: 8 bytes } // Event read SelectionNotify func SelectionNotifyEventNew(buf []byte) xgb.Event { v := SelectionNotifyEvent{} b := 1 // don't read event number v.Subtype = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Window = xproto.Window(xgb.Get32(buf[b:])) b += 4 v.Owner = xproto.Window(xgb.Get32(buf[b:])) b += 4 v.Selection = xproto.Atom(xgb.Get32(buf[b:])) b += 4 v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 v.SelectionTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 b += 8 // padding return v } // Event write SelectionNotify func (v SelectionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number buf[b] = 0 b += 1 buf[b] = v.Subtype b += 1 b += 2 // skip sequence number xgb.Put32(buf[b:], uint32(v.Window)) b += 4 xgb.Put32(buf[b:], uint32(v.Owner)) b += 4 xgb.Put32(buf[b:], uint32(v.Selection)) b += 4 xgb.Put32(buf[b:], uint32(v.Timestamp)) b += 4 xgb.Put32(buf[b:], uint32(v.SelectionTimestamp)) b += 4 b += 8 // padding return buf } func (v SelectionNotifyEvent) ImplementsEvent() {} func (v SelectionNotifyEvent) SequenceId() uint16 { return v.Sequence } func (v SelectionNotifyEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) fieldVals = append(fieldVals, xgb.Sprintf("SelectionTimestamp: %d", v.SelectionTimestamp)) return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew } // Event definition CursorNotify (1) // Size: 32 const CursorNotify = 1 type CursorNotifyEvent struct { Sequence uint16 Subtype byte Window xproto.Window CursorSerial uint32 Timestamp xproto.Timestamp Name xproto.Atom // padding: 12 bytes } // Event read CursorNotify 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 } // Event write CursorNotify 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 } func (v CursorNotifyEvent) ImplementsEvent() {} func (v CursorNotifyEvent) SequenceId() uint16 { return v.Sequence } 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 } // Error definition BadRegion (0) // Size: 32 const BadBadRegion = 0 type BadRegionError struct { Sequence uint16 NiceName string } // Error read BadRegion func BadRegionErrorNew(buf []byte) xgb.Error { v := BadRegionError{} v.NiceName = "BadRegion" b := 1 // skip error determinant b += 1 // don't read error number v.Sequence = xgb.Get16(buf[b:]) b += 2 return v } func (err BadRegionError) ImplementsError() {} func (err BadRegionError) SequenceId() uint16 { return err.Sequence } func (err BadRegionError) BadId() uint32 { return 0 } func (err BadRegionError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew } // Request QueryVersion // size: 12 type QueryVersionCookie struct { *xgb.Cookie } func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } // Request reply for QueryVersion // size: 32 type QueryVersionReply struct { Sequence uint16 Length uint32 // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 // padding: 16 bytes } // Waits and reads reply data from request QueryVersion func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err } if buf == nil { return nil, nil } return queryVersionReply(buf), nil } // Read reply into structure from buffer for QueryVersion func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 v.MajorVersion = xgb.Get32(buf[b:]) b += 4 v.MinorVersion = xgb.Get32(buf[b:]) b += 4 b += 16 // padding return v } // Write request to wire for QueryVersion func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], ClientMajorVersion) b += 4 xgb.Put32(buf[b:], ClientMinorVersion) b += 4 return buf } // Request ChangeSaveSet // size: 12 type ChangeSaveSetCookie struct { *xgb.Cookie } // Write request to wire for ChangeSaveSet func ChangeSaveSet(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) return ChangeSaveSetCookie{cookie} } func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) return ChangeSaveSetCookie{cookie} } func (cook ChangeSaveSetCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeSaveSet func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 buf[b] = Mode b += 1 buf[b] = Target b += 1 buf[b] = Map b += 1 b += 1 // padding xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } // Request SelectSelectionInput // size: 16 type SelectSelectionInputCookie struct { *xgb.Cookie } // Write request to wire for SelectSelectionInput func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) return SelectSelectionInputCookie{cookie} } func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) return SelectSelectionInputCookie{cookie} } func (cook SelectSelectionInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectSelectionInput 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 } // Request SelectCursorInput // size: 12 type SelectCursorInputCookie struct { *xgb.Cookie } // Write request to wire for SelectCursorInput func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) return SelectCursorInputCookie{cookie} } func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) return SelectCursorInputCookie{cookie} } func (cook SelectCursorInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectCursorInput func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Window)) b += 4 xgb.Put32(buf[b:], EventMask) b += 4 return buf } // Request GetCursorImage // size: 4 type GetCursorImageCookie struct { *xgb.Cookie } func GetCursorImage(c *xgb.Conn) GetCursorImageCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCursorImageRequest(c), cookie) return GetCursorImageCookie{cookie} } func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCursorImageRequest(c), cookie) return GetCursorImageCookie{cookie} } // Request reply for GetCursorImage // size: (32 + xgb.Pad(((int(Width) * int(Height)) * 4))) type GetCursorImageReply struct { Sequence uint16 Length uint32 // 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)) } // Waits and reads reply data from request GetCursorImage 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 } // Read reply into structure from buffer for GetCursorImage 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 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 } // Request CreateRegion // size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) type CreateRegionCookie struct { *xgb.Cookie } // Write request to wire for CreateRegion func CreateRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) return CreateRegionCookie{cookie} } func CreateRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) return CreateRegionCookie{cookie} } func (cook CreateRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegion func createRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 b += xproto.RectangleListBytes(buf[b:], Rectangles) return buf } // Request CreateRegionFromBitmap // size: 12 type CreateRegionFromBitmapCookie struct { *xgb.Cookie } // Write request to wire for CreateRegionFromBitmap func CreateRegionFromBitmap(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) return CreateRegionFromBitmapCookie{cookie} } func CreateRegionFromBitmapChecked(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) return CreateRegionFromBitmapCookie{cookie} } func (cook CreateRegionFromBitmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromBitmap func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 xgb.Put32(buf[b:], uint32(Bitmap)) b += 4 return buf } // Request CreateRegionFromWindow // size: 16 type CreateRegionFromWindowCookie struct { *xgb.Cookie } // Write request to wire for CreateRegionFromWindow func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) return CreateRegionFromWindowCookie{cookie} } func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) return CreateRegionFromWindowCookie{cookie} } func (cook CreateRegionFromWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromWindow 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 } // Request CreateRegionFromGC // size: 12 type CreateRegionFromGCCookie struct { *xgb.Cookie } // Write request to wire for CreateRegionFromGC func CreateRegionFromGC(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) return CreateRegionFromGCCookie{cookie} } func CreateRegionFromGCChecked(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) return CreateRegionFromGCCookie{cookie} } func (cook CreateRegionFromGCCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromGC func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 xgb.Put32(buf[b:], uint32(Gc)) b += 4 return buf } // Request CreateRegionFromPicture // size: 12 type CreateRegionFromPictureCookie struct { *xgb.Cookie } // Write request to wire for CreateRegionFromPicture func CreateRegionFromPicture(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) return CreateRegionFromPictureCookie{cookie} } func CreateRegionFromPictureChecked(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) return CreateRegionFromPictureCookie{cookie} } func (cook CreateRegionFromPictureCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromPicture func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.Picture) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 xgb.Put32(buf[b:], uint32(Picture)) b += 4 return buf } // Request DestroyRegion // size: 8 type DestroyRegionCookie struct { *xgb.Cookie } // Write request to wire for DestroyRegion func DestroyRegion(c *xgb.Conn, Region Region) DestroyRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyRegionRequest(c, Region), cookie) return DestroyRegionCookie{cookie} } func DestroyRegionChecked(c *xgb.Conn, Region Region) DestroyRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyRegionRequest(c, Region), cookie) return DestroyRegionCookie{cookie} } func (cook DestroyRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyRegion func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf } // Request SetRegion // size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) type SetRegionCookie struct { *xgb.Cookie } // Write request to wire for SetRegion func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) return SetRegionCookie{cookie} } func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) return SetRegionCookie{cookie} } func (cook SetRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetRegion func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 b += xproto.RectangleListBytes(buf[b:], Rectangles) return buf } // Request CopyRegion // size: 12 type CopyRegionCookie struct { *xgb.Cookie } // Write request to wire for CopyRegion func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) return CopyRegionCookie{cookie} } func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) return CopyRegionCookie{cookie} } func (cook CopyRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CopyRegion func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source)) b += 4 xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } // Request UnionRegion // size: 16 type UnionRegionCookie struct { *xgb.Cookie } // Write request to wire for UnionRegion func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) return UnionRegionCookie{cookie} } func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) return UnionRegionCookie{cookie} } func (cook UnionRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnionRegion func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source1)) b += 4 xgb.Put32(buf[b:], uint32(Source2)) b += 4 xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } // Request IntersectRegion // size: 16 type IntersectRegionCookie struct { *xgb.Cookie } // Write request to wire for IntersectRegion func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) return IntersectRegionCookie{cookie} } func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) return IntersectRegionCookie{cookie} } func (cook IntersectRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for IntersectRegion func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source1)) b += 4 xgb.Put32(buf[b:], uint32(Source2)) b += 4 xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } // Request SubtractRegion // size: 16 type SubtractRegionCookie struct { *xgb.Cookie } // Write request to wire for SubtractRegion func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) return SubtractRegionCookie{cookie} } func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) return SubtractRegionCookie{cookie} } func (cook SubtractRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SubtractRegion func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 15 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source1)) b += 4 xgb.Put32(buf[b:], uint32(Source2)) b += 4 xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } // Request InvertRegion // size: 20 type InvertRegionCookie struct { *xgb.Cookie } // Write request to wire for InvertRegion func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) return InvertRegionCookie{cookie} } func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) return InvertRegionCookie{cookie} } func (cook InvertRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for InvertRegion func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source)) b += 4 { structBytes := Bounds.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } // Request TranslateRegion // size: 12 type TranslateRegionCookie struct { *xgb.Cookie } // Write request to wire for TranslateRegion func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) return TranslateRegionCookie{cookie} } func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) return TranslateRegionCookie{cookie} } func (cook TranslateRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for TranslateRegion func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 xgb.Put16(buf[b:], uint16(Dx)) b += 2 xgb.Put16(buf[b:], uint16(Dy)) b += 2 return buf } // Request RegionExtents // size: 12 type RegionExtentsCookie struct { *xgb.Cookie } // Write request to wire for RegionExtents func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { cookie := c.NewCookie(false, false) c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) return RegionExtentsCookie{cookie} } func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { cookie := c.NewCookie(true, false) c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) return RegionExtentsCookie{cookie} } func (cook RegionExtentsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RegionExtents func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source)) b += 4 xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } // Request FetchRegion // size: 8 type FetchRegionCookie struct { *xgb.Cookie } func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie { cookie := c.NewCookie(true, true) c.NewRequest(fetchRegionRequest(c, Region), cookie) return FetchRegionCookie{cookie} } func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie { cookie := c.NewCookie(false, true) c.NewRequest(fetchRegionRequest(c, Region), cookie) return FetchRegionCookie{cookie} } // Request reply for FetchRegion // size: (32 + xgb.Pad(((int(Length) / 2) * 8))) type FetchRegionReply struct { Sequence uint16 Length uint32 // padding: 1 bytes Extents xproto.Rectangle // padding: 16 bytes Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) } // Waits and reads reply data from request FetchRegion 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 } // Read reply into structure from buffer for FetchRegion 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 func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf } // Request SetGCClipRegion // size: 16 type SetGCClipRegionCookie struct { *xgb.Cookie } // Write request to wire for SetGCClipRegion func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) return SetGCClipRegionCookie{cookie} } func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) return SetGCClipRegionCookie{cookie} } func (cook SetGCClipRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetGCClipRegion func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 20 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Gc)) b += 4 xgb.Put32(buf[b:], uint32(Region)) b += 4 xgb.Put16(buf[b:], uint16(XOrigin)) b += 2 xgb.Put16(buf[b:], uint16(YOrigin)) b += 2 return buf } // Request SetWindowShapeRegion // size: 20 type SetWindowShapeRegionCookie struct { *xgb.Cookie } // Write request to wire for SetWindowShapeRegion func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) return SetWindowShapeRegionCookie{cookie} } func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) return SetWindowShapeRegionCookie{cookie} } func (cook SetWindowShapeRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetWindowShapeRegion func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Dest)) b += 4 buf[b] = byte(DestKind) b += 1 b += 3 // padding xgb.Put16(buf[b:], uint16(XOffset)) b += 2 xgb.Put16(buf[b:], uint16(YOffset)) b += 2 xgb.Put32(buf[b:], uint32(Region)) b += 4 return buf } // Request SetPictureClipRegion // size: 16 type SetPictureClipRegionCookie struct { *xgb.Cookie } // Write request to wire for SetPictureClipRegion func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) return SetPictureClipRegionCookie{cookie} } func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) return SetPictureClipRegionCookie{cookie} } func (cook SetPictureClipRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPictureClipRegion func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 22 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Picture)) b += 4 xgb.Put32(buf[b:], uint32(Region)) b += 4 xgb.Put16(buf[b:], uint16(XOrigin)) b += 2 xgb.Put16(buf[b:], uint16(YOrigin)) b += 2 return buf } // Request SetCursorName // size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) type SetCursorNameCookie struct { *xgb.Cookie } // Write request to wire for SetCursorName func SetCursorName(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { cookie := c.NewCookie(false, false) c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) return SetCursorNameCookie{cookie} } func SetCursorNameChecked(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { cookie := c.NewCookie(true, false) c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) return SetCursorNameCookie{cookie} } func (cook SetCursorNameCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetCursorName func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) []byte { size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 23 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Cursor)) b += 4 xgb.Put16(buf[b:], Nbytes) b += 2 b += 2 // padding copy(buf[b:], Name[:Nbytes]) b += xgb.Pad(int(Nbytes)) return buf } // Request GetCursorName // size: 8 type GetCursorNameCookie struct { *xgb.Cookie } func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCursorNameRequest(c, Cursor), cookie) return GetCursorNameCookie{cookie} } func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCursorNameRequest(c, Cursor), cookie) return GetCursorNameCookie{cookie} } // Request reply for GetCursorName // size: (32 + xgb.Pad((int(Nbytes) * 1))) type GetCursorNameReply struct { Sequence uint16 Length uint32 // padding: 1 bytes Atom xproto.Atom Nbytes uint16 // padding: 18 bytes Name string // size: xgb.Pad((int(Nbytes) * 1)) } // Waits and reads reply data from request GetCursorName 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 } // Read reply into structure from buffer for GetCursorName 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 func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 24 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Cursor)) b += 4 return buf } // Request GetCursorImageAndName // size: 4 type GetCursorImageAndNameCookie struct { *xgb.Cookie } func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCursorImageAndNameRequest(c), cookie) return GetCursorImageAndNameCookie{cookie} } func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCursorImageAndNameRequest(c), cookie) return GetCursorImageAndNameCookie{cookie} } // Request reply for GetCursorImageAndName // size: ((32 + xgb.Pad((int(Nbytes) * 1))) + xgb.Pad(((int(Width) * int(Height)) * 4))) type GetCursorImageAndNameReply struct { Sequence uint16 Length uint32 // 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)) } // Waits and reads reply data from request GetCursorImageAndName 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 } // Read reply into structure from buffer for GetCursorImageAndName func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { v := new(GetCursorImageAndNameReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 v.X = int16(xgb.Get16(buf[b:])) b += 2 v.Y = int16(xgb.Get16(buf[b:])) b += 2 v.Width = xgb.Get16(buf[b:]) b += 2 v.Height = xgb.Get16(buf[b:]) b += 2 v.Xhot = xgb.Get16(buf[b:]) b += 2 v.Yhot = xgb.Get16(buf[b:]) b += 2 v.CursorSerial = xgb.Get32(buf[b:]) b += 4 v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:])) b += 4 v.Nbytes = xgb.Get16(buf[b:]) b += 2 b += 2 // padding { byteString := make([]byte, v.Nbytes) copy(byteString[:v.Nbytes], buf[b:]) v.Name = string(byteString) b += xgb.Pad(int(v.Nbytes)) } v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { v.CursorImage[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) return v } // Write request to wire for GetCursorImageAndName 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 } // Request ChangeCursor // size: 12 type ChangeCursorCookie struct { *xgb.Cookie } // Write request to wire for ChangeCursor func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) return ChangeCursorCookie{cookie} } func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) return ChangeCursorCookie{cookie} } func (cook ChangeCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeCursor func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 26 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source)) b += 4 xgb.Put32(buf[b:], uint32(Destination)) b += 4 return buf } // Request ChangeCursorByName // size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) type ChangeCursorByNameCookie struct { *xgb.Cookie } // Write request to wire for ChangeCursorByName func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) return ChangeCursorByNameCookie{cookie} } func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) return ChangeCursorByNameCookie{cookie} } func (cook ChangeCursorByNameCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeCursorByName func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 27 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Src)) b += 4 xgb.Put16(buf[b:], Nbytes) b += 2 b += 2 // padding copy(buf[b:], Name[:Nbytes]) b += xgb.Pad(int(Nbytes)) return buf } // Request ExpandRegion // size: 20 type ExpandRegionCookie struct { *xgb.Cookie } // Write request to wire for ExpandRegion func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) return ExpandRegionCookie{cookie} } func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) return ExpandRegionCookie{cookie} } func (cook ExpandRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ExpandRegion func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 28 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Source)) b += 4 xgb.Put32(buf[b:], uint32(Destination)) b += 4 xgb.Put16(buf[b:], Left) b += 2 xgb.Put16(buf[b:], Right) b += 2 xgb.Put16(buf[b:], Top) b += 2 xgb.Put16(buf[b:], Bottom) b += 2 return buf } // Request HideCursor // size: 8 type HideCursorCookie struct { *xgb.Cookie } // Write request to wire for HideCursor func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(hideCursorRequest(c, Window), cookie) return HideCursorCookie{cookie} } func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(hideCursorRequest(c, Window), cookie) return HideCursorCookie{cookie} } func (cook HideCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for HideCursor func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 29 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } // Request ShowCursor // size: 8 type ShowCursorCookie struct { *xgb.Cookie } // Write request to wire for ShowCursor func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(showCursorRequest(c, Window), cookie) return ShowCursorCookie{cookie} } func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(showCursorRequest(c, Window), cookie) return ShowCursorCookie{cookie} } func (cook ShowCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ShowCursor func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFIXES"] b += 1 buf[b] = 30 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf }