2012-05-11 02:06:22 +02:00
|
|
|
// Package render is the X client API for the RENDER extension.
|
2012-05-10 23:01:42 +02:00
|
|
|
package render
|
|
|
|
|
2013-08-12 02:45:36 +02:00
|
|
|
// This file is automatically generated from render.xml. Edit at your peril!
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
import (
|
2018-09-08 19:57:27 +02:00
|
|
|
xgb "janouch.name/haven/nexgb"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2018-09-08 19:57:27 +02:00
|
|
|
"janouch.name/haven/nexgb/xproto"
|
2012-05-10 23:01:42 +02:00
|
|
|
)
|
|
|
|
|
2018-09-21 08:37:21 +02:00
|
|
|
const (
|
|
|
|
MajorVersion = 0
|
|
|
|
MinorVersion = 11
|
|
|
|
)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
// Init must be called before using the RENDER extension.
|
|
|
|
func Init(c *xgb.Conn) error {
|
|
|
|
reply, err := xproto.QueryExtension(c, 6, "RENDER").Reply()
|
|
|
|
switch {
|
|
|
|
case err != nil:
|
|
|
|
return err
|
|
|
|
case !reply.Present:
|
|
|
|
return xgb.Errorf("No extension named RENDER could be found on on the server.")
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.Lock()
|
2012-05-10 23:01:42 +02:00
|
|
|
c.Extensions["RENDER"] = reply.MajorOpcode
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.Unlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
for evNum, fun := range xgb.NewExtEventFuncs["RENDER"] {
|
|
|
|
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
|
|
|
}
|
|
|
|
for errNum, fun := range xgb.NewExtErrorFuncs["RENDER"] {
|
|
|
|
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtEventFuncs["RENDER"] = make(map[int]xgb.NewEventFun)
|
|
|
|
xgb.NewExtErrorFuncs["RENDER"] = make(map[int]xgb.NewErrorFun)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Animcursorelt struct {
|
|
|
|
Cursor xproto.Cursor
|
|
|
|
Delay uint32
|
|
|
|
}
|
2012-05-27 00:24:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AnimcursoreltRead reads a byte slice into a Animcursorelt value.
|
|
|
|
func AnimcursoreltRead(buf []byte, v *Animcursorelt) int {
|
|
|
|
b := 0
|
2012-05-27 00:24:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Cursor = xproto.Cursor(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-27 00:24:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Delay = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
2012-05-27 00:24:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return b
|
|
|
|
}
|
2012-05-27 00:24:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AnimcursoreltReadList reads a byte slice into a list of Animcursorelt values.
|
|
|
|
func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Animcursorelt{}
|
|
|
|
b += AnimcursoreltRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
2012-05-27 00:24:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Animcursorelt value to a byte slice.
|
|
|
|
func (v Animcursorelt) Bytes() []byte {
|
|
|
|
buf := make([]byte, 8)
|
|
|
|
b := 0
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Cursor))
|
|
|
|
b += 4
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], v.Delay)
|
|
|
|
b += 4
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AnimcursoreltListBytes writes a list of Animcursorelt values to a byte slice.
|
|
|
|
func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Color struct {
|
|
|
|
Red uint16
|
|
|
|
Green uint16
|
|
|
|
Blue uint16
|
|
|
|
Alpha uint16
|
|
|
|
}
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ColorRead reads a byte slice into a Color value.
|
|
|
|
func ColorRead(buf []byte, v *Color) int {
|
|
|
|
b := 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Red = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Green = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Blue = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Alpha = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// ColorReadList reads a byte slice into a list of Color values.
|
|
|
|
func ColorReadList(buf []byte, dest []Color) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Color{}
|
|
|
|
b += ColorRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a Color value to a byte slice.
|
|
|
|
func (v Color) Bytes() []byte {
|
|
|
|
buf := make([]byte, 8)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Red)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Green)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Blue)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Alpha)
|
|
|
|
b += 2
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ColorListBytes writes a list of Color values to a byte slice.
|
|
|
|
func ColorListBytes(buf []byte, list []Color) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
const (
|
|
|
|
CpRepeat = 1
|
|
|
|
CpAlphaMap = 2
|
|
|
|
CpAlphaXOrigin = 4
|
|
|
|
CpAlphaYOrigin = 8
|
|
|
|
CpClipXOrigin = 16
|
|
|
|
CpClipYOrigin = 32
|
|
|
|
CpClipMask = 64
|
|
|
|
CpGraphicsExposure = 128
|
|
|
|
CpSubwindowMode = 256
|
|
|
|
CpPolyEdge = 512
|
|
|
|
CpPolyMode = 1024
|
|
|
|
CpDither = 2048
|
|
|
|
CpComponentAlpha = 4096
|
|
|
|
)
|
|
|
|
|
|
|
|
type Directformat struct {
|
|
|
|
RedShift uint16
|
|
|
|
RedMask uint16
|
|
|
|
GreenShift uint16
|
|
|
|
GreenMask uint16
|
|
|
|
BlueShift uint16
|
|
|
|
BlueMask uint16
|
|
|
|
AlphaShift uint16
|
|
|
|
AlphaMask uint16
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// DirectformatRead reads a byte slice into a Directformat value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func DirectformatRead(buf []byte, v *Directformat) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.RedShift = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.RedMask = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.GreenShift = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.GreenMask = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.BlueShift = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.BlueMask = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.AlphaShift = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.AlphaMask = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// DirectformatReadList reads a byte slice into a list of Directformat values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func DirectformatReadList(buf []byte, dest []Directformat) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Directformat{}
|
|
|
|
b += DirectformatRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a Directformat value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v Directformat) Bytes() []byte {
|
|
|
|
buf := make([]byte, 16)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.RedShift)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.RedMask)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.GreenShift)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.GreenMask)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.BlueShift)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.BlueMask)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.AlphaShift)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.AlphaMask)
|
|
|
|
b += 2
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// DirectformatListBytes writes a list of Directformat values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func DirectformatListBytes(buf []byte, list []Directformat) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Fixed int32
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Glyph uint32
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadGlyph is the error number for a BadGlyph.
|
|
|
|
const BadGlyph = 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type GlyphError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice.
|
|
|
|
func GlyphErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := GlyphError{}
|
|
|
|
v.NiceName = "Glyph"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SequenceId returns the sequence id attached to the BadGlyph error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err GlyphError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadGlyph error. If no bad value exists, 0 is returned.
|
|
|
|
func (err GlyphError) BadId() uint32 {
|
|
|
|
return 0
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Error returns a rudimentary string representation of the BadGlyph error.
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func (err GlyphError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadGlyph {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadGlyphSet is the error number for a BadGlyphSet.
|
|
|
|
const BadGlyphSet = 3
|
|
|
|
|
|
|
|
type GlyphSetError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice.
|
|
|
|
func GlyphSetErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := GlyphSetError{}
|
|
|
|
v.NiceName = "GlyphSet"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SequenceId returns the sequence id attached to the BadGlyphSet error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err GlyphSetError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadGlyphSet error. If no bad value exists, 0 is returned.
|
|
|
|
func (err GlyphSetError) BadId() uint32 {
|
|
|
|
return 0
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Error returns a rudimentary string representation of the BadGlyphSet error.
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func (err GlyphSetError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadGlyphSet {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Glyphinfo struct {
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
X int16
|
|
|
|
Y int16
|
|
|
|
XOff int16
|
|
|
|
YOff int16
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GlyphinfoRead reads a byte slice into a Glyphinfo value.
|
|
|
|
func GlyphinfoRead(buf []byte, v *Glyphinfo) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Width = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Height = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.X = int16(xgb.Get16(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Y = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.XOff = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.YOff = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GlyphinfoReadList reads a byte slice into a list of Glyphinfo values.
|
|
|
|
func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-08-12 02:43:26 +02:00
|
|
|
dest[i] = Glyphinfo{}
|
|
|
|
b += GlyphinfoRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Glyphinfo value to a byte slice.
|
|
|
|
func (v Glyphinfo) Bytes() []byte {
|
|
|
|
buf := make([]byte, 12)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], v.Width)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], v.Height)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(v.X))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(v.Y))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(v.XOff))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(v.YOff))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GlyphinfoListBytes writes a list of Glyphinfo values to a byte slice.
|
|
|
|
func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Glyphset uint32
|
|
|
|
|
|
|
|
func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) {
|
|
|
|
id, err := c.NewId()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return Glyphset(id), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Indexvalue struct {
|
|
|
|
Pixel uint32
|
|
|
|
Red uint16
|
|
|
|
Green uint16
|
|
|
|
Blue uint16
|
|
|
|
Alpha uint16
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// IndexvalueRead reads a byte slice into a Indexvalue value.
|
|
|
|
func IndexvalueRead(buf []byte, v *Indexvalue) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Pixel = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Red = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
v.Green = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Blue = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Alpha = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// IndexvalueReadList reads a byte slice into a list of Indexvalue values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func IndexvalueReadList(buf []byte, dest []Indexvalue) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Indexvalue{}
|
|
|
|
b += IndexvalueRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a Indexvalue value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v Indexvalue) Bytes() []byte {
|
|
|
|
buf := make([]byte, 12)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], v.Pixel)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Red)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Green)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Blue)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Alpha)
|
|
|
|
b += 2
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// IndexvalueListBytes writes a list of Indexvalue values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func IndexvalueListBytes(buf []byte, list []Indexvalue) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type Linefix struct {
|
|
|
|
P1 Pointfix
|
|
|
|
P2 Pointfix
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// LinefixRead reads a byte slice into a Linefix value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func LinefixRead(buf []byte, v *Linefix) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.P1 = Pointfix{}
|
|
|
|
b += PointfixRead(buf[b:], &v.P1)
|
|
|
|
|
|
|
|
v.P2 = Pointfix{}
|
|
|
|
b += PointfixRead(buf[b:], &v.P2)
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// LinefixReadList reads a byte slice into a list of Linefix values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func LinefixReadList(buf []byte, dest []Linefix) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Linefix{}
|
|
|
|
b += LinefixRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a Linefix value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v Linefix) Bytes() []byte {
|
|
|
|
buf := make([]byte, 16)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := v.P1.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := v.P2.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// LinefixListBytes writes a list of Linefix values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func LinefixListBytes(buf []byte, list []Linefix) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadPictFormat is the error number for a BadPictFormat.
|
|
|
|
const BadPictFormat = 0
|
|
|
|
|
|
|
|
type PictFormatError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice.
|
|
|
|
func PictFormatErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := PictFormatError{}
|
|
|
|
v.NiceName = "PictFormat"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SequenceId returns the sequence id attached to the BadPictFormat error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err PictFormatError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadPictFormat error. If no bad value exists, 0 is returned.
|
|
|
|
func (err PictFormatError) BadId() uint32 {
|
|
|
|
return 0
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Error returns a rudimentary string representation of the BadPictFormat error.
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func (err PictFormatError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadPictFormat {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadPictOp is the error number for a BadPictOp.
|
|
|
|
const BadPictOp = 2
|
|
|
|
|
|
|
|
type PictOpError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictOpErrorNew constructs a PictOpError value that implements xgb.Error from a byte slice.
|
|
|
|
func PictOpErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := PictOpError{}
|
|
|
|
v.NiceName = "PictOp"
|
|
|
|
|
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// SequenceId returns the sequence id attached to the BadPictOp error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err PictOpError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadPictOp error. If no bad value exists, 0 is returned.
|
|
|
|
func (err PictOpError) BadId() uint32 {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error returns a rudimentary string representation of the BadPictOp error.
|
|
|
|
|
|
|
|
func (err PictOpError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
PictOpClear = 0
|
|
|
|
PictOpSrc = 1
|
|
|
|
PictOpDst = 2
|
|
|
|
PictOpOver = 3
|
|
|
|
PictOpOverReverse = 4
|
|
|
|
PictOpIn = 5
|
|
|
|
PictOpInReverse = 6
|
|
|
|
PictOpOut = 7
|
|
|
|
PictOpOutReverse = 8
|
|
|
|
PictOpAtop = 9
|
|
|
|
PictOpAtopReverse = 10
|
|
|
|
PictOpXor = 11
|
|
|
|
PictOpAdd = 12
|
|
|
|
PictOpSaturate = 13
|
|
|
|
PictOpDisjointClear = 16
|
|
|
|
PictOpDisjointSrc = 17
|
|
|
|
PictOpDisjointDst = 18
|
|
|
|
PictOpDisjointOver = 19
|
|
|
|
PictOpDisjointOverReverse = 20
|
|
|
|
PictOpDisjointIn = 21
|
|
|
|
PictOpDisjointInReverse = 22
|
|
|
|
PictOpDisjointOut = 23
|
|
|
|
PictOpDisjointOutReverse = 24
|
|
|
|
PictOpDisjointAtop = 25
|
|
|
|
PictOpDisjointAtopReverse = 26
|
|
|
|
PictOpDisjointXor = 27
|
|
|
|
PictOpConjointClear = 32
|
|
|
|
PictOpConjointSrc = 33
|
|
|
|
PictOpConjointDst = 34
|
|
|
|
PictOpConjointOver = 35
|
|
|
|
PictOpConjointOverReverse = 36
|
|
|
|
PictOpConjointIn = 37
|
|
|
|
PictOpConjointInReverse = 38
|
|
|
|
PictOpConjointOut = 39
|
|
|
|
PictOpConjointOutReverse = 40
|
|
|
|
PictOpConjointAtop = 41
|
|
|
|
PictOpConjointAtopReverse = 42
|
|
|
|
PictOpConjointXor = 43
|
|
|
|
PictOpMultiply = 48
|
|
|
|
PictOpScreen = 49
|
|
|
|
PictOpOverlay = 50
|
|
|
|
PictOpDarken = 51
|
|
|
|
PictOpLighten = 52
|
|
|
|
PictOpColorDodge = 53
|
|
|
|
PictOpColorBurn = 54
|
|
|
|
PictOpHardLight = 55
|
|
|
|
PictOpSoftLight = 56
|
|
|
|
PictOpDifference = 57
|
|
|
|
PictOpExclusion = 58
|
|
|
|
PictOpHSLHue = 59
|
|
|
|
PictOpHSLSaturation = 60
|
|
|
|
PictOpHSLColor = 61
|
|
|
|
PictOpHSLLuminosity = 62
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
PictTypeIndexed = 0
|
|
|
|
PictTypeDirect = 1
|
|
|
|
)
|
|
|
|
|
|
|
|
type Pictdepth struct {
|
|
|
|
Depth byte
|
|
|
|
// padding: 1 bytes
|
|
|
|
NumVisuals uint16
|
|
|
|
// padding: 4 bytes
|
|
|
|
Visuals []Pictvisual // size: xgb.Pad((int(NumVisuals) * 8))
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictdepthRead reads a byte slice into a Pictdepth value.
|
|
|
|
func PictdepthRead(buf []byte, v *Pictdepth) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Depth = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 1 // padding
|
|
|
|
|
|
|
|
v.NumVisuals = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 4 // padding
|
|
|
|
|
|
|
|
v.Visuals = make([]Pictvisual, v.NumVisuals)
|
|
|
|
b += PictvisualReadList(buf[b:], v.Visuals)
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictdepthReadList reads a byte slice into a list of Pictdepth values.
|
|
|
|
func PictdepthReadList(buf []byte, dest []Pictdepth) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Pictdepth{}
|
|
|
|
b += PictdepthRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a Pictdepth value to a byte slice.
|
|
|
|
func (v Pictdepth) Bytes() []byte {
|
|
|
|
buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8))))
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
buf[b] = v.Depth
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 1 // padding
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.NumVisuals)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 4 // padding
|
|
|
|
|
|
|
|
b += PictvisualListBytes(buf[b:], v.Visuals)
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// PictdepthListBytes writes a list of Pictdepth values to a byte slice.
|
|
|
|
func PictdepthListBytes(buf []byte, list []Pictdepth) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// PictdepthListSize computes the size (bytes) of a list of Pictdepth values.
|
|
|
|
func PictdepthListSize(list []Pictdepth) int {
|
|
|
|
size := 0
|
|
|
|
for _, item := range list {
|
|
|
|
size += (8 + xgb.Pad((int(item.NumVisuals) * 8)))
|
|
|
|
}
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
type Pictformat uint32
|
|
|
|
|
|
|
|
func NewPictformatId(c *xgb.Conn) (Pictformat, error) {
|
|
|
|
id, err := c.NewId()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return Pictformat(id), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type Pictforminfo struct {
|
|
|
|
Id Pictformat
|
|
|
|
Type byte
|
|
|
|
Depth byte
|
|
|
|
// padding: 2 bytes
|
|
|
|
Direct Directformat
|
|
|
|
Colormap xproto.Colormap
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictforminfoRead reads a byte slice into a Pictforminfo value.
|
|
|
|
func PictforminfoRead(buf []byte, v *Pictforminfo) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Id = Pictformat(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Type = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Depth = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
v.Direct = Directformat{}
|
|
|
|
b += DirectformatRead(buf[b:], &v.Direct)
|
|
|
|
|
|
|
|
v.Colormap = xproto.Colormap(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictforminfoReadList reads a byte slice into a list of Pictforminfo values.
|
|
|
|
func PictforminfoReadList(buf []byte, dest []Pictforminfo) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Pictforminfo{}
|
|
|
|
b += PictforminfoRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a Pictforminfo value to a byte slice.
|
|
|
|
func (v Pictforminfo) Bytes() []byte {
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Id))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
buf[b] = v.Type
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = v.Depth
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
{
|
2013-08-12 02:43:26 +02:00
|
|
|
structBytes := v.Direct.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Colormap))
|
|
|
|
b += 4
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// PictforminfoListBytes writes a list of Pictforminfo values to a byte slice.
|
|
|
|
func PictforminfoListBytes(buf []byte, list []Pictforminfo) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type Pictscreen struct {
|
|
|
|
NumDepths uint32
|
|
|
|
Fallback Pictformat
|
|
|
|
Depths []Pictdepth // size: PictdepthListSize(Depths)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictscreenRead reads a byte slice into a Pictscreen value.
|
|
|
|
func PictscreenRead(buf []byte, v *Pictscreen) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.NumDepths = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Fallback = Pictformat(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Depths = make([]Pictdepth, v.NumDepths)
|
|
|
|
b += PictdepthReadList(buf[b:], v.Depths)
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictscreenReadList reads a byte slice into a list of Pictscreen values.
|
|
|
|
func PictscreenReadList(buf []byte, dest []Pictscreen) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Pictscreen{}
|
|
|
|
b += PictscreenRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a Pictscreen value to a byte slice.
|
|
|
|
func (v Pictscreen) Bytes() []byte {
|
|
|
|
buf := make([]byte, (8 + PictdepthListSize(v.Depths)))
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], v.NumDepths)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Fallback))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += PictdepthListBytes(buf[b:], v.Depths)
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// PictscreenListBytes writes a list of Pictscreen values to a byte slice.
|
|
|
|
func PictscreenListBytes(buf []byte, list []Pictscreen) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
2012-05-10 23:01:42 +02:00
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// PictscreenListSize computes the size (bytes) of a list of Pictscreen values.
|
|
|
|
func PictscreenListSize(list []Pictscreen) int {
|
|
|
|
size := 0
|
|
|
|
for _, item := range list {
|
|
|
|
size += (8 + PictdepthListSize(item.Depths))
|
|
|
|
}
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
type Picture uint32
|
|
|
|
|
|
|
|
func NewPictureId(c *xgb.Conn) (Picture, error) {
|
|
|
|
id, err := c.NewId()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return Picture(id), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadPicture is the error number for a BadPicture.
|
|
|
|
const BadPicture = 1
|
|
|
|
|
|
|
|
type PictureError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictureErrorNew constructs a PictureError value that implements xgb.Error from a byte slice.
|
|
|
|
func PictureErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := PictureError{}
|
|
|
|
v.NiceName = "Picture"
|
|
|
|
|
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// SequenceId returns the sequence id attached to the BadPicture error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err PictureError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadPicture error. If no bad value exists, 0 is returned.
|
|
|
|
func (err PictureError) BadId() uint32 {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error returns a rudimentary string representation of the BadPicture error.
|
|
|
|
|
|
|
|
func (err PictureError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadPicture {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
PictureNone = 0
|
|
|
|
)
|
|
|
|
|
|
|
|
type Pictvisual struct {
|
|
|
|
Visual xproto.Visualid
|
|
|
|
Format Pictformat
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictvisualRead reads a byte slice into a Pictvisual value.
|
|
|
|
func PictvisualRead(buf []byte, v *Pictvisual) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Visual = xproto.Visualid(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Format = Pictformat(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// PictvisualReadList reads a byte slice into a list of Pictvisual values.
|
|
|
|
func PictvisualReadList(buf []byte, dest []Pictvisual) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Pictvisual{}
|
|
|
|
b += PictvisualRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a Pictvisual value to a byte slice.
|
|
|
|
func (v Pictvisual) Bytes() []byte {
|
|
|
|
buf := make([]byte, 8)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Visual))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Format))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PictvisualListBytes writes a list of Pictvisual values to a byte slice.
|
|
|
|
func PictvisualListBytes(buf []byte, list []Pictvisual) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Pointfix struct {
|
|
|
|
X Fixed
|
|
|
|
Y Fixed
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PointfixRead reads a byte slice into a Pointfix value.
|
|
|
|
func PointfixRead(buf []byte, v *Pointfix) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.X = Fixed(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Y = Fixed(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PointfixReadList reads a byte slice into a list of Pointfix values.
|
|
|
|
func PointfixReadList(buf []byte, dest []Pointfix) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-08-12 02:43:26 +02:00
|
|
|
dest[i] = Pointfix{}
|
|
|
|
b += PointfixRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Pointfix value to a byte slice.
|
|
|
|
func (v Pointfix) Bytes() []byte {
|
|
|
|
buf := make([]byte, 8)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.X))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Y))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PointfixListBytes writes a list of Pointfix values to a byte slice.
|
|
|
|
func PointfixListBytes(buf []byte, list []Pointfix) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
PolyEdgeSharp = 0
|
|
|
|
PolyEdgeSmooth = 1
|
|
|
|
)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
PolyModePrecise = 0
|
|
|
|
PolyModeImprecise = 1
|
|
|
|
)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
RepeatNone = 0
|
|
|
|
RepeatNormal = 1
|
|
|
|
RepeatPad = 2
|
|
|
|
RepeatReflect = 3
|
|
|
|
)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Spanfix struct {
|
|
|
|
L Fixed
|
|
|
|
R Fixed
|
|
|
|
Y Fixed
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SpanfixRead reads a byte slice into a Spanfix value.
|
|
|
|
func SpanfixRead(buf []byte, v *Spanfix) int {
|
|
|
|
b := 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.L = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.R = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Y = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SpanfixReadList reads a byte slice into a list of Spanfix values.
|
|
|
|
func SpanfixReadList(buf []byte, dest []Spanfix) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-08-12 02:43:26 +02:00
|
|
|
dest[i] = Spanfix{}
|
|
|
|
b += SpanfixRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Spanfix value to a byte slice.
|
|
|
|
func (v Spanfix) Bytes() []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
buf := make([]byte, 12)
|
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.L))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.R))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Y))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SpanfixListBytes writes a list of Spanfix values to a byte slice.
|
|
|
|
func SpanfixListBytes(buf []byte, list []Spanfix) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
SubPixelUnknown = 0
|
|
|
|
SubPixelHorizontalRGB = 1
|
|
|
|
SubPixelHorizontalBGR = 2
|
|
|
|
SubPixelVerticalRGB = 3
|
|
|
|
SubPixelVerticalBGR = 4
|
|
|
|
SubPixelNone = 5
|
|
|
|
)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
type Transform struct {
|
|
|
|
Matrix11 Fixed
|
|
|
|
Matrix12 Fixed
|
|
|
|
Matrix13 Fixed
|
|
|
|
Matrix21 Fixed
|
|
|
|
Matrix22 Fixed
|
|
|
|
Matrix23 Fixed
|
|
|
|
Matrix31 Fixed
|
|
|
|
Matrix32 Fixed
|
|
|
|
Matrix33 Fixed
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// TransformRead reads a byte slice into a Transform value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func TransformRead(buf []byte, v *Transform) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Matrix11 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix12 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix13 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix21 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix22 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix23 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix31 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix32 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Matrix33 = Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// TransformReadList reads a byte slice into a list of Transform values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func TransformReadList(buf []byte, dest []Transform) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = Transform{}
|
|
|
|
b += TransformRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a Transform value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v Transform) Bytes() []byte {
|
|
|
|
buf := make([]byte, 36)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix11))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix12))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix13))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix21))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix22))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix23))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix31))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix32))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Matrix33))
|
|
|
|
b += 4
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// TransformListBytes writes a list of Transform values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func TransformListBytes(buf []byte, list []Transform) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Trap struct {
|
|
|
|
Top Spanfix
|
|
|
|
Bot Spanfix
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapRead reads a byte slice into a Trap value.
|
|
|
|
func TrapRead(buf []byte, v *Trap) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Top = Spanfix{}
|
|
|
|
b += SpanfixRead(buf[b:], &v.Top)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Bot = Spanfix{}
|
|
|
|
b += SpanfixRead(buf[b:], &v.Bot)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapReadList reads a byte slice into a list of Trap values.
|
|
|
|
func TrapReadList(buf []byte, dest []Trap) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-08-12 02:43:26 +02:00
|
|
|
dest[i] = Trap{}
|
|
|
|
b += TrapRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Trap value to a byte slice.
|
|
|
|
func (v Trap) Bytes() []byte {
|
|
|
|
buf := make([]byte, 24)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := v.Top.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := v.Bot.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapListBytes writes a list of Trap values to a byte slice.
|
|
|
|
func TrapListBytes(buf []byte, list []Trap) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Trapezoid struct {
|
|
|
|
Top Fixed
|
|
|
|
Bottom Fixed
|
|
|
|
Left Linefix
|
|
|
|
Right Linefix
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapezoidRead reads a byte slice into a Trapezoid value.
|
|
|
|
func TrapezoidRead(buf []byte, v *Trapezoid) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Top = Fixed(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Bottom = Fixed(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Left = Linefix{}
|
|
|
|
b += LinefixRead(buf[b:], &v.Left)
|
|
|
|
|
|
|
|
v.Right = Linefix{}
|
|
|
|
b += LinefixRead(buf[b:], &v.Right)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapezoidReadList reads a byte slice into a list of Trapezoid values.
|
|
|
|
func TrapezoidReadList(buf []byte, dest []Trapezoid) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-08-12 02:43:26 +02:00
|
|
|
dest[i] = Trapezoid{}
|
|
|
|
b += TrapezoidRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Trapezoid value to a byte slice.
|
|
|
|
func (v Trapezoid) Bytes() []byte {
|
|
|
|
buf := make([]byte, 40)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Top))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Bottom))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := v.Left.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := v.Right.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapezoidListBytes writes a list of Trapezoid values to a byte slice.
|
|
|
|
func TrapezoidListBytes(buf []byte, list []Trapezoid) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Triangle struct {
|
|
|
|
P1 Pointfix
|
|
|
|
P2 Pointfix
|
|
|
|
P3 Pointfix
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriangleRead reads a byte slice into a Triangle value.
|
|
|
|
func TriangleRead(buf []byte, v *Triangle) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.P1 = Pointfix{}
|
|
|
|
b += PointfixRead(buf[b:], &v.P1)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.P2 = Pointfix{}
|
|
|
|
b += PointfixRead(buf[b:], &v.P2)
|
|
|
|
|
|
|
|
v.P3 = Pointfix{}
|
|
|
|
b += PointfixRead(buf[b:], &v.P3)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriangleReadList reads a byte slice into a list of Triangle values.
|
|
|
|
func TriangleReadList(buf []byte, dest []Triangle) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-08-12 02:43:26 +02:00
|
|
|
dest[i] = Triangle{}
|
|
|
|
b += TriangleRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Triangle value to a byte slice.
|
|
|
|
func (v Triangle) Bytes() []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
buf := make([]byte, 24)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
{
|
2013-08-12 02:43:26 +02:00
|
|
|
structBytes := v.P1.Bytes()
|
2012-05-10 23:01:42 +02:00
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-08-12 02:43:26 +02:00
|
|
|
structBytes := v.P2.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := v.P3.Bytes()
|
2012-05-10 23:01:42 +02:00
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriangleListBytes writes a list of Triangle values to a byte slice.
|
|
|
|
func TriangleListBytes(buf []byte, list []Triangle) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Bool'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Byte'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Card8'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Char'
|
2012-05-11 07:58:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Void'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Double'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Float'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Int16'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Int32'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Int8'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Card16'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Card32'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddGlyphsCookie is a cookie used only for AddGlyphs requests.
|
|
|
|
type AddGlyphsCookie struct {
|
|
|
|
*xgb.Cookie
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddGlyphs sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func AddGlyphs(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie)
|
|
|
|
return AddGlyphsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddGlyphsChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using AddGlyphsCookie.Check()
|
|
|
|
func AddGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie)
|
|
|
|
return AddGlyphsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
|
|
|
func (cook AddGlyphsCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for AddGlyphs
|
|
|
|
// addGlyphsRequest writes a AddGlyphs request to a byte slice.
|
|
|
|
func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
size := xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1))))
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 20 // request opcode
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Glyphset))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], GlyphsLen)
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < int(GlyphsLen); i++ {
|
|
|
|
xgb.Put32(buf[b:], Glyphids[i])
|
|
|
|
b += 4
|
|
|
|
}
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += GlyphinfoListBytes(buf[b:], Glyphs)
|
2012-05-11 07:58:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
copy(buf[b:], Data[:len(Data)])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(len(Data))
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
return buf
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddTrapsCookie is a cookie used only for AddTraps requests.
|
|
|
|
type AddTrapsCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddTraps sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie)
|
|
|
|
return AddTrapsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddTrapsChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using AddTrapsCookie.Check()
|
|
|
|
func AddTrapsChecked(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie)
|
|
|
|
return AddTrapsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
|
|
|
func (cook AddTrapsCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for AddTraps
|
|
|
|
// addTrapsRequest writes a AddTraps request to a byte slice.
|
|
|
|
func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte {
|
|
|
|
size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24))))
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 32 // request opcode
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(XOff))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(YOff))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += TrapListBytes(buf[b:], Traps)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return buf
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ChangePictureCookie is a cookie used only for ChangePicture requests.
|
|
|
|
type ChangePictureCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChangePicture sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'ChangePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie)
|
|
|
|
return ChangePictureCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChangePictureChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using ChangePictureCookie.Check()
|
|
|
|
func ChangePictureChecked(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'ChangePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie)
|
|
|
|
return ChangePictureCookie{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 ChangePictureCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for ChangePicture
|
|
|
|
// changePictureRequest writes a ChangePicture request to a byte slice.
|
|
|
|
func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 5 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], ValueMask)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
2017-01-18 10:52:16 +01:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
|
|
|
|
xgb.Put32(buf[b:], ValueList[i])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeCookie is a cookie used only for Composite requests.
|
|
|
|
type CompositeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Composite sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func Composite(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'Composite' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie)
|
|
|
|
return CompositeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CompositeCookie.Check()
|
|
|
|
func CompositeChecked(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'Composite' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie)
|
|
|
|
return CompositeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
|
|
|
func (cook CompositeCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for Composite
|
|
|
|
// compositeRequest writes a Composite request to a byte slice.
|
|
|
|
func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte {
|
|
|
|
size := 36
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 8 // request opcode
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Mask))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(MaskX))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(MaskY))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(DstX))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(DstY))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Width)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Height)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests.
|
|
|
|
type CompositeGlyphs16Cookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs16 sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
|
|
|
|
return CompositeGlyphs16Cookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs16Checked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CompositeGlyphs16Cookie.Check()
|
|
|
|
func CompositeGlyphs16Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
|
|
|
|
return CompositeGlyphs16Cookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
|
|
|
func (cook CompositeGlyphs16Cookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CompositeGlyphs16
|
|
|
|
// compositeGlyphs16Request writes a CompositeGlyphs16 request to a byte slice.
|
|
|
|
func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte {
|
|
|
|
size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1))))
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 24 // request opcode
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(MaskFormat))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Glyphset))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
copy(buf[b:], Glyphcmds[:len(Glyphcmds)])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(len(Glyphcmds))
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests.
|
|
|
|
type CompositeGlyphs32Cookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs32 sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CompositeGlyphs32(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
|
|
|
|
return CompositeGlyphs32Cookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs32Checked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CompositeGlyphs32Cookie.Check()
|
|
|
|
func CompositeGlyphs32Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
|
|
|
|
return CompositeGlyphs32Cookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CompositeGlyphs32Cookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CompositeGlyphs32
|
|
|
|
// compositeGlyphs32Request writes a CompositeGlyphs32 request to a byte slice.
|
|
|
|
func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte {
|
|
|
|
size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 25 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 3 // padding
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(MaskFormat))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Glyphset))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
2013-08-12 02:43:26 +02:00
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
copy(buf[b:], Glyphcmds[:len(Glyphcmds)])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(len(Glyphcmds))
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs8Cookie is a cookie used only for CompositeGlyphs8 requests.
|
|
|
|
type CompositeGlyphs8Cookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs8 sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CompositeGlyphs8(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
|
|
|
|
return CompositeGlyphs8Cookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CompositeGlyphs8Checked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CompositeGlyphs8Cookie.Check()
|
|
|
|
func CompositeGlyphs8Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
|
|
|
|
return CompositeGlyphs8Cookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CompositeGlyphs8Cookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CompositeGlyphs8
|
|
|
|
// compositeGlyphs8Request writes a CompositeGlyphs8 request to a byte slice.
|
|
|
|
func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte {
|
|
|
|
size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 23 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 3 // padding
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
2013-08-12 02:43:26 +02:00
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(MaskFormat))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Glyphset))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
copy(buf[b:], Glyphcmds[:len(Glyphcmds)])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(len(Glyphcmds))
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateAnimCursorCookie is a cookie used only for CreateAnimCursor requests.
|
|
|
|
type CreateAnimCursorCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateAnimCursor sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie)
|
|
|
|
return CreateAnimCursorCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateAnimCursorChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreateAnimCursorCookie.Check()
|
|
|
|
func CreateAnimCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie)
|
|
|
|
return CreateAnimCursorCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreateAnimCursorCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateAnimCursor
|
|
|
|
// createAnimCursorRequest writes a CreateAnimCursor request to a byte slice.
|
|
|
|
func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) []byte {
|
|
|
|
size := xgb.Pad((8 + xgb.Pad((len(Cursors) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 31 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Cid))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += AnimcursoreltListBytes(buf[b:], Cursors)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests.
|
|
|
|
type CreateConicalGradientCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateConicalGradient sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreateConicalGradient(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie)
|
|
|
|
return CreateConicalGradientCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateConicalGradientChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreateConicalGradientCookie.Check()
|
|
|
|
func CreateConicalGradientChecked(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie)
|
|
|
|
return CreateConicalGradientCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreateConicalGradientCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateConicalGradient
|
|
|
|
// createConicalGradientRequest writes a CreateConicalGradient request to a byte slice.
|
|
|
|
func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
size := xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 36 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Center.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Angle))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], NumStops)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
for i := 0; i < int(NumStops); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Stops[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += ColorListBytes(buf[b:], Colors)
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
return buf
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateCursorCookie is a cookie used only for CreateCursor requests.
|
|
|
|
type CreateCursorCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateCursor sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreateCursor(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie)
|
|
|
|
return CreateCursorCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateCursorChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreateCursorCookie.Check()
|
|
|
|
func CreateCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie)
|
|
|
|
return CreateCursorCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreateCursorCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateCursor
|
|
|
|
// createCursorRequest writes a CreateCursor request to a byte slice.
|
|
|
|
func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) []byte {
|
|
|
|
size := 16
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 27 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Cid))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Source))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], X)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Y)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests.
|
|
|
|
type CreateGlyphSetCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateGlyphSet sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie)
|
|
|
|
return CreateGlyphSetCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateGlyphSetChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreateGlyphSetCookie.Check()
|
|
|
|
func CreateGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie)
|
|
|
|
return CreateGlyphSetCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreateGlyphSetCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateGlyphSet
|
|
|
|
// createGlyphSetRequest writes a CreateGlyphSet request to a byte slice.
|
|
|
|
func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 17 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Gsid))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Format))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests.
|
|
|
|
type CreateLinearGradientCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateLinearGradient sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie)
|
|
|
|
return CreateLinearGradientCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateLinearGradientChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreateLinearGradientCookie.Check()
|
|
|
|
func CreateLinearGradientChecked(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie)
|
|
|
|
return CreateLinearGradientCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreateLinearGradientCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateLinearGradient
|
|
|
|
// createLinearGradientRequest writes a CreateLinearGradient request to a byte slice.
|
|
|
|
func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
size := xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 34 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := P1.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := P2.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], NumStops)
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < int(NumStops); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Stops[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += ColorListBytes(buf[b:], Colors)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
return buf
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreatePictureCookie is a cookie used only for CreatePicture requests.
|
|
|
|
type CreatePictureCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreatePicture sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie)
|
|
|
|
return CreatePictureCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreatePictureChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreatePictureCookie.Check()
|
|
|
|
func CreatePictureChecked(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie)
|
|
|
|
return CreatePictureCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreatePictureCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreatePicture
|
|
|
|
// createPictureRequest writes a CreatePicture request to a byte slice.
|
|
|
|
func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
size := xgb.Pad((20 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 4 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Pid))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Drawable))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Format))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], ValueMask)
|
|
|
|
b += 4
|
2017-01-18 10:52:16 +01:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
|
|
|
|
xgb.Put32(buf[b:], ValueList[i])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests.
|
|
|
|
type CreateRadialGradientCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateRadialGradient sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreateRadialGradient(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie)
|
|
|
|
return CreateRadialGradientCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateRadialGradientChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreateRadialGradientCookie.Check()
|
|
|
|
func CreateRadialGradientChecked(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie)
|
|
|
|
return CreateRadialGradientCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreateRadialGradientCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateRadialGradient
|
|
|
|
// createRadialGradientRequest writes a CreateRadialGradient request to a byte slice.
|
|
|
|
func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
size := xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 35 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Inner.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Outer.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(InnerRadius))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(OuterRadius))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], NumStops)
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < int(NumStops); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Stops[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += ColorListBytes(buf[b:], Colors)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
return buf
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests.
|
|
|
|
type CreateSolidFillCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateSolidFill sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie)
|
|
|
|
return CreateSolidFillCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateSolidFillChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using CreateSolidFillCookie.Check()
|
|
|
|
func CreateSolidFillChecked(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie)
|
|
|
|
return CreateSolidFillCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook CreateSolidFillCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateSolidFill
|
|
|
|
// createSolidFillRequest writes a CreateSolidFill request to a byte slice.
|
|
|
|
func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte {
|
|
|
|
size := 16
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 33 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Color.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// FillRectanglesCookie is a cookie used only for FillRectangles requests.
|
|
|
|
type FillRectanglesCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// FillRectangles sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func FillRectangles(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie)
|
|
|
|
return FillRectanglesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// FillRectanglesChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using FillRectanglesCookie.Check()
|
|
|
|
func FillRectanglesChecked(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie)
|
|
|
|
return FillRectanglesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook FillRectanglesCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for FillRectangles
|
|
|
|
// fillRectanglesRequest writes a FillRectangles request to a byte slice.
|
|
|
|
func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) []byte {
|
|
|
|
size := xgb.Pad((20 + xgb.Pad((len(Rects) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 26 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Color.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
b += xproto.RectangleListBytes(buf[b:], Rects)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// FreeGlyphSetCookie is a cookie used only for FreeGlyphSet requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type FreeGlyphSetCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// FreeGlyphSet sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie)
|
|
|
|
return FreeGlyphSetCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// FreeGlyphSetChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using FreeGlyphSetCookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie)
|
|
|
|
return FreeGlyphSetCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (cook FreeGlyphSetCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for FreeGlyphSet
|
2012-05-11 05:57:34 +02:00
|
|
|
// freeGlyphSetRequest writes a FreeGlyphSet request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte {
|
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
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(Glyphset))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// FreeGlyphsCookie is a cookie used only for FreeGlyphs requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type FreeGlyphsCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// FreeGlyphs sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie)
|
|
|
|
return FreeGlyphsCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// FreeGlyphsChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using FreeGlyphsCookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie)
|
|
|
|
return FreeGlyphsCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (cook FreeGlyphsCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for FreeGlyphs
|
2012-05-11 05:57:34 +02:00
|
|
|
// freeGlyphsRequest writes a FreeGlyphs request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte {
|
|
|
|
size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4))))
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
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(Glyphset))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
for i := 0; i < int(len(Glyphs)); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Glyphs[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// FreePictureCookie is a cookie used only for FreePicture requests.
|
|
|
|
type FreePictureCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// FreePicture sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(freePictureRequest(c, Picture), cookie)
|
|
|
|
return FreePictureCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// FreePictureChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using FreePictureCookie.Check()
|
|
|
|
func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(freePictureRequest(c, Picture), cookie)
|
|
|
|
return FreePictureCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook FreePictureCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for FreePicture
|
|
|
|
// freePictureRequest writes a FreePicture request to a byte slice.
|
|
|
|
func freePictureRequest(c *xgb.Conn, Picture Picture) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 7 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return buf
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryFiltersCookie is a cookie used only for QueryFilters requests.
|
|
|
|
type QueryFiltersCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryFilters sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryFiltersCookie.Reply()
|
|
|
|
func QueryFilters(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'QueryFilters' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryFiltersRequest(c, Drawable), cookie)
|
|
|
|
return QueryFiltersCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryFiltersUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'QueryFilters' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryFiltersRequest(c, Drawable), cookie)
|
|
|
|
return QueryFiltersCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryFiltersReply represents the data returned from a QueryFilters request.
|
|
|
|
type QueryFiltersReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
NumAliases uint32
|
|
|
|
NumFilters uint32
|
|
|
|
// padding: 16 bytes
|
|
|
|
Aliases []uint16 // size: xgb.Pad((int(NumAliases) * 2))
|
|
|
|
Filters []xproto.Str // size: xproto.StrListSize(Filters)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reply blocks and returns the reply data for a QueryFilters request.
|
|
|
|
func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return queryFiltersReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// queryFiltersReply reads a byte slice into a QueryFiltersReply value.
|
|
|
|
func queryFiltersReply(buf []byte) *QueryFiltersReply {
|
|
|
|
v := new(QueryFiltersReply)
|
|
|
|
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
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumAliases = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumFilters = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 16 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Aliases = make([]uint16, v.NumAliases)
|
|
|
|
for i := 0; i < int(v.NumAliases); i++ {
|
|
|
|
v.Aliases[i] = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
}
|
|
|
|
|
|
|
|
v.Filters = make([]xproto.Str, v.NumFilters)
|
|
|
|
b += xproto.StrReadList(buf[b:], v.Filters)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for QueryFilters
|
|
|
|
// queryFiltersRequest writes a QueryFilters request to a byte slice.
|
|
|
|
func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte {
|
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 29 // request opcode
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Drawable))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictFormatsCookie is a cookie used only for QueryPictFormats requests.
|
|
|
|
type QueryPictFormatsCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictFormats sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryPictFormatsCookie.Reply()
|
|
|
|
func QueryPictFormats(c *xgb.Conn) QueryPictFormatsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryPictFormatsRequest(c), cookie)
|
|
|
|
return QueryPictFormatsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictFormatsUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func QueryPictFormatsUnchecked(c *xgb.Conn) QueryPictFormatsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryPictFormatsRequest(c), cookie)
|
|
|
|
return QueryPictFormatsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictFormatsReply represents the data returned from a QueryPictFormats request.
|
|
|
|
type QueryPictFormatsReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
NumFormats uint32
|
|
|
|
NumScreens uint32
|
|
|
|
NumDepths uint32
|
|
|
|
NumVisuals uint32
|
|
|
|
NumSubpixel uint32
|
|
|
|
// padding: 4 bytes
|
2017-01-18 10:52:16 +01:00
|
|
|
Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28))
|
|
|
|
Screens []Pictscreen // size: PictscreenListSize(Screens)
|
|
|
|
Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4))
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Reply blocks and returns the reply data for a QueryPictFormats request.
|
|
|
|
func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return queryPictFormatsReply(buf), nil
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// queryPictFormatsReply reads a byte slice into a QueryPictFormatsReply value.
|
|
|
|
func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply {
|
|
|
|
v := new(QueryPictFormatsReply)
|
|
|
|
b := 1 // skip reply determinant
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumFormats = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumScreens = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumDepths = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NumVisuals = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NumSubpixel = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 4 // padding
|
|
|
|
|
|
|
|
v.Formats = make([]Pictforminfo, v.NumFormats)
|
|
|
|
b += PictforminfoReadList(buf[b:], v.Formats)
|
|
|
|
|
|
|
|
v.Screens = make([]Pictscreen, v.NumScreens)
|
|
|
|
b += PictscreenReadList(buf[b:], v.Screens)
|
|
|
|
|
|
|
|
v.Subpixels = make([]uint32, v.NumSubpixel)
|
|
|
|
for i := 0; i < int(v.NumSubpixel); i++ {
|
|
|
|
v.Subpixels[i] = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for QueryPictFormats
|
|
|
|
// queryPictFormatsRequest writes a QueryPictFormats request to a byte slice.
|
|
|
|
func queryPictFormatsRequest(c *xgb.Conn) []byte {
|
|
|
|
size := 4
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 1 // request opcode
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictIndexValuesCookie is a cookie used only for QueryPictIndexValues requests.
|
|
|
|
type QueryPictIndexValuesCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictIndexValues sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryPictIndexValuesCookie.Reply()
|
|
|
|
func QueryPictIndexValues(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie)
|
|
|
|
return QueryPictIndexValuesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictIndexValuesUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func QueryPictIndexValuesUnchecked(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie)
|
|
|
|
return QueryPictIndexValuesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryPictIndexValuesReply represents the data returned from a QueryPictIndexValues request.
|
|
|
|
type QueryPictIndexValuesReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
NumValues uint32
|
|
|
|
// padding: 20 bytes
|
|
|
|
Values []Indexvalue // size: xgb.Pad((int(NumValues) * 12))
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Reply blocks and returns the reply data for a QueryPictIndexValues request.
|
|
|
|
func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return queryPictIndexValuesReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// queryPictIndexValuesReply reads a byte slice into a QueryPictIndexValuesReply value.
|
|
|
|
func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply {
|
|
|
|
v := new(QueryPictIndexValuesReply)
|
|
|
|
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.NumValues = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 20 // padding
|
|
|
|
|
|
|
|
v.Values = make([]Indexvalue, v.NumValues)
|
|
|
|
b += IndexvalueReadList(buf[b:], v.Values)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for QueryPictIndexValues
|
|
|
|
// queryPictIndexValuesRequest writes a QueryPictIndexValues request to a byte slice.
|
|
|
|
func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 2 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Format))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryVersionCookie is a cookie used only for QueryVersion requests.
|
|
|
|
type QueryVersionCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryVersion sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
|
|
|
|
func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
|
|
|
return QueryVersionCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryVersionUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
|
|
|
return QueryVersionCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Reply blocks and returns the reply data for a QueryVersion request.
|
|
|
|
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return queryVersionReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// queryVersionReply reads a byte slice into a QueryVersionReply value.
|
|
|
|
func queryVersionReply(buf []byte) *QueryVersionReply {
|
|
|
|
v := new(QueryVersionReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
b += 1 // padding
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.MajorVersion = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.MinorVersion = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 16 // padding
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for QueryVersion
|
|
|
|
// queryVersionRequest writes a QueryVersion request to a byte slice.
|
|
|
|
func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 0 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], ClientMajorVersion)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], ClientMinorVersion)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests.
|
|
|
|
type ReferenceGlyphSetCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ReferenceGlyphSet sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie)
|
|
|
|
return ReferenceGlyphSetCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ReferenceGlyphSetChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using ReferenceGlyphSetCookie.Check()
|
|
|
|
func ReferenceGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie)
|
|
|
|
return ReferenceGlyphSetCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook ReferenceGlyphSetCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for ReferenceGlyphSet
|
|
|
|
// referenceGlyphSetRequest writes a ReferenceGlyphSet request to a byte slice.
|
|
|
|
func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 18 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Gsid))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Existing))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPictureClipRectanglesCookie is a cookie used only for SetPictureClipRectangles requests.
|
|
|
|
type SetPictureClipRectanglesCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPictureClipRectangles sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie)
|
|
|
|
return SetPictureClipRectanglesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPictureClipRectanglesChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetPictureClipRectanglesCookie.Check()
|
|
|
|
func SetPictureClipRectanglesChecked(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie)
|
|
|
|
return SetPictureClipRectanglesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
|
|
|
func (cook SetPictureClipRectanglesCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SetPictureClipRectangles
|
|
|
|
// setPictureClipRectanglesRequest writes a SetPictureClipRectangles request to a byte slice.
|
|
|
|
func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) []byte {
|
|
|
|
size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 6 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(ClipXOrigin))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(ClipYOrigin))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += xproto.RectangleListBytes(buf[b:], Rectangles)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SetPictureFilterCookie is a cookie used only for SetPictureFilter requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type SetPictureFilterCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SetPictureFilter sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie)
|
|
|
|
return SetPictureFilterCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SetPictureFilterChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetPictureFilterCookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie)
|
|
|
|
return SetPictureFilterCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (cook SetPictureFilterCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for SetPictureFilter
|
2012-05-11 05:57:34 +02:00
|
|
|
// setPictureFilterRequest writes a SetPictureFilter request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte {
|
2014-05-02 15:09:23 +02:00
|
|
|
size := xgb.Pad((((12 + xgb.Pad((int(FilterLen) * 1))) + 4) + xgb.Pad((len(Values) * 4))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 30 // request opcode
|
|
|
|
b += 1
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
blen := b
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Picture))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], FilterLen)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
copy(buf[b:], Filter[:FilterLen])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(FilterLen)
|
|
|
|
|
|
|
|
b = (b + 3) & ^3 // alignment gap
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
for i := 0; i < int(len(Values)); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Values[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
b = xgb.Pad(b)
|
|
|
|
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
|
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPictureTransformCookie is a cookie used only for SetPictureTransform requests.
|
|
|
|
type SetPictureTransformCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPictureTransform sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie)
|
|
|
|
return SetPictureTransformCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPictureTransformChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetPictureTransformCookie.Check()
|
|
|
|
func SetPictureTransformChecked(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie)
|
|
|
|
return SetPictureTransformCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook SetPictureTransformCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SetPictureTransform
|
|
|
|
// setPictureTransformRequest writes a SetPictureTransform request to a byte slice.
|
|
|
|
func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transform) []byte {
|
|
|
|
size := 44
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 28 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Transform.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapezoidsCookie is a cookie used only for Trapezoids requests.
|
|
|
|
type TrapezoidsCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Trapezoids sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie)
|
|
|
|
return TrapezoidsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrapezoidsChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using TrapezoidsCookie.Check()
|
|
|
|
func TrapezoidsChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie)
|
|
|
|
return TrapezoidsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook TrapezoidsCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for Trapezoids
|
|
|
|
// trapezoidsRequest writes a Trapezoids request to a byte slice.
|
|
|
|
func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) []byte {
|
|
|
|
size := xgb.Pad((24 + xgb.Pad((len(Traps) * 40))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 10 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 3 // padding
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(MaskFormat))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += TrapezoidListBytes(buf[b:], Traps)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriFanCookie is a cookie used only for TriFan requests.
|
|
|
|
type TriFanCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriFan sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
|
|
|
|
return TriFanCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriFanChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using TriFanCookie.Check()
|
|
|
|
func TriFanChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
|
|
|
|
return TriFanCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook TriFanCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for TriFan
|
|
|
|
// triFanRequest writes a TriFan request to a byte slice.
|
|
|
|
func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte {
|
|
|
|
size := xgb.Pad((24 + xgb.Pad((len(Points) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 13 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(MaskFormat))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += PointfixListBytes(buf[b:], Points)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriStripCookie is a cookie used only for TriStrip requests.
|
|
|
|
type TriStripCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriStrip sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
|
|
|
|
return TriStripCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TriStripChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using TriStripCookie.Check()
|
|
|
|
func TriStripChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
|
|
|
|
return TriStripCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook TriStripCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for TriStrip
|
|
|
|
// triStripRequest writes a TriStrip request to a byte slice.
|
|
|
|
func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte {
|
|
|
|
size := xgb.Pad((24 + xgb.Pad((len(Points) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 12 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(MaskFormat))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += PointfixListBytes(buf[b:], Points)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrianglesCookie is a cookie used only for Triangles requests.
|
|
|
|
type TrianglesCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Triangles sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie)
|
|
|
|
return TrianglesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// TrianglesChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using TrianglesCookie.Check()
|
|
|
|
func TrianglesChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RENDER"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie)
|
|
|
|
return TrianglesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Check returns an error if one occurred for checked requests that are not expecting a reply.
|
|
|
|
// This cannot be called for requests expecting a reply, nor for unchecked requests.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook TrianglesCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for Triangles
|
|
|
|
// trianglesRequest writes a Triangles request to a byte slice.
|
|
|
|
func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) []byte {
|
|
|
|
size := xgb.Pad((24 + xgb.Pad((len(Triangles) * 24))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2012-05-10 23:01:42 +02:00
|
|
|
buf[b] = c.Extensions["RENDER"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 11 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Op
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Src))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Dst))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(MaskFormat))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += TriangleListBytes(buf[b:], Triangles)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|