a huge commit. splitting extensions into their own sub-packages.
This commit is contained in:
parent
e239bb3c68
commit
0c50dc6241
@ -16,17 +16,30 @@ all: build-xgbgen \
|
||||
build-xgbgen:
|
||||
(cd xgbgen && go build)
|
||||
|
||||
%.xml:
|
||||
xgbgen/xgbgen --proto-path $(XPROTO) $(XPROTO)/$*.xml > auto_$*.go
|
||||
build-all: bigreq.b composite.b damage.b dpms.b dri2.b ge.b glx.b randr.b \
|
||||
record.b render.b res.b screensaver.b shape.b shm.b sync.b xcmisc.b \
|
||||
xevie.b xf86dri.b xf86vidmode.b xfixes.b xinerama.b xinput.b \
|
||||
xprint.b xproto.b xselinux.b xtest.b xv.b xvmc.b
|
||||
|
||||
%.b:
|
||||
(cd $* ; go build)
|
||||
|
||||
xc_misc.xml: build-xgbgen
|
||||
mkdir -p xcmisc
|
||||
xgbgen/xgbgen --proto-path $(XPROTO) $(XPROTO)/xc_misc.xml > xcmisc/xcmisc.go
|
||||
|
||||
%.xml: build-xgbgen
|
||||
mkdir -p $*
|
||||
xgbgen/xgbgen --proto-path $(XPROTO) $(XPROTO)/$*.xml > $*/$*.go
|
||||
|
||||
test:
|
||||
go test
|
||||
(cd xproto ; go test)
|
||||
|
||||
bench:
|
||||
go test -run 'nomatch' -bench '.*' -cpu 1,2,6
|
||||
(cd xproto ; go test -run 'nomatch' -bench '.*' -cpu 1,2,6)
|
||||
|
||||
gofmt:
|
||||
gofmt -w *.go xgbgen/*.go examples/*.go examples/*/*.go
|
||||
colcheck xgbgen/*.go examples/*.go examples/*/*.go \
|
||||
auth.go conn.go cookie.go doc.go xgb.go xgb_help.go xgb_test.go
|
||||
colcheck xgbgen/*.go examples/*.go examples/*/*.go xproto/xproto_test.go \
|
||||
auth.go conn.go cookie.go doc.go xgb.go xgb_help.go
|
||||
|
||||
|
@ -1,138 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by bigreq.xml on May 10 2012 12:39:33pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// BigreqInit must be called before using the BIG-REQUESTS extension.
|
||||
func (c *Conn) BigreqInit() error {
|
||||
reply, err := c.QueryExtension(12, "BIG-REQUESTS").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named BIG-REQUESTS could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["BIG-REQUESTS"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["BIG-REQUESTS"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["BIG-REQUESTS"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["BIG-REQUESTS"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["BIG-REQUESTS"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Request BigreqEnable
|
||||
// size: 4
|
||||
type BigreqEnableCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) BigreqEnable() BigreqEnableCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.bigreqEnableRequest(), cookie)
|
||||
return BigreqEnableCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) BigreqEnableUnchecked() BigreqEnableCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.bigreqEnableRequest(), cookie)
|
||||
return BigreqEnableCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for BigreqEnable
|
||||
// size: 12
|
||||
type BigreqEnableReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MaximumRequestLength uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request BigreqEnable
|
||||
func (cook BigreqEnableCookie) Reply() (*BigreqEnableReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return bigreqEnableReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for BigreqEnable
|
||||
func bigreqEnableReply(buf []byte) *BigreqEnableReply {
|
||||
v := new(BigreqEnableReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MaximumRequestLength = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook BigreqEnableCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for BigreqEnable
|
||||
func (c *Conn) bigreqEnableRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["BIG-REQUESTS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
@ -1,581 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by composite.xml on May 10 2012 12:39:33pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
// import "xfixes"
|
||||
|
||||
// CompositeInit must be called before using the Composite extension.
|
||||
func (c *Conn) CompositeInit() error {
|
||||
reply, err := c.QueryExtension(9, "Composite").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named Composite could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["Composite"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["Composite"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["Composite"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["Composite"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["Composite"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
const (
|
||||
CompositeRedirectAutomatic = 0
|
||||
CompositeRedirectManual = 1
|
||||
)
|
||||
|
||||
// Request CompositeQueryVersion
|
||||
// size: 12
|
||||
type CompositeQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) CompositeQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.compositeQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return CompositeQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) CompositeQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.compositeQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return CompositeQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for CompositeQueryVersion
|
||||
// size: 32
|
||||
type CompositeQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint32
|
||||
MinorVersion uint32
|
||||
// padding: 16 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request CompositeQueryVersion
|
||||
func (cook CompositeQueryVersionCookie) Reply() (*CompositeQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return compositeQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for CompositeQueryVersion
|
||||
func compositeQueryVersionReply(buf []byte) *CompositeQueryVersionReply {
|
||||
v := new(CompositeQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.MinorVersion = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 16 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook CompositeQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeQueryVersion
|
||||
func (c *Conn) compositeQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], ClientMajorVersion)
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], ClientMinorVersion)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeRedirectWindow
|
||||
// size: 12
|
||||
type CompositeRedirectWindowCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeRedirectWindow
|
||||
func (c *Conn) CompositeRedirectWindow(Window Window, Update byte) CompositeRedirectWindowCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.compositeRedirectWindowRequest(Window, Update), cookie)
|
||||
return CompositeRedirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeRedirectWindowChecked(Window Window, Update byte) CompositeRedirectWindowCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.compositeRedirectWindowRequest(Window, Update), cookie)
|
||||
return CompositeRedirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CompositeRedirectWindowCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeRedirectWindow
|
||||
func (c *Conn) compositeRedirectWindowRequest(Window Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeRedirectSubwindows
|
||||
// size: 12
|
||||
type CompositeRedirectSubwindowsCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeRedirectSubwindows
|
||||
func (c *Conn) CompositeRedirectSubwindows(Window Window, Update byte) CompositeRedirectSubwindowsCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.compositeRedirectSubwindowsRequest(Window, Update), cookie)
|
||||
return CompositeRedirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeRedirectSubwindowsChecked(Window Window, Update byte) CompositeRedirectSubwindowsCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.compositeRedirectSubwindowsRequest(Window, Update), cookie)
|
||||
return CompositeRedirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CompositeRedirectSubwindowsCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeRedirectSubwindows
|
||||
func (c *Conn) compositeRedirectSubwindowsRequest(Window Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeUnredirectWindow
|
||||
// size: 12
|
||||
type CompositeUnredirectWindowCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeUnredirectWindow
|
||||
func (c *Conn) CompositeUnredirectWindow(Window Window, Update byte) CompositeUnredirectWindowCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.compositeUnredirectWindowRequest(Window, Update), cookie)
|
||||
return CompositeUnredirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeUnredirectWindowChecked(Window Window, Update byte) CompositeUnredirectWindowCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.compositeUnredirectWindowRequest(Window, Update), cookie)
|
||||
return CompositeUnredirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CompositeUnredirectWindowCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeUnredirectWindow
|
||||
func (c *Conn) compositeUnredirectWindowRequest(Window Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeUnredirectSubwindows
|
||||
// size: 12
|
||||
type CompositeUnredirectSubwindowsCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeUnredirectSubwindows
|
||||
func (c *Conn) CompositeUnredirectSubwindows(Window Window, Update byte) CompositeUnredirectSubwindowsCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.compositeUnredirectSubwindowsRequest(Window, Update), cookie)
|
||||
return CompositeUnredirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeUnredirectSubwindowsChecked(Window Window, Update byte) CompositeUnredirectSubwindowsCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.compositeUnredirectSubwindowsRequest(Window, Update), cookie)
|
||||
return CompositeUnredirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CompositeUnredirectSubwindowsCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeUnredirectSubwindows
|
||||
func (c *Conn) compositeUnredirectSubwindowsRequest(Window Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeCreateRegionFromBorderClip
|
||||
// size: 12
|
||||
type CompositeCreateRegionFromBorderClipCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeCreateRegionFromBorderClip
|
||||
func (c *Conn) CompositeCreateRegionFromBorderClip(Region XfixesRegion, Window Window) CompositeCreateRegionFromBorderClipCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.compositeCreateRegionFromBorderClipRequest(Region, Window), cookie)
|
||||
return CompositeCreateRegionFromBorderClipCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeCreateRegionFromBorderClipChecked(Region XfixesRegion, Window Window) CompositeCreateRegionFromBorderClipCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.compositeCreateRegionFromBorderClipRequest(Region, Window), cookie)
|
||||
return CompositeCreateRegionFromBorderClipCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CompositeCreateRegionFromBorderClipCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeCreateRegionFromBorderClip
|
||||
func (c *Conn) compositeCreateRegionFromBorderClipRequest(Region XfixesRegion, Window Window) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Region))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeNameWindowPixmap
|
||||
// size: 12
|
||||
type CompositeNameWindowPixmapCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeNameWindowPixmap
|
||||
func (c *Conn) CompositeNameWindowPixmap(Window Window, Pixmap Pixmap) CompositeNameWindowPixmapCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.compositeNameWindowPixmapRequest(Window, Pixmap), cookie)
|
||||
return CompositeNameWindowPixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeNameWindowPixmapChecked(Window Window, Pixmap Pixmap) CompositeNameWindowPixmapCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.compositeNameWindowPixmapRequest(Window, Pixmap), cookie)
|
||||
return CompositeNameWindowPixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CompositeNameWindowPixmapCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeNameWindowPixmap
|
||||
func (c *Conn) compositeNameWindowPixmapRequest(Window Window, Pixmap Pixmap) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Pixmap))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeGetOverlayWindow
|
||||
// size: 8
|
||||
type CompositeGetOverlayWindowCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeGetOverlayWindow(Window Window) CompositeGetOverlayWindowCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.compositeGetOverlayWindowRequest(Window), cookie)
|
||||
return CompositeGetOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeGetOverlayWindowUnchecked(Window Window) CompositeGetOverlayWindowCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.compositeGetOverlayWindowRequest(Window), cookie)
|
||||
return CompositeGetOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for CompositeGetOverlayWindow
|
||||
// size: 32
|
||||
type CompositeGetOverlayWindowReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
OverlayWin Window
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request CompositeGetOverlayWindow
|
||||
func (cook CompositeGetOverlayWindowCookie) Reply() (*CompositeGetOverlayWindowReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return compositeGetOverlayWindowReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for CompositeGetOverlayWindow
|
||||
func compositeGetOverlayWindowReply(buf []byte) *CompositeGetOverlayWindowReply {
|
||||
v := new(CompositeGetOverlayWindowReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.OverlayWin = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook CompositeGetOverlayWindowCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeGetOverlayWindow
|
||||
func (c *Conn) compositeGetOverlayWindowRequest(Window Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompositeReleaseOverlayWindow
|
||||
// size: 8
|
||||
type CompositeReleaseOverlayWindowCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeReleaseOverlayWindow
|
||||
func (c *Conn) CompositeReleaseOverlayWindow(Window Window) CompositeReleaseOverlayWindowCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.compositeReleaseOverlayWindowRequest(Window), cookie)
|
||||
return CompositeReleaseOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) CompositeReleaseOverlayWindowChecked(Window Window) CompositeReleaseOverlayWindowCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.compositeReleaseOverlayWindowRequest(Window), cookie)
|
||||
return CompositeReleaseOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CompositeReleaseOverlayWindowCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for CompositeReleaseOverlayWindow
|
||||
func (c *Conn) compositeReleaseOverlayWindowRequest(Window Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 8 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
@ -1,513 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by damage.xml on May 10 2012 12:39:33pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
// import "xfixes"
|
||||
|
||||
// DamageInit must be called before using the DAMAGE extension.
|
||||
func (c *Conn) DamageInit() error {
|
||||
reply, err := c.QueryExtension(6, "DAMAGE").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named DAMAGE could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["DAMAGE"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["DAMAGE"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["DAMAGE"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["DAMAGE"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["DAMAGE"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
const (
|
||||
DamageReportLevelRawRectangles = 0
|
||||
DamageReportLevelDeltaRectangles = 1
|
||||
DamageReportLevelBoundingBox = 2
|
||||
DamageReportLevelNonEmpty = 3
|
||||
)
|
||||
|
||||
type DamageDamage uint32
|
||||
|
||||
func (c *Conn) NewDamageDamageId() (DamageDamage, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return DamageDamage(id), nil
|
||||
}
|
||||
|
||||
// Event definition DamageNotify (0)
|
||||
// Size: 32
|
||||
|
||||
const DamageNotify = 0
|
||||
|
||||
type DamageNotifyEvent struct {
|
||||
Sequence uint16
|
||||
Level byte
|
||||
Drawable Drawable
|
||||
Damage DamageDamage
|
||||
Timestamp Timestamp
|
||||
Area Rectangle
|
||||
Geometry Rectangle
|
||||
}
|
||||
|
||||
// Event read DamageNotify
|
||||
func NewDamageNotifyEvent(buf []byte) Event {
|
||||
v := DamageNotifyEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
v.Level = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Drawable = Drawable(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Damage = DamageDamage(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Timestamp = Timestamp(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Area = Rectangle{}
|
||||
b += ReadRectangle(buf[b:], &v.Area)
|
||||
|
||||
v.Geometry = Rectangle{}
|
||||
b += ReadRectangle(buf[b:], &v.Geometry)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write DamageNotify
|
||||
func (v DamageNotifyEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
buf[b] = v.Level
|
||||
b += 1
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
Put32(buf[b:], uint32(v.Drawable))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(v.Damage))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(v.Timestamp))
|
||||
b += 4
|
||||
|
||||
{
|
||||
structBytes := v.Area.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
|
||||
{
|
||||
structBytes := v.Geometry.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v DamageNotifyEvent) ImplementsEvent() {}
|
||||
|
||||
func (v DamageNotifyEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v DamageNotifyEvent) String() string {
|
||||
fieldVals := make([]string, 0, 6)
|
||||
fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, sprintf("Level: %d", v.Level))
|
||||
fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable))
|
||||
fieldVals = append(fieldVals, sprintf("Damage: %d", v.Damage))
|
||||
fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp))
|
||||
return "DamageNotify {" + stringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["DAMAGE"][0] = NewDamageNotifyEvent
|
||||
}
|
||||
|
||||
// Error definition DamageBadDamage (0)
|
||||
// Size: 32
|
||||
|
||||
const BadDamageBadDamage = 0
|
||||
|
||||
type DamageBadDamageError struct {
|
||||
Sequence uint16
|
||||
NiceName string
|
||||
}
|
||||
|
||||
// Error read DamageBadDamage
|
||||
func NewDamageBadDamageError(buf []byte) Error {
|
||||
v := DamageBadDamageError{}
|
||||
v.NiceName = "DamageBadDamage"
|
||||
|
||||
b := 1 // skip error determinant
|
||||
b += 1 // don't read error number
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (err DamageBadDamageError) ImplementsError() {}
|
||||
|
||||
func (err DamageBadDamageError) SequenceId() uint16 {
|
||||
return err.Sequence
|
||||
}
|
||||
|
||||
func (err DamageBadDamageError) BadId() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (err DamageBadDamageError) Error() string {
|
||||
fieldVals := make([]string, 0, 0)
|
||||
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
||||
fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence))
|
||||
return "BadDamageBadDamage {" + stringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtErrorFuncs["DAMAGE"][0] = NewDamageBadDamageError
|
||||
}
|
||||
|
||||
// Request DamageQueryVersion
|
||||
// size: 12
|
||||
type DamageQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) DamageQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) DamageQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.damageQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return DamageQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DamageQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) DamageQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.damageQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return DamageQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for DamageQueryVersion
|
||||
// size: 32
|
||||
type DamageQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint32
|
||||
MinorVersion uint32
|
||||
// padding: 16 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request DamageQueryVersion
|
||||
func (cook DamageQueryVersionCookie) Reply() (*DamageQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return damageQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for DamageQueryVersion
|
||||
func damageQueryVersionReply(buf []byte) *DamageQueryVersionReply {
|
||||
v := new(DamageQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.MinorVersion = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 16 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook DamageQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DamageQueryVersion
|
||||
func (c *Conn) damageQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], ClientMajorVersion)
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], ClientMinorVersion)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DamageCreate
|
||||
// size: 16
|
||||
type DamageCreateCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DamageCreate
|
||||
func (c *Conn) DamageCreate(Damage DamageDamage, Drawable Drawable, Level byte) DamageCreateCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.damageCreateRequest(Damage, Drawable, Level), cookie)
|
||||
return DamageCreateCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DamageCreateChecked(Damage DamageDamage, Drawable Drawable, Level byte) DamageCreateCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.damageCreateRequest(Damage, Drawable, Level), cookie)
|
||||
return DamageCreateCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DamageCreateCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DamageCreate
|
||||
func (c *Conn) damageCreateRequest(Damage DamageDamage, Drawable Drawable, Level byte) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Damage))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
buf[b] = Level
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DamageDestroy
|
||||
// size: 8
|
||||
type DamageDestroyCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DamageDestroy
|
||||
func (c *Conn) DamageDestroy(Damage DamageDamage) DamageDestroyCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.damageDestroyRequest(Damage), cookie)
|
||||
return DamageDestroyCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DamageDestroyChecked(Damage DamageDamage) DamageDestroyCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.damageDestroyRequest(Damage), cookie)
|
||||
return DamageDestroyCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DamageDestroyCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DamageDestroy
|
||||
func (c *Conn) damageDestroyRequest(Damage DamageDamage) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Damage))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DamageSubtract
|
||||
// size: 16
|
||||
type DamageSubtractCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DamageSubtract
|
||||
func (c *Conn) DamageSubtract(Damage DamageDamage, Repair XfixesRegion, Parts XfixesRegion) DamageSubtractCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.damageSubtractRequest(Damage, Repair, Parts), cookie)
|
||||
return DamageSubtractCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DamageSubtractChecked(Damage DamageDamage, Repair XfixesRegion, Parts XfixesRegion) DamageSubtractCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.damageSubtractRequest(Damage, Repair, Parts), cookie)
|
||||
return DamageSubtractCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DamageSubtractCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DamageSubtract
|
||||
func (c *Conn) damageSubtractRequest(Damage DamageDamage, Repair XfixesRegion, Parts XfixesRegion) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Damage))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Repair))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Parts))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DamageAdd
|
||||
// size: 12
|
||||
type DamageAddCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DamageAdd
|
||||
func (c *Conn) DamageAdd(Drawable Drawable, Region XfixesRegion) DamageAddCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.damageAddRequest(Drawable, Region), cookie)
|
||||
return DamageAddCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DamageAddChecked(Drawable Drawable, Region XfixesRegion) DamageAddCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.damageAddRequest(Drawable, Region), cookie)
|
||||
return DamageAddCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DamageAddCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DamageAdd
|
||||
func (c *Conn) damageAddRequest(Drawable Drawable, Region XfixesRegion) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Region))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
@ -1,600 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by dpms.xml on May 10 2012 12:39:33pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// DpmsInit must be called before using the DPMS extension.
|
||||
func (c *Conn) DpmsInit() error {
|
||||
reply, err := c.QueryExtension(4, "DPMS").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named DPMS could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["DPMS"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["DPMS"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["DPMS"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["DPMS"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["DPMS"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
const (
|
||||
DpmsDPMSModeOn = 0
|
||||
DpmsDPMSModeStandby = 1
|
||||
DpmsDPMSModeSuspend = 2
|
||||
DpmsDPMSModeOff = 3
|
||||
)
|
||||
|
||||
// Request DpmsGetVersion
|
||||
// size: 8
|
||||
type DpmsGetVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsGetVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) DpmsGetVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.dpmsGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return DpmsGetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsGetVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) DpmsGetVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.dpmsGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return DpmsGetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for DpmsGetVersion
|
||||
// size: 12
|
||||
type DpmsGetVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request DpmsGetVersion
|
||||
func (cook DpmsGetVersionCookie) Reply() (*DpmsGetVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return dpmsGetVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for DpmsGetVersion
|
||||
func dpmsGetVersionReply(buf []byte) *DpmsGetVersionReply {
|
||||
v := new(DpmsGetVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook DpmsGetVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsGetVersion
|
||||
func (c *Conn) dpmsGetVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DpmsCapable
|
||||
// size: 4
|
||||
type DpmsCapableCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsCapable() DpmsCapableCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.dpmsCapableRequest(), cookie)
|
||||
return DpmsCapableCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsCapableUnchecked() DpmsCapableCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.dpmsCapableRequest(), cookie)
|
||||
return DpmsCapableCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for DpmsCapable
|
||||
// size: 32
|
||||
type DpmsCapableReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Capable bool
|
||||
// padding: 23 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request DpmsCapable
|
||||
func (cook DpmsCapableCookie) Reply() (*DpmsCapableReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return dpmsCapableReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for DpmsCapable
|
||||
func dpmsCapableReply(buf []byte) *DpmsCapableReply {
|
||||
v := new(DpmsCapableReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Capable = true
|
||||
} else {
|
||||
v.Capable = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 23 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook DpmsCapableCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsCapable
|
||||
func (c *Conn) dpmsCapableRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DpmsGetTimeouts
|
||||
// size: 4
|
||||
type DpmsGetTimeoutsCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsGetTimeouts() DpmsGetTimeoutsCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.dpmsGetTimeoutsRequest(), cookie)
|
||||
return DpmsGetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsGetTimeoutsUnchecked() DpmsGetTimeoutsCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.dpmsGetTimeoutsRequest(), cookie)
|
||||
return DpmsGetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for DpmsGetTimeouts
|
||||
// size: 32
|
||||
type DpmsGetTimeoutsReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
StandbyTimeout uint16
|
||||
SuspendTimeout uint16
|
||||
OffTimeout uint16
|
||||
// padding: 18 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request DpmsGetTimeouts
|
||||
func (cook DpmsGetTimeoutsCookie) Reply() (*DpmsGetTimeoutsReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return dpmsGetTimeoutsReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for DpmsGetTimeouts
|
||||
func dpmsGetTimeoutsReply(buf []byte) *DpmsGetTimeoutsReply {
|
||||
v := new(DpmsGetTimeoutsReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.StandbyTimeout = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.SuspendTimeout = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.OffTimeout = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 18 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook DpmsGetTimeoutsCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsGetTimeouts
|
||||
func (c *Conn) dpmsGetTimeoutsRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DpmsSetTimeouts
|
||||
// size: 12
|
||||
type DpmsSetTimeoutsCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsSetTimeouts
|
||||
func (c *Conn) DpmsSetTimeouts(StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) DpmsSetTimeoutsCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.dpmsSetTimeoutsRequest(StandbyTimeout, SuspendTimeout, OffTimeout), cookie)
|
||||
return DpmsSetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsSetTimeoutsChecked(StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) DpmsSetTimeoutsCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.dpmsSetTimeoutsRequest(StandbyTimeout, SuspendTimeout, OffTimeout), cookie)
|
||||
return DpmsSetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DpmsSetTimeoutsCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsSetTimeouts
|
||||
func (c *Conn) dpmsSetTimeoutsRequest(StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], StandbyTimeout)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], SuspendTimeout)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], OffTimeout)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DpmsEnable
|
||||
// size: 4
|
||||
type DpmsEnableCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsEnable
|
||||
func (c *Conn) DpmsEnable() DpmsEnableCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.dpmsEnableRequest(), cookie)
|
||||
return DpmsEnableCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsEnableChecked() DpmsEnableCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.dpmsEnableRequest(), cookie)
|
||||
return DpmsEnableCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DpmsEnableCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsEnable
|
||||
func (c *Conn) dpmsEnableRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DpmsDisable
|
||||
// size: 4
|
||||
type DpmsDisableCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsDisable
|
||||
func (c *Conn) DpmsDisable() DpmsDisableCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.dpmsDisableRequest(), cookie)
|
||||
return DpmsDisableCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsDisableChecked() DpmsDisableCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.dpmsDisableRequest(), cookie)
|
||||
return DpmsDisableCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DpmsDisableCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsDisable
|
||||
func (c *Conn) dpmsDisableRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DpmsForceLevel
|
||||
// size: 8
|
||||
type DpmsForceLevelCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsForceLevel
|
||||
func (c *Conn) DpmsForceLevel(PowerLevel uint16) DpmsForceLevelCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.dpmsForceLevelRequest(PowerLevel), cookie)
|
||||
return DpmsForceLevelCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsForceLevelChecked(PowerLevel uint16) DpmsForceLevelCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.dpmsForceLevelRequest(PowerLevel), cookie)
|
||||
return DpmsForceLevelCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DpmsForceLevelCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsForceLevel
|
||||
func (c *Conn) dpmsForceLevelRequest(PowerLevel uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], PowerLevel)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DpmsInfo
|
||||
// size: 4
|
||||
type DpmsInfoCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsInfo() DpmsInfoCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.dpmsInfoRequest(), cookie)
|
||||
return DpmsInfoCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) DpmsInfoUnchecked() DpmsInfoCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.dpmsInfoRequest(), cookie)
|
||||
return DpmsInfoCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for DpmsInfo
|
||||
// size: 32
|
||||
type DpmsInfoReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
PowerLevel uint16
|
||||
State bool
|
||||
// padding: 21 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request DpmsInfo
|
||||
func (cook DpmsInfoCookie) Reply() (*DpmsInfoReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return dpmsInfoReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for DpmsInfo
|
||||
func dpmsInfoReply(buf []byte) *DpmsInfoReply {
|
||||
v := new(DpmsInfoReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.PowerLevel = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.State = true
|
||||
} else {
|
||||
v.State = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 21 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook DpmsInfoCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for DpmsInfo
|
||||
func (c *Conn) dpmsInfoRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
1560
nexgb/auto_dri2.go
1560
nexgb/auto_dri2.go
File diff suppressed because it is too large
Load Diff
151
nexgb/auto_ge.go
151
nexgb/auto_ge.go
@ -1,151 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by ge.xml on May 10 2012 12:39:33pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// GeInit must be called before using the Generic Event Extension extension.
|
||||
func (c *Conn) GeInit() error {
|
||||
reply, err := c.QueryExtension(23, "Generic Event Extension").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named Generic Event Extension could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["Generic Event Extension"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["Generic Event Extension"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["Generic Event Extension"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["Generic Event Extension"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["Generic Event Extension"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Request GeQueryVersion
|
||||
// size: 8
|
||||
type GeQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) GeQueryVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) GeQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.geQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return GeQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) GeQueryVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) GeQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.geQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return GeQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GeQueryVersion
|
||||
// size: 32
|
||||
type GeQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint16
|
||||
MinorVersion uint16
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GeQueryVersion
|
||||
func (cook GeQueryVersionCookie) Reply() (*GeQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return geQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GeQueryVersion
|
||||
func geQueryVersionReply(buf []byte) *GeQueryVersionReply {
|
||||
v := new(GeQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook GeQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for GeQueryVersion
|
||||
func (c *Conn) geQueryVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["GENERIC EVENT EXTENSION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
9430
nexgb/auto_glx.go
9430
nexgb/auto_glx.go
File diff suppressed because it is too large
Load Diff
4038
nexgb/auto_randr.go
4038
nexgb/auto_randr.go
File diff suppressed because it is too large
Load Diff
1095
nexgb/auto_record.go
1095
nexgb/auto_record.go
File diff suppressed because it is too large
Load Diff
3556
nexgb/auto_render.go
3556
nexgb/auto_render.go
File diff suppressed because it is too large
Load Diff
@ -1,528 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by res.xml on May 10 2012 12:39:33pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
|
||||
// ResInit must be called before using the X-Resource extension.
|
||||
func (c *Conn) ResInit() error {
|
||||
reply, err := c.QueryExtension(10, "X-Resource").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named X-Resource could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["X-Resource"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["X-Resource"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["X-Resource"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["X-Resource"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["X-Resource"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// 'ResClient' struct definition
|
||||
// Size: 8
|
||||
type ResClient struct {
|
||||
ResourceBase uint32
|
||||
ResourceMask uint32
|
||||
}
|
||||
|
||||
// Struct read ResClient
|
||||
func ReadResClient(buf []byte, v *ResClient) int {
|
||||
b := 0
|
||||
|
||||
v.ResourceBase = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.ResourceMask = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read ResClient
|
||||
func ReadResClientList(buf []byte, dest []ResClient) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = ResClient{}
|
||||
b += ReadResClient(buf[b:], &dest[i])
|
||||
}
|
||||
return pad(b)
|
||||
}
|
||||
|
||||
// Struct write ResClient
|
||||
func (v ResClient) Bytes() []byte {
|
||||
buf := make([]byte, 8)
|
||||
b := 0
|
||||
|
||||
Put32(buf[b:], v.ResourceBase)
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], v.ResourceMask)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list ResClient
|
||||
func ResClientListBytes(buf []byte, list []ResClient) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// 'ResType' struct definition
|
||||
// Size: 8
|
||||
type ResType struct {
|
||||
ResourceType Atom
|
||||
Count uint32
|
||||
}
|
||||
|
||||
// Struct read ResType
|
||||
func ReadResType(buf []byte, v *ResType) int {
|
||||
b := 0
|
||||
|
||||
v.ResourceType = Atom(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Count = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read ResType
|
||||
func ReadResTypeList(buf []byte, dest []ResType) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = ResType{}
|
||||
b += ReadResType(buf[b:], &dest[i])
|
||||
}
|
||||
return pad(b)
|
||||
}
|
||||
|
||||
// Struct write ResType
|
||||
func (v ResType) Bytes() []byte {
|
||||
buf := make([]byte, 8)
|
||||
b := 0
|
||||
|
||||
Put32(buf[b:], uint32(v.ResourceType))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], v.Count)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list ResType
|
||||
func ResTypeListBytes(buf []byte, list []ResType) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request ResQueryVersion
|
||||
// size: 8
|
||||
type ResQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryVersion(ClientMajor byte, ClientMinor byte) ResQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.resQueryVersionRequest(ClientMajor, ClientMinor), cookie)
|
||||
return ResQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryVersionUnchecked(ClientMajor byte, ClientMinor byte) ResQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.resQueryVersionRequest(ClientMajor, ClientMinor), cookie)
|
||||
return ResQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ResQueryVersion
|
||||
// size: 12
|
||||
type ResQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajor uint16
|
||||
ServerMinor uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ResQueryVersion
|
||||
func (cook ResQueryVersionCookie) Reply() (*ResQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return resQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ResQueryVersion
|
||||
func resQueryVersionReply(buf []byte) *ResQueryVersionReply {
|
||||
v := new(ResQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajor = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinor = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ResQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ResQueryVersion
|
||||
func (c *Conn) resQueryVersionRequest(ClientMajor byte, ClientMinor byte) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = ClientMajor
|
||||
b += 1
|
||||
|
||||
buf[b] = ClientMinor
|
||||
b += 1
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ResQueryClients
|
||||
// size: 4
|
||||
type ResQueryClientsCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryClients() ResQueryClientsCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.resQueryClientsRequest(), cookie)
|
||||
return ResQueryClientsCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryClientsUnchecked() ResQueryClientsCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.resQueryClientsRequest(), cookie)
|
||||
return ResQueryClientsCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ResQueryClients
|
||||
// size: (32 + pad((int(NumClients) * 8)))
|
||||
type ResQueryClientsReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
NumClients uint32
|
||||
// padding: 20 bytes
|
||||
Clients []ResClient // size: pad((int(NumClients) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ResQueryClients
|
||||
func (cook ResQueryClientsCookie) Reply() (*ResQueryClientsReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return resQueryClientsReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ResQueryClients
|
||||
func resQueryClientsReply(buf []byte) *ResQueryClientsReply {
|
||||
v := new(ResQueryClientsReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.NumClients = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Clients = make([]ResClient, v.NumClients)
|
||||
b += ReadResClientList(buf[b:], v.Clients)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ResQueryClientsCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ResQueryClients
|
||||
func (c *Conn) resQueryClientsRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ResQueryClientResources
|
||||
// size: 8
|
||||
type ResQueryClientResourcesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryClientResources(Xid uint32) ResQueryClientResourcesCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.resQueryClientResourcesRequest(Xid), cookie)
|
||||
return ResQueryClientResourcesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryClientResourcesUnchecked(Xid uint32) ResQueryClientResourcesCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.resQueryClientResourcesRequest(Xid), cookie)
|
||||
return ResQueryClientResourcesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ResQueryClientResources
|
||||
// size: (32 + pad((int(NumTypes) * 8)))
|
||||
type ResQueryClientResourcesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
NumTypes uint32
|
||||
// padding: 20 bytes
|
||||
Types []ResType // size: pad((int(NumTypes) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ResQueryClientResources
|
||||
func (cook ResQueryClientResourcesCookie) Reply() (*ResQueryClientResourcesReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return resQueryClientResourcesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ResQueryClientResources
|
||||
func resQueryClientResourcesReply(buf []byte) *ResQueryClientResourcesReply {
|
||||
v := new(ResQueryClientResourcesReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.NumTypes = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Types = make([]ResType, v.NumTypes)
|
||||
b += ReadResTypeList(buf[b:], v.Types)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ResQueryClientResourcesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ResQueryClientResources
|
||||
func (c *Conn) resQueryClientResourcesRequest(Xid uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], Xid)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ResQueryClientPixmapBytes
|
||||
// size: 8
|
||||
type ResQueryClientPixmapBytesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryClientPixmapBytes(Xid uint32) ResQueryClientPixmapBytesCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.resQueryClientPixmapBytesRequest(Xid), cookie)
|
||||
return ResQueryClientPixmapBytesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ResQueryClientPixmapBytesUnchecked(Xid uint32) ResQueryClientPixmapBytesCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.resQueryClientPixmapBytesRequest(Xid), cookie)
|
||||
return ResQueryClientPixmapBytesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ResQueryClientPixmapBytes
|
||||
// size: 16
|
||||
type ResQueryClientPixmapBytesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Bytes uint32
|
||||
BytesOverflow uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ResQueryClientPixmapBytes
|
||||
func (cook ResQueryClientPixmapBytesCookie) Reply() (*ResQueryClientPixmapBytesReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return resQueryClientPixmapBytesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ResQueryClientPixmapBytes
|
||||
func resQueryClientPixmapBytesReply(buf []byte) *ResQueryClientPixmapBytesReply {
|
||||
v := new(ResQueryClientPixmapBytesReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Bytes = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.BytesOverflow = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ResQueryClientPixmapBytesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ResQueryClientPixmapBytes
|
||||
func (c *Conn) resQueryClientPixmapBytesRequest(Xid uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], Xid)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
@ -1,627 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by screensaver.xml on May 10 2012 12:39:34pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
|
||||
// ScreensaverInit must be called before using the MIT-SCREEN-SAVER extension.
|
||||
func (c *Conn) ScreensaverInit() error {
|
||||
reply, err := c.QueryExtension(16, "MIT-SCREEN-SAVER").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named MIT-SCREEN-SAVER could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["MIT-SCREEN-SAVER"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["MIT-SCREEN-SAVER"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["MIT-SCREEN-SAVER"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["MIT-SCREEN-SAVER"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["MIT-SCREEN-SAVER"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
const (
|
||||
ScreensaverKindBlanked = 0
|
||||
ScreensaverKindInternal = 1
|
||||
ScreensaverKindExternal = 2
|
||||
)
|
||||
|
||||
const (
|
||||
ScreensaverEventNotifyMask = 1
|
||||
ScreensaverEventCycleMask = 2
|
||||
)
|
||||
|
||||
const (
|
||||
ScreensaverStateOff = 0
|
||||
ScreensaverStateOn = 1
|
||||
ScreensaverStateCycle = 2
|
||||
ScreensaverStateDisabled = 3
|
||||
)
|
||||
|
||||
// Event definition ScreensaverNotify (0)
|
||||
// Size: 32
|
||||
|
||||
const ScreensaverNotify = 0
|
||||
|
||||
type ScreensaverNotifyEvent struct {
|
||||
Sequence uint16
|
||||
Code byte
|
||||
State byte
|
||||
// padding: 1 bytes
|
||||
SequenceNumber uint16
|
||||
Time Timestamp
|
||||
Root Window
|
||||
Window Window
|
||||
Kind byte
|
||||
Forced bool
|
||||
// padding: 14 bytes
|
||||
}
|
||||
|
||||
// Event read ScreensaverNotify
|
||||
func NewScreensaverNotifyEvent(buf []byte) Event {
|
||||
v := ScreensaverNotifyEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
v.Code = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.State = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.SequenceNumber = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Time = Timestamp(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Root = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Window = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Kind = buf[b]
|
||||
b += 1
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Forced = true
|
||||
} else {
|
||||
v.Forced = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 14 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write ScreensaverNotify
|
||||
func (v ScreensaverNotifyEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
buf[b] = v.Code
|
||||
b += 1
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
buf[b] = v.State
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
Put16(buf[b:], v.SequenceNumber)
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(v.Time))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(v.Root))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(v.Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = v.Kind
|
||||
b += 1
|
||||
|
||||
if v.Forced {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 14 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v ScreensaverNotifyEvent) ImplementsEvent() {}
|
||||
|
||||
func (v ScreensaverNotifyEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v ScreensaverNotifyEvent) String() string {
|
||||
fieldVals := make([]string, 0, 10)
|
||||
fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, sprintf("Code: %d", v.Code))
|
||||
fieldVals = append(fieldVals, sprintf("State: %d", v.State))
|
||||
fieldVals = append(fieldVals, sprintf("SequenceNumber: %d", v.SequenceNumber))
|
||||
fieldVals = append(fieldVals, sprintf("Time: %d", v.Time))
|
||||
fieldVals = append(fieldVals, sprintf("Root: %d", v.Root))
|
||||
fieldVals = append(fieldVals, sprintf("Window: %d", v.Window))
|
||||
fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind))
|
||||
fieldVals = append(fieldVals, sprintf("Forced: %t", v.Forced))
|
||||
return "ScreensaverNotify {" + stringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["MIT-SCREEN-SAVER"][0] = NewScreensaverNotifyEvent
|
||||
}
|
||||
|
||||
// Request ScreensaverQueryVersion
|
||||
// size: 8
|
||||
type ScreensaverQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverQueryVersion(ClientMajorVersion byte, ClientMinorVersion byte) ScreensaverQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.screensaverQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return ScreensaverQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverQueryVersionUnchecked(ClientMajorVersion byte, ClientMinorVersion byte) ScreensaverQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.screensaverQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return ScreensaverQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ScreensaverQueryVersion
|
||||
// size: 32
|
||||
type ScreensaverQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ScreensaverQueryVersion
|
||||
func (cook ScreensaverQueryVersionCookie) Reply() (*ScreensaverQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return screensaverQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ScreensaverQueryVersion
|
||||
func screensaverQueryVersionReply(buf []byte) *ScreensaverQueryVersionReply {
|
||||
v := new(ScreensaverQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ScreensaverQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverQueryVersion
|
||||
func (c *Conn) screensaverQueryVersionRequest(ClientMajorVersion byte, ClientMinorVersion byte) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = ClientMajorVersion
|
||||
b += 1
|
||||
|
||||
buf[b] = ClientMinorVersion
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ScreensaverQueryInfo
|
||||
// size: 8
|
||||
type ScreensaverQueryInfoCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverQueryInfo(Drawable Drawable) ScreensaverQueryInfoCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.screensaverQueryInfoRequest(Drawable), cookie)
|
||||
return ScreensaverQueryInfoCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverQueryInfoUnchecked(Drawable Drawable) ScreensaverQueryInfoCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.screensaverQueryInfoRequest(Drawable), cookie)
|
||||
return ScreensaverQueryInfoCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ScreensaverQueryInfo
|
||||
// size: 32
|
||||
type ScreensaverQueryInfoReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
State byte
|
||||
SaverWindow Window
|
||||
MsUntilServer uint32
|
||||
MsSinceUserInput uint32
|
||||
EventMask uint32
|
||||
Kind byte
|
||||
// padding: 7 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ScreensaverQueryInfo
|
||||
func (cook ScreensaverQueryInfoCookie) Reply() (*ScreensaverQueryInfoReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return screensaverQueryInfoReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ScreensaverQueryInfo
|
||||
func screensaverQueryInfoReply(buf []byte) *ScreensaverQueryInfoReply {
|
||||
v := new(ScreensaverQueryInfoReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.State = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.SaverWindow = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.MsUntilServer = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.MsSinceUserInput = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.EventMask = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Kind = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 7 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ScreensaverQueryInfoCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverQueryInfo
|
||||
func (c *Conn) screensaverQueryInfoRequest(Drawable Drawable) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ScreensaverSelectInput
|
||||
// size: 12
|
||||
type ScreensaverSelectInputCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverSelectInput
|
||||
func (c *Conn) ScreensaverSelectInput(Drawable Drawable, EventMask uint32) ScreensaverSelectInputCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.screensaverSelectInputRequest(Drawable, EventMask), cookie)
|
||||
return ScreensaverSelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverSelectInputChecked(Drawable Drawable, EventMask uint32) ScreensaverSelectInputCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.screensaverSelectInputRequest(Drawable, EventMask), cookie)
|
||||
return ScreensaverSelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ScreensaverSelectInputCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverSelectInput
|
||||
func (c *Conn) screensaverSelectInputRequest(Drawable Drawable, EventMask uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], EventMask)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ScreensaverSetAttributes
|
||||
// size: pad((24 + (4 + pad((4 * popCount(int(ValueMask)))))))
|
||||
type ScreensaverSetAttributesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverSetAttributes
|
||||
func (c *Conn) ScreensaverSetAttributes(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual Visualid, ValueMask uint32, ValueList []uint32) ScreensaverSetAttributesCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.screensaverSetAttributesRequest(Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie)
|
||||
return ScreensaverSetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverSetAttributesChecked(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual Visualid, ValueMask uint32, ValueList []uint32) ScreensaverSetAttributesCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.screensaverSetAttributesRequest(Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie)
|
||||
return ScreensaverSetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ScreensaverSetAttributesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverSetAttributes
|
||||
func (c *Conn) screensaverSetAttributesRequest(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte {
|
||||
size := pad((24 + (4 + pad((4 * popCount(int(ValueMask)))))))
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], uint16(X))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(Y))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], BorderWidth)
|
||||
b += 2
|
||||
|
||||
buf[b] = Class
|
||||
b += 1
|
||||
|
||||
buf[b] = Depth
|
||||
b += 1
|
||||
|
||||
Put32(buf[b:], uint32(Visual))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], ValueMask)
|
||||
b += 4
|
||||
for i := 0; i < popCount(int(ValueMask)); i++ {
|
||||
Put32(buf[b:], ValueList[i])
|
||||
b += 4
|
||||
}
|
||||
b = pad(b)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ScreensaverUnsetAttributes
|
||||
// size: 8
|
||||
type ScreensaverUnsetAttributesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverUnsetAttributes
|
||||
func (c *Conn) ScreensaverUnsetAttributes(Drawable Drawable) ScreensaverUnsetAttributesCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.screensaverUnsetAttributesRequest(Drawable), cookie)
|
||||
return ScreensaverUnsetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverUnsetAttributesChecked(Drawable Drawable) ScreensaverUnsetAttributesCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.screensaverUnsetAttributesRequest(Drawable), cookie)
|
||||
return ScreensaverUnsetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ScreensaverUnsetAttributesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverUnsetAttributes
|
||||
func (c *Conn) screensaverUnsetAttributesRequest(Drawable Drawable) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ScreensaverSuspend
|
||||
// size: 8
|
||||
type ScreensaverSuspendCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverSuspend
|
||||
func (c *Conn) ScreensaverSuspend(Suspend bool) ScreensaverSuspendCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.screensaverSuspendRequest(Suspend), cookie)
|
||||
return ScreensaverSuspendCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ScreensaverSuspendChecked(Suspend bool) ScreensaverSuspendCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.screensaverSuspendRequest(Suspend), cookie)
|
||||
return ScreensaverSuspendCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ScreensaverSuspendCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ScreensaverSuspend
|
||||
func (c *Conn) screensaverSuspendRequest(Suspend bool) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
if Suspend {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
@ -1,897 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by shape.xml on May 10 2012 12:39:34pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
|
||||
// ShapeInit must be called before using the SHAPE extension.
|
||||
func (c *Conn) ShapeInit() error {
|
||||
reply, err := c.QueryExtension(5, "SHAPE").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named SHAPE could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["SHAPE"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["SHAPE"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["SHAPE"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["SHAPE"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["SHAPE"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
const (
|
||||
ShapeSoSet = 0
|
||||
ShapeSoUnion = 1
|
||||
ShapeSoIntersect = 2
|
||||
ShapeSoSubtract = 3
|
||||
ShapeSoInvert = 4
|
||||
)
|
||||
|
||||
const (
|
||||
ShapeSkBounding = 0
|
||||
ShapeSkClip = 1
|
||||
ShapeSkInput = 2
|
||||
)
|
||||
|
||||
type ShapeOp byte
|
||||
|
||||
type ShapeKind byte
|
||||
|
||||
// Event definition ShapeNotify (0)
|
||||
// Size: 32
|
||||
|
||||
const ShapeNotify = 0
|
||||
|
||||
type ShapeNotifyEvent struct {
|
||||
Sequence uint16
|
||||
ShapeKind ShapeKind
|
||||
AffectedWindow Window
|
||||
ExtentsX int16
|
||||
ExtentsY int16
|
||||
ExtentsWidth uint16
|
||||
ExtentsHeight uint16
|
||||
ServerTime Timestamp
|
||||
Shaped bool
|
||||
// padding: 11 bytes
|
||||
}
|
||||
|
||||
// Event read ShapeNotify
|
||||
func NewShapeNotifyEvent(buf []byte) Event {
|
||||
v := ShapeNotifyEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
v.ShapeKind = ShapeKind(buf[b])
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.AffectedWindow = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.ExtentsX = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ExtentsY = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ExtentsWidth = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ExtentsHeight = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerTime = Timestamp(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Shaped = true
|
||||
} else {
|
||||
v.Shaped = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 11 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write ShapeNotify
|
||||
func (v ShapeNotifyEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(v.ShapeKind)
|
||||
b += 1
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
Put32(buf[b:], uint32(v.AffectedWindow))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], uint16(v.ExtentsX))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(v.ExtentsY))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.ExtentsWidth)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.ExtentsHeight)
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(v.ServerTime))
|
||||
b += 4
|
||||
|
||||
if v.Shaped {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 11 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v ShapeNotifyEvent) ImplementsEvent() {}
|
||||
|
||||
func (v ShapeNotifyEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v ShapeNotifyEvent) String() string {
|
||||
fieldVals := make([]string, 0, 9)
|
||||
fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, sprintf("ShapeKind: %d", v.ShapeKind))
|
||||
fieldVals = append(fieldVals, sprintf("AffectedWindow: %d", v.AffectedWindow))
|
||||
fieldVals = append(fieldVals, sprintf("ExtentsX: %d", v.ExtentsX))
|
||||
fieldVals = append(fieldVals, sprintf("ExtentsY: %d", v.ExtentsY))
|
||||
fieldVals = append(fieldVals, sprintf("ExtentsWidth: %d", v.ExtentsWidth))
|
||||
fieldVals = append(fieldVals, sprintf("ExtentsHeight: %d", v.ExtentsHeight))
|
||||
fieldVals = append(fieldVals, sprintf("ServerTime: %d", v.ServerTime))
|
||||
fieldVals = append(fieldVals, sprintf("Shaped: %t", v.Shaped))
|
||||
return "ShapeNotify {" + stringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["SHAPE"][0] = NewShapeNotifyEvent
|
||||
}
|
||||
|
||||
// Request ShapeQueryVersion
|
||||
// size: 4
|
||||
type ShapeQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeQueryVersion() ShapeQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.shapeQueryVersionRequest(), cookie)
|
||||
return ShapeQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeQueryVersionUnchecked() ShapeQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.shapeQueryVersionRequest(), cookie)
|
||||
return ShapeQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ShapeQueryVersion
|
||||
// size: 12
|
||||
type ShapeQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint16
|
||||
MinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ShapeQueryVersion
|
||||
func (cook ShapeQueryVersionCookie) Reply() (*ShapeQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return shapeQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ShapeQueryVersion
|
||||
func shapeQueryVersionReply(buf []byte) *ShapeQueryVersionReply {
|
||||
v := new(ShapeQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ShapeQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeQueryVersion
|
||||
func (c *Conn) shapeQueryVersionRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeRectangles
|
||||
// size: pad((16 + pad((len(Rectangles) * 8))))
|
||||
type ShapeRectanglesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeRectangles
|
||||
func (c *Conn) ShapeRectangles(Operation ShapeOp, DestinationKind ShapeKind, Ordering byte, DestinationWindow Window, XOffset int16, YOffset int16, Rectangles []Rectangle) ShapeRectanglesCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shapeRectanglesRequest(Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie)
|
||||
return ShapeRectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeRectanglesChecked(Operation ShapeOp, DestinationKind ShapeKind, Ordering byte, DestinationWindow Window, XOffset int16, YOffset int16, Rectangles []Rectangle) ShapeRectanglesCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shapeRectanglesRequest(Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie)
|
||||
return ShapeRectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShapeRectanglesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeRectangles
|
||||
func (c *Conn) shapeRectanglesRequest(Operation ShapeOp, DestinationKind ShapeKind, Ordering byte, DestinationWindow Window, XOffset int16, YOffset int16, Rectangles []Rectangle) []byte {
|
||||
size := pad((16 + pad((len(Rectangles) * 8))))
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(Operation)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
buf[b] = Ordering
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
b += RectangleListBytes(buf[b:], Rectangles)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeMask
|
||||
// size: 20
|
||||
type ShapeMaskCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeMask
|
||||
func (c *Conn) ShapeMask(Operation ShapeOp, DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceBitmap Pixmap) ShapeMaskCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shapeMaskRequest(Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie)
|
||||
return ShapeMaskCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeMaskChecked(Operation ShapeOp, DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceBitmap Pixmap) ShapeMaskCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shapeMaskRequest(Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie)
|
||||
return ShapeMaskCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShapeMaskCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeMask
|
||||
func (c *Conn) shapeMaskRequest(Operation ShapeOp, DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceBitmap Pixmap) []byte {
|
||||
size := 20
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(Operation)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(SourceBitmap))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeCombine
|
||||
// size: 20
|
||||
type ShapeCombineCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeCombine
|
||||
func (c *Conn) ShapeCombine(Operation ShapeOp, DestinationKind ShapeKind, SourceKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceWindow Window) ShapeCombineCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shapeCombineRequest(Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie)
|
||||
return ShapeCombineCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeCombineChecked(Operation ShapeOp, DestinationKind ShapeKind, SourceKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceWindow Window) ShapeCombineCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shapeCombineRequest(Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie)
|
||||
return ShapeCombineCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShapeCombineCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeCombine
|
||||
func (c *Conn) shapeCombineRequest(Operation ShapeOp, DestinationKind ShapeKind, SourceKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceWindow Window) []byte {
|
||||
size := 20
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(Operation)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(SourceKind)
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(SourceWindow))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeOffset
|
||||
// size: 16
|
||||
type ShapeOffsetCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeOffset
|
||||
func (c *Conn) ShapeOffset(DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16) ShapeOffsetCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shapeOffsetRequest(DestinationKind, DestinationWindow, XOffset, YOffset), cookie)
|
||||
return ShapeOffsetCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeOffsetChecked(DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16) ShapeOffsetCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shapeOffsetRequest(DestinationKind, DestinationWindow, XOffset, YOffset), cookie)
|
||||
return ShapeOffsetCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShapeOffsetCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeOffset
|
||||
func (c *Conn) shapeOffsetRequest(DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeQueryExtents
|
||||
// size: 8
|
||||
type ShapeQueryExtentsCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeQueryExtents(DestinationWindow Window) ShapeQueryExtentsCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.shapeQueryExtentsRequest(DestinationWindow), cookie)
|
||||
return ShapeQueryExtentsCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeQueryExtentsUnchecked(DestinationWindow Window) ShapeQueryExtentsCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.shapeQueryExtentsRequest(DestinationWindow), cookie)
|
||||
return ShapeQueryExtentsCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ShapeQueryExtents
|
||||
// size: 28
|
||||
type ShapeQueryExtentsReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
BoundingShaped bool
|
||||
ClipShaped bool
|
||||
// padding: 2 bytes
|
||||
BoundingShapeExtentsX int16
|
||||
BoundingShapeExtentsY int16
|
||||
BoundingShapeExtentsWidth uint16
|
||||
BoundingShapeExtentsHeight uint16
|
||||
ClipShapeExtentsX int16
|
||||
ClipShapeExtentsY int16
|
||||
ClipShapeExtentsWidth uint16
|
||||
ClipShapeExtentsHeight uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ShapeQueryExtents
|
||||
func (cook ShapeQueryExtentsCookie) Reply() (*ShapeQueryExtentsReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return shapeQueryExtentsReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ShapeQueryExtents
|
||||
func shapeQueryExtentsReply(buf []byte) *ShapeQueryExtentsReply {
|
||||
v := new(ShapeQueryExtentsReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.BoundingShaped = true
|
||||
} else {
|
||||
v.BoundingShaped = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.ClipShaped = true
|
||||
} else {
|
||||
v.ClipShaped = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
v.BoundingShapeExtentsX = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.BoundingShapeExtentsY = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.BoundingShapeExtentsWidth = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.BoundingShapeExtentsHeight = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsX = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsY = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsWidth = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsHeight = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ShapeQueryExtentsCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeQueryExtents
|
||||
func (c *Conn) shapeQueryExtentsRequest(DestinationWindow Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeSelectInput
|
||||
// size: 12
|
||||
type ShapeSelectInputCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeSelectInput
|
||||
func (c *Conn) ShapeSelectInput(DestinationWindow Window, Enable bool) ShapeSelectInputCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shapeSelectInputRequest(DestinationWindow, Enable), cookie)
|
||||
return ShapeSelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeSelectInputChecked(DestinationWindow Window, Enable bool) ShapeSelectInputCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shapeSelectInputRequest(DestinationWindow, Enable), cookie)
|
||||
return ShapeSelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShapeSelectInputCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeSelectInput
|
||||
func (c *Conn) shapeSelectInputRequest(DestinationWindow Window, Enable bool) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
if Enable {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeInputSelected
|
||||
// size: 8
|
||||
type ShapeInputSelectedCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeInputSelected(DestinationWindow Window) ShapeInputSelectedCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.shapeInputSelectedRequest(DestinationWindow), cookie)
|
||||
return ShapeInputSelectedCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeInputSelectedUnchecked(DestinationWindow Window) ShapeInputSelectedCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.shapeInputSelectedRequest(DestinationWindow), cookie)
|
||||
return ShapeInputSelectedCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ShapeInputSelected
|
||||
// size: 8
|
||||
type ShapeInputSelectedReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Enabled bool
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ShapeInputSelected
|
||||
func (cook ShapeInputSelectedCookie) Reply() (*ShapeInputSelectedReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return shapeInputSelectedReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ShapeInputSelected
|
||||
func shapeInputSelectedReply(buf []byte) *ShapeInputSelectedReply {
|
||||
v := new(ShapeInputSelectedReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Enabled = true
|
||||
} else {
|
||||
v.Enabled = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ShapeInputSelectedCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeInputSelected
|
||||
func (c *Conn) shapeInputSelectedRequest(DestinationWindow Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShapeGetRectangles
|
||||
// size: 12
|
||||
type ShapeGetRectanglesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeGetRectangles(Window Window, SourceKind ShapeKind) ShapeGetRectanglesCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.shapeGetRectanglesRequest(Window, SourceKind), cookie)
|
||||
return ShapeGetRectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShapeGetRectanglesUnchecked(Window Window, SourceKind ShapeKind) ShapeGetRectanglesCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.shapeGetRectanglesRequest(Window, SourceKind), cookie)
|
||||
return ShapeGetRectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ShapeGetRectangles
|
||||
// size: (32 + pad((int(RectanglesLen) * 8)))
|
||||
type ShapeGetRectanglesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Ordering byte
|
||||
RectanglesLen uint32
|
||||
// padding: 20 bytes
|
||||
Rectangles []Rectangle // size: pad((int(RectanglesLen) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ShapeGetRectangles
|
||||
func (cook ShapeGetRectanglesCookie) Reply() (*ShapeGetRectanglesReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return shapeGetRectanglesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ShapeGetRectangles
|
||||
func shapeGetRectanglesReply(buf []byte) *ShapeGetRectanglesReply {
|
||||
v := new(ShapeGetRectanglesReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.Ordering = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.RectanglesLen = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Rectangles = make([]Rectangle, v.RectanglesLen)
|
||||
b += ReadRectangleList(buf[b:], v.Rectangles)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ShapeGetRectanglesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShapeGetRectangles
|
||||
func (c *Conn) shapeGetRectanglesRequest(Window Window, SourceKind ShapeKind) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 8 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = byte(SourceKind)
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
@ -1,678 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by shm.xml on May 10 2012 12:39:34pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
|
||||
// ShmInit must be called before using the MIT-SHM extension.
|
||||
func (c *Conn) ShmInit() error {
|
||||
reply, err := c.QueryExtension(7, "MIT-SHM").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named MIT-SHM could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["MIT-SHM"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["MIT-SHM"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["MIT-SHM"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["MIT-SHM"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["MIT-SHM"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
type ShmSeg uint32
|
||||
|
||||
func (c *Conn) NewShmSegId() (ShmSeg, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return ShmSeg(id), nil
|
||||
}
|
||||
|
||||
// Event definition ShmCompletion (0)
|
||||
// Size: 32
|
||||
|
||||
const ShmCompletion = 0
|
||||
|
||||
type ShmCompletionEvent struct {
|
||||
Sequence uint16
|
||||
// padding: 1 bytes
|
||||
Drawable Drawable
|
||||
MinorEvent uint16
|
||||
MajorEvent byte
|
||||
// padding: 1 bytes
|
||||
Shmseg ShmSeg
|
||||
Offset uint32
|
||||
}
|
||||
|
||||
// Event read ShmCompletion
|
||||
func NewShmCompletionEvent(buf []byte) Event {
|
||||
v := ShmCompletionEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Drawable = Drawable(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.MinorEvent = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MajorEvent = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Shmseg = ShmSeg(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Offset = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write ShmCompletion
|
||||
func (v ShmCompletionEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
Put32(buf[b:], uint32(v.Drawable))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], v.MinorEvent)
|
||||
b += 2
|
||||
|
||||
buf[b] = v.MajorEvent
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
Put32(buf[b:], uint32(v.Shmseg))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], v.Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v ShmCompletionEvent) ImplementsEvent() {}
|
||||
|
||||
func (v ShmCompletionEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v ShmCompletionEvent) String() string {
|
||||
fieldVals := make([]string, 0, 7)
|
||||
fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable))
|
||||
fieldVals = append(fieldVals, sprintf("MinorEvent: %d", v.MinorEvent))
|
||||
fieldVals = append(fieldVals, sprintf("MajorEvent: %d", v.MajorEvent))
|
||||
fieldVals = append(fieldVals, sprintf("Shmseg: %d", v.Shmseg))
|
||||
fieldVals = append(fieldVals, sprintf("Offset: %d", v.Offset))
|
||||
return "ShmCompletion {" + stringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["MIT-SHM"][0] = NewShmCompletionEvent
|
||||
}
|
||||
|
||||
// ErrorCopy definition ShmBadSeg (0)
|
||||
|
||||
const BadShmBadSeg = 0
|
||||
|
||||
type ShmBadSegError ValueError
|
||||
|
||||
func NewShmBadSegError(buf []byte) Error {
|
||||
v := ShmBadSegError(NewValueError(buf).(ValueError))
|
||||
v.NiceName = "ShmBadSeg"
|
||||
return v
|
||||
}
|
||||
|
||||
func (err ShmBadSegError) ImplementsError() {}
|
||||
|
||||
func (err ShmBadSegError) SequenceId() uint16 {
|
||||
return err.Sequence
|
||||
}
|
||||
|
||||
func (err ShmBadSegError) BadId() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (err ShmBadSegError) Error() string {
|
||||
fieldVals := make([]string, 0, 4)
|
||||
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
||||
fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence))
|
||||
fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue))
|
||||
fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode))
|
||||
fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode))
|
||||
return "BadShmBadSeg {" + stringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtErrorFuncs["MIT-SHM"][0] = NewShmBadSegError
|
||||
}
|
||||
|
||||
// Request ShmQueryVersion
|
||||
// size: 4
|
||||
type ShmQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ShmQueryVersion() ShmQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.shmQueryVersionRequest(), cookie)
|
||||
return ShmQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShmQueryVersionUnchecked() ShmQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.shmQueryVersionRequest(), cookie)
|
||||
return ShmQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ShmQueryVersion
|
||||
// size: 32
|
||||
type ShmQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
SharedPixmaps bool
|
||||
MajorVersion uint16
|
||||
MinorVersion uint16
|
||||
Uid uint16
|
||||
Gid uint16
|
||||
PixmapFormat byte
|
||||
// padding: 15 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ShmQueryVersion
|
||||
func (cook ShmQueryVersionCookie) Reply() (*ShmQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return shmQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ShmQueryVersion
|
||||
func shmQueryVersionReply(buf []byte) *ShmQueryVersionReply {
|
||||
v := new(ShmQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.SharedPixmaps = true
|
||||
} else {
|
||||
v.SharedPixmaps = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Uid = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Gid = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.PixmapFormat = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 15 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ShmQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShmQueryVersion
|
||||
func (c *Conn) shmQueryVersionRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShmAttach
|
||||
// size: 16
|
||||
type ShmAttachCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShmAttach
|
||||
func (c *Conn) ShmAttach(Shmseg ShmSeg, Shmid uint32, ReadOnly bool) ShmAttachCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shmAttachRequest(Shmseg, Shmid, ReadOnly), cookie)
|
||||
return ShmAttachCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShmAttachChecked(Shmseg ShmSeg, Shmid uint32, ReadOnly bool) ShmAttachCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shmAttachRequest(Shmseg, Shmid, ReadOnly), cookie)
|
||||
return ShmAttachCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShmAttachCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShmAttach
|
||||
func (c *Conn) shmAttachRequest(Shmseg ShmSeg, Shmid uint32, ReadOnly bool) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], Shmid)
|
||||
b += 4
|
||||
|
||||
if ReadOnly {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShmDetach
|
||||
// size: 8
|
||||
type ShmDetachCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShmDetach
|
||||
func (c *Conn) ShmDetach(Shmseg ShmSeg) ShmDetachCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shmDetachRequest(Shmseg), cookie)
|
||||
return ShmDetachCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShmDetachChecked(Shmseg ShmSeg) ShmDetachCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shmDetachRequest(Shmseg), cookie)
|
||||
return ShmDetachCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShmDetachCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShmDetach
|
||||
func (c *Conn) shmDetachRequest(Shmseg ShmSeg) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShmPutImage
|
||||
// size: 40
|
||||
type ShmPutImageCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShmPutImage
|
||||
func (c *Conn) ShmPutImage(Drawable Drawable, Gc Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg ShmSeg, Offset uint32) ShmPutImageCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shmPutImageRequest(Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
|
||||
return ShmPutImageCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShmPutImageChecked(Drawable Drawable, Gc Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg ShmSeg, Offset uint32) ShmPutImageCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shmPutImageRequest(Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
|
||||
return ShmPutImageCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShmPutImageCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShmPutImage
|
||||
func (c *Conn) shmPutImageRequest(Drawable Drawable, Gc Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg ShmSeg, Offset uint32) []byte {
|
||||
size := 40
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Gc))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], TotalWidth)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], TotalHeight)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], SrcX)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], SrcY)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], SrcWidth)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], SrcHeight)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(DstX))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(DstY))
|
||||
b += 2
|
||||
|
||||
buf[b] = Depth
|
||||
b += 1
|
||||
|
||||
buf[b] = Format
|
||||
b += 1
|
||||
|
||||
buf[b] = SendEvent
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShmGetImage
|
||||
// size: 32
|
||||
type ShmGetImageCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) ShmGetImage(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg ShmSeg, Offset uint32) ShmGetImageCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.shmGetImageRequest(Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie)
|
||||
return ShmGetImageCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShmGetImageUnchecked(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg ShmSeg, Offset uint32) ShmGetImageCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.shmGetImageRequest(Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie)
|
||||
return ShmGetImageCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ShmGetImage
|
||||
// size: 16
|
||||
type ShmGetImageReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Depth byte
|
||||
Visual Visualid
|
||||
Size uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ShmGetImage
|
||||
func (cook ShmGetImageCookie) Reply() (*ShmGetImageReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return shmGetImageReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ShmGetImage
|
||||
func shmGetImageReply(buf []byte) *ShmGetImageReply {
|
||||
v := new(ShmGetImageReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.Depth = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Visual = Visualid(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Size = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook ShmGetImageCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShmGetImage
|
||||
func (c *Conn) shmGetImageRequest(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg ShmSeg, Offset uint32) []byte {
|
||||
size := 32
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], uint16(X))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(Y))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], PlaneMask)
|
||||
b += 4
|
||||
|
||||
buf[b] = Format
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ShmCreatePixmap
|
||||
// size: 28
|
||||
type ShmCreatePixmapCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ShmCreatePixmap
|
||||
func (c *Conn) ShmCreatePixmap(Pid Pixmap, Drawable Drawable, Width uint16, Height uint16, Depth byte, Shmseg ShmSeg, Offset uint32) ShmCreatePixmapCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.shmCreatePixmapRequest(Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
|
||||
return ShmCreatePixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) ShmCreatePixmapChecked(Pid Pixmap, Drawable Drawable, Width uint16, Height uint16, Depth byte, Shmseg ShmSeg, Offset uint32) ShmCreatePixmapCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.shmCreatePixmapRequest(Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
|
||||
return ShmCreatePixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ShmCreatePixmapCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for ShmCreatePixmap
|
||||
func (c *Conn) shmCreatePixmapRequest(Pid Pixmap, Drawable Drawable, Width uint16, Height uint16, Depth byte, Shmseg ShmSeg, Offset uint32) []byte {
|
||||
size := 28
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Pid))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
buf[b] = Depth
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
1949
nexgb/auto_sync.go
1949
nexgb/auto_sync.go
File diff suppressed because it is too large
Load Diff
@ -1,326 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by xc_misc.xml on May 10 2012 12:39:34pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Xc_miscInit must be called before using the XC-MISC extension.
|
||||
func (c *Conn) Xc_miscInit() error {
|
||||
reply, err := c.QueryExtension(7, "XC-MISC").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named XC-MISC could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["XC-MISC"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["XC-MISC"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["XC-MISC"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["XC-MISC"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["XC-MISC"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Request Xc_miscGetVersion
|
||||
// size: 8
|
||||
type Xc_miscGetVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) Xc_miscGetVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) Xc_miscGetVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xc_miscGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return Xc_miscGetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) Xc_miscGetVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) Xc_miscGetVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xc_miscGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return Xc_miscGetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Xc_miscGetVersion
|
||||
// size: 12
|
||||
type Xc_miscGetVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Xc_miscGetVersion
|
||||
func (cook Xc_miscGetVersionCookie) Reply() (*Xc_miscGetVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xc_miscGetVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Xc_miscGetVersion
|
||||
func xc_miscGetVersionReply(buf []byte) *Xc_miscGetVersionReply {
|
||||
v := new(Xc_miscGetVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook Xc_miscGetVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for Xc_miscGetVersion
|
||||
func (c *Conn) xc_miscGetVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XC-MISC"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Xc_miscGetXIDRange
|
||||
// size: 4
|
||||
type Xc_miscGetXIDRangeCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) Xc_miscGetXIDRange() Xc_miscGetXIDRangeCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xc_miscGetXIDRangeRequest(), cookie)
|
||||
return Xc_miscGetXIDRangeCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) Xc_miscGetXIDRangeUnchecked() Xc_miscGetXIDRangeCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xc_miscGetXIDRangeRequest(), cookie)
|
||||
return Xc_miscGetXIDRangeCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Xc_miscGetXIDRange
|
||||
// size: 16
|
||||
type Xc_miscGetXIDRangeReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
StartId uint32
|
||||
Count uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Xc_miscGetXIDRange
|
||||
func (cook Xc_miscGetXIDRangeCookie) Reply() (*Xc_miscGetXIDRangeReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xc_miscGetXIDRangeReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Xc_miscGetXIDRange
|
||||
func xc_miscGetXIDRangeReply(buf []byte) *Xc_miscGetXIDRangeReply {
|
||||
v := new(Xc_miscGetXIDRangeReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.StartId = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Count = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook Xc_miscGetXIDRangeCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for Xc_miscGetXIDRange
|
||||
func (c *Conn) xc_miscGetXIDRangeRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XC-MISC"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Xc_miscGetXIDList
|
||||
// size: 8
|
||||
type Xc_miscGetXIDListCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) Xc_miscGetXIDList(Count uint32) Xc_miscGetXIDListCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xc_miscGetXIDListRequest(Count), cookie)
|
||||
return Xc_miscGetXIDListCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) Xc_miscGetXIDListUnchecked(Count uint32) Xc_miscGetXIDListCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xc_miscGetXIDListRequest(Count), cookie)
|
||||
return Xc_miscGetXIDListCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Xc_miscGetXIDList
|
||||
// size: (32 + pad((int(IdsLen) * 4)))
|
||||
type Xc_miscGetXIDListReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
IdsLen uint32
|
||||
// padding: 20 bytes
|
||||
Ids []uint32 // size: pad((int(IdsLen) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Xc_miscGetXIDList
|
||||
func (cook Xc_miscGetXIDListCookie) Reply() (*Xc_miscGetXIDListReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xc_miscGetXIDListReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Xc_miscGetXIDList
|
||||
func xc_miscGetXIDListReply(buf []byte) *Xc_miscGetXIDListReply {
|
||||
v := new(Xc_miscGetXIDListReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.IdsLen = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Ids = make([]uint32, v.IdsLen)
|
||||
for i := 0; i < int(v.IdsLen); i++ {
|
||||
v.Ids[i] = Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook Xc_miscGetXIDListCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for Xc_miscGetXIDList
|
||||
func (c *Conn) xc_miscGetXIDListRequest(Count uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XC-MISC"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], Count)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
@ -1,539 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by xevie.xml on May 10 2012 12:39:34pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// XevieInit must be called before using the XEVIE extension.
|
||||
func (c *Conn) XevieInit() error {
|
||||
reply, err := c.QueryExtension(5, "XEVIE").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named XEVIE could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["XEVIE"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["XEVIE"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["XEVIE"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["XEVIE"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["XEVIE"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
const (
|
||||
XevieDatatypeUnmodified = 0
|
||||
XevieDatatypeModified = 1
|
||||
)
|
||||
|
||||
// 'XevieEvent' struct definition
|
||||
// Size: 32
|
||||
type XevieEvent struct {
|
||||
// padding: 32 bytes
|
||||
}
|
||||
|
||||
// Struct read XevieEvent
|
||||
func ReadXevieEvent(buf []byte, v *XevieEvent) int {
|
||||
b := 0
|
||||
|
||||
b += 32 // padding
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read XevieEvent
|
||||
func ReadXevieEventList(buf []byte, dest []XevieEvent) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = XevieEvent{}
|
||||
b += ReadXevieEvent(buf[b:], &dest[i])
|
||||
}
|
||||
return pad(b)
|
||||
}
|
||||
|
||||
// Struct write XevieEvent
|
||||
func (v XevieEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
b += 32 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list XevieEvent
|
||||
func XevieEventListBytes(buf []byte, list []XevieEvent) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request XevieQueryVersion
|
||||
// size: 8
|
||||
type XevieQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XevieQueryVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) XevieQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xevieQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return XevieQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XevieQueryVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) XevieQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xevieQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return XevieQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XevieQueryVersion
|
||||
// size: 32
|
||||
type XevieQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XevieQueryVersion
|
||||
func (cook XevieQueryVersionCookie) Reply() (*XevieQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xevieQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XevieQueryVersion
|
||||
func xevieQueryVersionReply(buf []byte) *XevieQueryVersionReply {
|
||||
v := new(XevieQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XevieQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XevieQueryVersion
|
||||
func (c *Conn) xevieQueryVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XevieStart
|
||||
// size: 8
|
||||
type XevieStartCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XevieStart(Screen uint32) XevieStartCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xevieStartRequest(Screen), cookie)
|
||||
return XevieStartCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XevieStartUnchecked(Screen uint32) XevieStartCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xevieStartRequest(Screen), cookie)
|
||||
return XevieStartCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XevieStart
|
||||
// size: 32
|
||||
type XevieStartReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XevieStart
|
||||
func (cook XevieStartCookie) Reply() (*XevieStartReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xevieStartReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XevieStart
|
||||
func xevieStartReply(buf []byte) *XevieStartReply {
|
||||
v := new(XevieStartReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XevieStartCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XevieStart
|
||||
func (c *Conn) xevieStartRequest(Screen uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], Screen)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XevieEnd
|
||||
// size: 8
|
||||
type XevieEndCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XevieEnd(Cmap uint32) XevieEndCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xevieEndRequest(Cmap), cookie)
|
||||
return XevieEndCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XevieEndUnchecked(Cmap uint32) XevieEndCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xevieEndRequest(Cmap), cookie)
|
||||
return XevieEndCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XevieEnd
|
||||
// size: 32
|
||||
type XevieEndReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XevieEnd
|
||||
func (cook XevieEndCookie) Reply() (*XevieEndReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xevieEndReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XevieEnd
|
||||
func xevieEndReply(buf []byte) *XevieEndReply {
|
||||
v := new(XevieEndReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XevieEndCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XevieEnd
|
||||
func (c *Conn) xevieEndRequest(Cmap uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], Cmap)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XevieSend
|
||||
// size: 104
|
||||
type XevieSendCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XevieSend(Event XevieEvent, DataType uint32) XevieSendCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xevieSendRequest(Event, DataType), cookie)
|
||||
return XevieSendCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XevieSendUnchecked(Event XevieEvent, DataType uint32) XevieSendCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xevieSendRequest(Event, DataType), cookie)
|
||||
return XevieSendCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XevieSend
|
||||
// size: 32
|
||||
type XevieSendReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XevieSend
|
||||
func (cook XevieSendCookie) Reply() (*XevieSendReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xevieSendReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XevieSend
|
||||
func xevieSendReply(buf []byte) *XevieSendReply {
|
||||
v := new(XevieSendReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XevieSendCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XevieSend
|
||||
func (c *Conn) xevieSendRequest(Event XevieEvent, DataType uint32) []byte {
|
||||
size := 104
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
{
|
||||
structBytes := Event.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
|
||||
Put32(buf[b:], DataType)
|
||||
b += 4
|
||||
|
||||
b += 64 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XevieSelectInput
|
||||
// size: 8
|
||||
type XevieSelectInputCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XevieSelectInput(EventMask uint32) XevieSelectInputCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xevieSelectInputRequest(EventMask), cookie)
|
||||
return XevieSelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XevieSelectInputUnchecked(EventMask uint32) XevieSelectInputCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xevieSelectInputRequest(EventMask), cookie)
|
||||
return XevieSelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XevieSelectInput
|
||||
// size: 32
|
||||
type XevieSelectInputReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XevieSelectInput
|
||||
func (cook XevieSelectInputCookie) Reply() (*XevieSelectInputReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xevieSelectInputReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XevieSelectInput
|
||||
func xevieSelectInputReply(buf []byte) *XevieSelectInputReply {
|
||||
v := new(XevieSelectInputReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XevieSelectInputCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XevieSelectInput
|
||||
func (c *Conn) xevieSelectInputRequest(EventMask uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], EventMask)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2173
nexgb/auto_xfixes.go
2173
nexgb/auto_xfixes.go
File diff suppressed because it is too large
Load Diff
@ -1,655 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by xinerama.xml on May 10 2012 12:39:34pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
|
||||
// XineramaInit must be called before using the XINERAMA extension.
|
||||
func (c *Conn) XineramaInit() error {
|
||||
reply, err := c.QueryExtension(8, "XINERAMA").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named XINERAMA could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["XINERAMA"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["XINERAMA"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["XINERAMA"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["XINERAMA"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["XINERAMA"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// 'XineramaScreenInfo' struct definition
|
||||
// Size: 8
|
||||
type XineramaScreenInfo struct {
|
||||
XOrg int16
|
||||
YOrg int16
|
||||
Width uint16
|
||||
Height uint16
|
||||
}
|
||||
|
||||
// Struct read XineramaScreenInfo
|
||||
func ReadXineramaScreenInfo(buf []byte, v *XineramaScreenInfo) int {
|
||||
b := 0
|
||||
|
||||
v.XOrg = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.YOrg = int16(Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.Width = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Height = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read XineramaScreenInfo
|
||||
func ReadXineramaScreenInfoList(buf []byte, dest []XineramaScreenInfo) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = XineramaScreenInfo{}
|
||||
b += ReadXineramaScreenInfo(buf[b:], &dest[i])
|
||||
}
|
||||
return pad(b)
|
||||
}
|
||||
|
||||
// Struct write XineramaScreenInfo
|
||||
func (v XineramaScreenInfo) Bytes() []byte {
|
||||
buf := make([]byte, 8)
|
||||
b := 0
|
||||
|
||||
Put16(buf[b:], uint16(v.XOrg))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(v.YOrg))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.Width)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.Height)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list XineramaScreenInfo
|
||||
func XineramaScreenInfoListBytes(buf []byte, list []XineramaScreenInfo) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request XineramaQueryVersion
|
||||
// size: 8
|
||||
type XineramaQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaQueryVersion(Major byte, Minor byte) XineramaQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xineramaQueryVersionRequest(Major, Minor), cookie)
|
||||
return XineramaQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaQueryVersionUnchecked(Major byte, Minor byte) XineramaQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xineramaQueryVersionRequest(Major, Minor), cookie)
|
||||
return XineramaQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XineramaQueryVersion
|
||||
// size: 12
|
||||
type XineramaQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Major uint16
|
||||
Minor uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XineramaQueryVersion
|
||||
func (cook XineramaQueryVersionCookie) Reply() (*XineramaQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xineramaQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XineramaQueryVersion
|
||||
func xineramaQueryVersionReply(buf []byte) *XineramaQueryVersionReply {
|
||||
v := new(XineramaQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Major = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Minor = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XineramaQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XineramaQueryVersion
|
||||
func (c *Conn) xineramaQueryVersionRequest(Major byte, Minor byte) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = Major
|
||||
b += 1
|
||||
|
||||
buf[b] = Minor
|
||||
b += 1
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XineramaGetState
|
||||
// size: 8
|
||||
type XineramaGetStateCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaGetState(Window Window) XineramaGetStateCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xineramaGetStateRequest(Window), cookie)
|
||||
return XineramaGetStateCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaGetStateUnchecked(Window Window) XineramaGetStateCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xineramaGetStateRequest(Window), cookie)
|
||||
return XineramaGetStateCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XineramaGetState
|
||||
// size: 12
|
||||
type XineramaGetStateReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
State byte
|
||||
Window Window
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XineramaGetState
|
||||
func (cook XineramaGetStateCookie) Reply() (*XineramaGetStateReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xineramaGetStateReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XineramaGetState
|
||||
func xineramaGetStateReply(buf []byte) *XineramaGetStateReply {
|
||||
v := new(XineramaGetStateReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.State = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Window = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XineramaGetStateCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XineramaGetState
|
||||
func (c *Conn) xineramaGetStateRequest(Window Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XineramaGetScreenCount
|
||||
// size: 8
|
||||
type XineramaGetScreenCountCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaGetScreenCount(Window Window) XineramaGetScreenCountCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xineramaGetScreenCountRequest(Window), cookie)
|
||||
return XineramaGetScreenCountCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaGetScreenCountUnchecked(Window Window) XineramaGetScreenCountCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xineramaGetScreenCountRequest(Window), cookie)
|
||||
return XineramaGetScreenCountCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XineramaGetScreenCount
|
||||
// size: 12
|
||||
type XineramaGetScreenCountReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
ScreenCount byte
|
||||
Window Window
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XineramaGetScreenCount
|
||||
func (cook XineramaGetScreenCountCookie) Reply() (*XineramaGetScreenCountReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xineramaGetScreenCountReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XineramaGetScreenCount
|
||||
func xineramaGetScreenCountReply(buf []byte) *XineramaGetScreenCountReply {
|
||||
v := new(XineramaGetScreenCountReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.ScreenCount = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Window = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XineramaGetScreenCountCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XineramaGetScreenCount
|
||||
func (c *Conn) xineramaGetScreenCountRequest(Window Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XineramaGetScreenSize
|
||||
// size: 12
|
||||
type XineramaGetScreenSizeCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaGetScreenSize(Window Window, Screen uint32) XineramaGetScreenSizeCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xineramaGetScreenSizeRequest(Window, Screen), cookie)
|
||||
return XineramaGetScreenSizeCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaGetScreenSizeUnchecked(Window Window, Screen uint32) XineramaGetScreenSizeCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xineramaGetScreenSizeRequest(Window, Screen), cookie)
|
||||
return XineramaGetScreenSizeCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XineramaGetScreenSize
|
||||
// size: 24
|
||||
type XineramaGetScreenSizeReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Width uint32
|
||||
Height uint32
|
||||
Window Window
|
||||
Screen uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XineramaGetScreenSize
|
||||
func (cook XineramaGetScreenSizeCookie) Reply() (*XineramaGetScreenSizeReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xineramaGetScreenSizeReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XineramaGetScreenSize
|
||||
func xineramaGetScreenSizeReply(buf []byte) *XineramaGetScreenSizeReply {
|
||||
v := new(XineramaGetScreenSizeReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Width = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Height = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Window = Window(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Screen = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XineramaGetScreenSizeCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XineramaGetScreenSize
|
||||
func (c *Conn) xineramaGetScreenSizeRequest(Window Window, Screen uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], Screen)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XineramaIsActive
|
||||
// size: 4
|
||||
type XineramaIsActiveCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaIsActive() XineramaIsActiveCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xineramaIsActiveRequest(), cookie)
|
||||
return XineramaIsActiveCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaIsActiveUnchecked() XineramaIsActiveCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xineramaIsActiveRequest(), cookie)
|
||||
return XineramaIsActiveCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XineramaIsActive
|
||||
// size: 12
|
||||
type XineramaIsActiveReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
State uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XineramaIsActive
|
||||
func (cook XineramaIsActiveCookie) Reply() (*XineramaIsActiveReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xineramaIsActiveReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XineramaIsActive
|
||||
func xineramaIsActiveReply(buf []byte) *XineramaIsActiveReply {
|
||||
v := new(XineramaIsActiveReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.State = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XineramaIsActiveCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XineramaIsActive
|
||||
func (c *Conn) xineramaIsActiveRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XineramaQueryScreens
|
||||
// size: 4
|
||||
type XineramaQueryScreensCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaQueryScreens() XineramaQueryScreensCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xineramaQueryScreensRequest(), cookie)
|
||||
return XineramaQueryScreensCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XineramaQueryScreensUnchecked() XineramaQueryScreensCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xineramaQueryScreensRequest(), cookie)
|
||||
return XineramaQueryScreensCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XineramaQueryScreens
|
||||
// size: (32 + pad((int(Number) * 8)))
|
||||
type XineramaQueryScreensReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Number uint32
|
||||
// padding: 20 bytes
|
||||
ScreenInfo []XineramaScreenInfo // size: pad((int(Number) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XineramaQueryScreens
|
||||
func (cook XineramaQueryScreensCookie) Reply() (*XineramaQueryScreensReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xineramaQueryScreensReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XineramaQueryScreens
|
||||
func xineramaQueryScreensReply(buf []byte) *XineramaQueryScreensReply {
|
||||
v := new(XineramaQueryScreensReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Number = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.ScreenInfo = make([]XineramaScreenInfo, v.Number)
|
||||
b += ReadXineramaScreenInfoList(buf[b:], v.ScreenInfo)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XineramaQueryScreensCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XineramaQueryScreens
|
||||
func (c *Conn) xineramaQueryScreensRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
7297
nexgb/auto_xinput.go
7297
nexgb/auto_xinput.go
File diff suppressed because it is too large
Load Diff
2210
nexgb/auto_xprint.go
2210
nexgb/auto_xprint.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,361 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by xtest.xml on May 10 2012 12:39:34pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xproto"
|
||||
|
||||
// XtestInit must be called before using the XTEST extension.
|
||||
func (c *Conn) XtestInit() error {
|
||||
reply, err := c.QueryExtension(5, "XTEST").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named XTEST could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["XTEST"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["XTEST"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["XTEST"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["XTEST"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["XTEST"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
const (
|
||||
XtestCursorNone = 0
|
||||
XtestCursorCurrent = 1
|
||||
)
|
||||
|
||||
// Request XtestGetVersion
|
||||
// size: 8
|
||||
type XtestGetVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XtestGetVersion(MajorVersion byte, MinorVersion uint16) XtestGetVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xtestGetVersionRequest(MajorVersion, MinorVersion), cookie)
|
||||
return XtestGetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XtestGetVersionUnchecked(MajorVersion byte, MinorVersion uint16) XtestGetVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xtestGetVersionRequest(MajorVersion, MinorVersion), cookie)
|
||||
return XtestGetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XtestGetVersion
|
||||
// size: 10
|
||||
type XtestGetVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
MajorVersion byte
|
||||
MinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XtestGetVersion
|
||||
func (cook XtestGetVersionCookie) Reply() (*XtestGetVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xtestGetVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XtestGetVersion
|
||||
func xtestGetVersionReply(buf []byte) *XtestGetVersionReply {
|
||||
v := new(XtestGetVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.MajorVersion = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MinorVersion = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XtestGetVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XtestGetVersion
|
||||
func (c *Conn) xtestGetVersionRequest(MajorVersion byte, MinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = MajorVersion
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
Put16(buf[b:], MinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XtestCompareCursor
|
||||
// size: 12
|
||||
type XtestCompareCursorCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XtestCompareCursor(Window Window, Cursor Cursor) XtestCompareCursorCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xtestCompareCursorRequest(Window, Cursor), cookie)
|
||||
return XtestCompareCursorCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XtestCompareCursorUnchecked(Window Window, Cursor Cursor) XtestCompareCursorCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xtestCompareCursorRequest(Window, Cursor), cookie)
|
||||
return XtestCompareCursorCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XtestCompareCursor
|
||||
// size: 8
|
||||
type XtestCompareCursorReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Same bool
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XtestCompareCursor
|
||||
func (cook XtestCompareCursorCookie) Reply() (*XtestCompareCursorReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xtestCompareCursorReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XtestCompareCursor
|
||||
func xtestCompareCursorReply(buf []byte) *XtestCompareCursorReply {
|
||||
v := new(XtestCompareCursorReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Same = true
|
||||
} else {
|
||||
v.Same = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XtestCompareCursorCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XtestCompareCursor
|
||||
func (c *Conn) xtestCompareCursorRequest(Window Window, Cursor Cursor) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Cursor))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XtestFakeInput
|
||||
// size: 36
|
||||
type XtestFakeInputCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for XtestFakeInput
|
||||
func (c *Conn) XtestFakeInput(Type byte, Detail byte, Time uint32, Root Window, RootX int16, RootY int16, Deviceid byte) XtestFakeInputCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.xtestFakeInputRequest(Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie)
|
||||
return XtestFakeInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XtestFakeInputChecked(Type byte, Detail byte, Time uint32, Root Window, RootX int16, RootY int16, Deviceid byte) XtestFakeInputCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.xtestFakeInputRequest(Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie)
|
||||
return XtestFakeInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook XtestFakeInputCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XtestFakeInput
|
||||
func (c *Conn) xtestFakeInputRequest(Type byte, Detail byte, Time uint32, Root Window, RootX int16, RootY int16, Deviceid byte) []byte {
|
||||
size := 36
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = Type
|
||||
b += 1
|
||||
|
||||
buf[b] = Detail
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
Put32(buf[b:], Time)
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Root))
|
||||
b += 4
|
||||
|
||||
b += 8 // padding
|
||||
|
||||
Put16(buf[b:], uint16(RootX))
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], uint16(RootY))
|
||||
b += 2
|
||||
|
||||
b += 7 // padding
|
||||
|
||||
buf[b] = Deviceid
|
||||
b += 1
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XtestGrabControl
|
||||
// size: 8
|
||||
type XtestGrabControlCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for XtestGrabControl
|
||||
func (c *Conn) XtestGrabControl(Impervious bool) XtestGrabControlCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.xtestGrabControlRequest(Impervious), cookie)
|
||||
return XtestGrabControlCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XtestGrabControlChecked(Impervious bool) XtestGrabControlCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.xtestGrabControlRequest(Impervious), cookie)
|
||||
return XtestGrabControlCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook XtestGrabControlCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XtestGrabControl
|
||||
func (c *Conn) xtestGrabControlRequest(Impervious bool) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
if Impervious {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
2780
nexgb/auto_xv.go
2780
nexgb/auto_xv.go
File diff suppressed because it is too large
Load Diff
@ -1,929 +0,0 @@
|
||||
package xgb
|
||||
|
||||
/*
|
||||
This file was generated by xvmc.xml on May 10 2012 12:39:35pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
// Imports are not necessary for XGB because everything is
|
||||
// in one package. They are still listed here for reference.
|
||||
// import "xv"
|
||||
|
||||
// XvmcInit must be called before using the XVideo-MotionCompensation extension.
|
||||
func (c *Conn) XvmcInit() error {
|
||||
reply, err := c.QueryExtension(25, "XVideo-MotionCompensation").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return errorf("No extension named XVideo-MotionCompensation could be found on on the server.")
|
||||
}
|
||||
|
||||
c.extLock.Lock()
|
||||
c.extensions["XVideo-MotionCompensation"] = reply.MajorOpcode
|
||||
for evNum, fun := range newExtEventFuncs["XVideo-MotionCompensation"] {
|
||||
newEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range newExtErrorFuncs["XVideo-MotionCompensation"] {
|
||||
newErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
c.extLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
newExtEventFuncs["XVideo-MotionCompensation"] = make(map[int]newEventFun)
|
||||
newExtErrorFuncs["XVideo-MotionCompensation"] = make(map[int]newErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
type XvmcContext uint32
|
||||
|
||||
func (c *Conn) NewXvmcContextId() (XvmcContext, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return XvmcContext(id), nil
|
||||
}
|
||||
|
||||
type XvmcSurface uint32
|
||||
|
||||
func (c *Conn) NewXvmcSurfaceId() (XvmcSurface, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return XvmcSurface(id), nil
|
||||
}
|
||||
|
||||
type XvmcSubpicture uint32
|
||||
|
||||
func (c *Conn) NewXvmcSubpictureId() (XvmcSubpicture, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return XvmcSubpicture(id), nil
|
||||
}
|
||||
|
||||
// 'XvmcSurfaceInfo' struct definition
|
||||
// Size: 24
|
||||
type XvmcSurfaceInfo struct {
|
||||
Id XvmcSurface
|
||||
ChromaFormat uint16
|
||||
Pad0 uint16
|
||||
MaxWidth uint16
|
||||
MaxHeight uint16
|
||||
SubpictureMaxWidth uint16
|
||||
SubpictureMaxHeight uint16
|
||||
McType uint32
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
// Struct read XvmcSurfaceInfo
|
||||
func ReadXvmcSurfaceInfo(buf []byte, v *XvmcSurfaceInfo) int {
|
||||
b := 0
|
||||
|
||||
v.Id = XvmcSurface(Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.ChromaFormat = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Pad0 = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MaxWidth = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MaxHeight = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.SubpictureMaxWidth = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.SubpictureMaxHeight = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.McType = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Flags = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read XvmcSurfaceInfo
|
||||
func ReadXvmcSurfaceInfoList(buf []byte, dest []XvmcSurfaceInfo) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = XvmcSurfaceInfo{}
|
||||
b += ReadXvmcSurfaceInfo(buf[b:], &dest[i])
|
||||
}
|
||||
return pad(b)
|
||||
}
|
||||
|
||||
// Struct write XvmcSurfaceInfo
|
||||
func (v XvmcSurfaceInfo) Bytes() []byte {
|
||||
buf := make([]byte, 24)
|
||||
b := 0
|
||||
|
||||
Put32(buf[b:], uint32(v.Id))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], v.ChromaFormat)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.Pad0)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.MaxWidth)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.MaxHeight)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.SubpictureMaxWidth)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], v.SubpictureMaxHeight)
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], v.McType)
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], v.Flags)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list XvmcSurfaceInfo
|
||||
func XvmcSurfaceInfoListBytes(buf []byte, list []XvmcSurfaceInfo) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request XvmcQueryVersion
|
||||
// size: 4
|
||||
type XvmcQueryVersionCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcQueryVersion() XvmcQueryVersionCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xvmcQueryVersionRequest(), cookie)
|
||||
return XvmcQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcQueryVersionUnchecked() XvmcQueryVersionCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xvmcQueryVersionRequest(), cookie)
|
||||
return XvmcQueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XvmcQueryVersion
|
||||
// size: 16
|
||||
type XvmcQueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Major uint32
|
||||
Minor uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XvmcQueryVersion
|
||||
func (cook XvmcQueryVersionCookie) Reply() (*XvmcQueryVersionReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xvmcQueryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XvmcQueryVersion
|
||||
func xvmcQueryVersionReply(buf []byte) *XvmcQueryVersionReply {
|
||||
v := new(XvmcQueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Major = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Minor = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XvmcQueryVersionCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcQueryVersion
|
||||
func (c *Conn) xvmcQueryVersionRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcListSurfaceTypes
|
||||
// size: 8
|
||||
type XvmcListSurfaceTypesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcListSurfaceTypes(PortId XvPort) XvmcListSurfaceTypesCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xvmcListSurfaceTypesRequest(PortId), cookie)
|
||||
return XvmcListSurfaceTypesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcListSurfaceTypesUnchecked(PortId XvPort) XvmcListSurfaceTypesCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xvmcListSurfaceTypesRequest(PortId), cookie)
|
||||
return XvmcListSurfaceTypesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XvmcListSurfaceTypes
|
||||
// size: (32 + pad((int(Num) * 24)))
|
||||
type XvmcListSurfaceTypesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Num uint32
|
||||
// padding: 20 bytes
|
||||
Surfaces []XvmcSurfaceInfo // size: pad((int(Num) * 24))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XvmcListSurfaceTypes
|
||||
func (cook XvmcListSurfaceTypesCookie) Reply() (*XvmcListSurfaceTypesReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xvmcListSurfaceTypesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XvmcListSurfaceTypes
|
||||
func xvmcListSurfaceTypesReply(buf []byte) *XvmcListSurfaceTypesReply {
|
||||
v := new(XvmcListSurfaceTypesReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Num = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Surfaces = make([]XvmcSurfaceInfo, v.Num)
|
||||
b += ReadXvmcSurfaceInfoList(buf[b:], v.Surfaces)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XvmcListSurfaceTypesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcListSurfaceTypes
|
||||
func (c *Conn) xvmcListSurfaceTypesRequest(PortId XvPort) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(PortId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcCreateContext
|
||||
// size: 24
|
||||
type XvmcCreateContextCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcCreateContext(ContextId XvmcContext, PortId XvPort, SurfaceId XvmcSurface, Width uint16, Height uint16, Flags uint32) XvmcCreateContextCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xvmcCreateContextRequest(ContextId, PortId, SurfaceId, Width, Height, Flags), cookie)
|
||||
return XvmcCreateContextCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcCreateContextUnchecked(ContextId XvmcContext, PortId XvPort, SurfaceId XvmcSurface, Width uint16, Height uint16, Flags uint32) XvmcCreateContextCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xvmcCreateContextRequest(ContextId, PortId, SurfaceId, Width, Height, Flags), cookie)
|
||||
return XvmcCreateContextCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XvmcCreateContext
|
||||
// size: (36 + pad((int(Length) * 4)))
|
||||
type XvmcCreateContextReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
WidthActual uint16
|
||||
HeightActual uint16
|
||||
FlagsReturn uint32
|
||||
// padding: 20 bytes
|
||||
PrivData []uint32 // size: pad((int(Length) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XvmcCreateContext
|
||||
func (cook XvmcCreateContextCookie) Reply() (*XvmcCreateContextReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xvmcCreateContextReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XvmcCreateContext
|
||||
func xvmcCreateContextReply(buf []byte) *XvmcCreateContextReply {
|
||||
v := new(XvmcCreateContextReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.WidthActual = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.HeightActual = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.FlagsReturn = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.PrivData = make([]uint32, v.Length)
|
||||
for i := 0; i < int(v.Length); i++ {
|
||||
v.PrivData[i] = Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XvmcCreateContextCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcCreateContext
|
||||
func (c *Conn) xvmcCreateContextRequest(ContextId XvmcContext, PortId XvPort, SurfaceId XvmcSurface, Width uint16, Height uint16, Flags uint32) []byte {
|
||||
size := 24
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(ContextId))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(PortId))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], Flags)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcDestroyContext
|
||||
// size: 8
|
||||
type XvmcDestroyContextCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcDestroyContext
|
||||
func (c *Conn) XvmcDestroyContext(ContextId XvmcContext) XvmcDestroyContextCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.xvmcDestroyContextRequest(ContextId), cookie)
|
||||
return XvmcDestroyContextCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcDestroyContextChecked(ContextId XvmcContext) XvmcDestroyContextCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.xvmcDestroyContextRequest(ContextId), cookie)
|
||||
return XvmcDestroyContextCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook XvmcDestroyContextCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcDestroyContext
|
||||
func (c *Conn) xvmcDestroyContextRequest(ContextId XvmcContext) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(ContextId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcCreateSurface
|
||||
// size: 12
|
||||
type XvmcCreateSurfaceCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcCreateSurface(SurfaceId XvmcSurface, ContextId XvmcContext) XvmcCreateSurfaceCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xvmcCreateSurfaceRequest(SurfaceId, ContextId), cookie)
|
||||
return XvmcCreateSurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcCreateSurfaceUnchecked(SurfaceId XvmcSurface, ContextId XvmcContext) XvmcCreateSurfaceCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xvmcCreateSurfaceRequest(SurfaceId, ContextId), cookie)
|
||||
return XvmcCreateSurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XvmcCreateSurface
|
||||
// size: (32 + pad((int(Length) * 4)))
|
||||
type XvmcCreateSurfaceReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
PrivData []uint32 // size: pad((int(Length) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XvmcCreateSurface
|
||||
func (cook XvmcCreateSurfaceCookie) Reply() (*XvmcCreateSurfaceReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xvmcCreateSurfaceReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XvmcCreateSurface
|
||||
func xvmcCreateSurfaceReply(buf []byte) *XvmcCreateSurfaceReply {
|
||||
v := new(XvmcCreateSurfaceReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
v.PrivData = make([]uint32, v.Length)
|
||||
for i := 0; i < int(v.Length); i++ {
|
||||
v.PrivData[i] = Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XvmcCreateSurfaceCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcCreateSurface
|
||||
func (c *Conn) xvmcCreateSurfaceRequest(SurfaceId XvmcSurface, ContextId XvmcContext) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(ContextId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcDestroySurface
|
||||
// size: 8
|
||||
type XvmcDestroySurfaceCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcDestroySurface
|
||||
func (c *Conn) XvmcDestroySurface(SurfaceId XvmcSurface) XvmcDestroySurfaceCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.xvmcDestroySurfaceRequest(SurfaceId), cookie)
|
||||
return XvmcDestroySurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcDestroySurfaceChecked(SurfaceId XvmcSurface) XvmcDestroySurfaceCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.xvmcDestroySurfaceRequest(SurfaceId), cookie)
|
||||
return XvmcDestroySurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook XvmcDestroySurfaceCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcDestroySurface
|
||||
func (c *Conn) xvmcDestroySurfaceRequest(SurfaceId XvmcSurface) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcCreateSubpicture
|
||||
// size: 20
|
||||
type XvmcCreateSubpictureCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcCreateSubpicture(SubpictureId XvmcSubpicture, Context XvmcContext, XvimageId uint32, Width uint16, Height uint16) XvmcCreateSubpictureCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xvmcCreateSubpictureRequest(SubpictureId, Context, XvimageId, Width, Height), cookie)
|
||||
return XvmcCreateSubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcCreateSubpictureUnchecked(SubpictureId XvmcSubpicture, Context XvmcContext, XvimageId uint32, Width uint16, Height uint16) XvmcCreateSubpictureCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xvmcCreateSubpictureRequest(SubpictureId, Context, XvimageId, Width, Height), cookie)
|
||||
return XvmcCreateSubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XvmcCreateSubpicture
|
||||
// size: (32 + pad((int(Length) * 4)))
|
||||
type XvmcCreateSubpictureReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
WidthActual uint16
|
||||
HeightActual uint16
|
||||
NumPaletteEntries uint16
|
||||
EntryBytes uint16
|
||||
ComponentOrder []byte // size: 4
|
||||
// padding: 12 bytes
|
||||
PrivData []uint32 // size: pad((int(Length) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XvmcCreateSubpicture
|
||||
func (cook XvmcCreateSubpictureCookie) Reply() (*XvmcCreateSubpictureReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xvmcCreateSubpictureReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XvmcCreateSubpicture
|
||||
func xvmcCreateSubpictureReply(buf []byte) *XvmcCreateSubpictureReply {
|
||||
v := new(XvmcCreateSubpictureReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.WidthActual = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.HeightActual = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.NumPaletteEntries = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.EntryBytes = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ComponentOrder = make([]byte, 4)
|
||||
copy(v.ComponentOrder[:4], buf[b:])
|
||||
b += pad(int(4))
|
||||
|
||||
b += 12 // padding
|
||||
|
||||
v.PrivData = make([]uint32, v.Length)
|
||||
for i := 0; i < int(v.Length); i++ {
|
||||
v.PrivData[i] = Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XvmcCreateSubpictureCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcCreateSubpicture
|
||||
func (c *Conn) xvmcCreateSubpictureRequest(SubpictureId XvmcSubpicture, Context XvmcContext, XvimageId uint32, Width uint16, Height uint16) []byte {
|
||||
size := 20
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(SubpictureId))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(Context))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], XvimageId)
|
||||
b += 4
|
||||
|
||||
Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcDestroySubpicture
|
||||
// size: 8
|
||||
type XvmcDestroySubpictureCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcDestroySubpicture
|
||||
func (c *Conn) XvmcDestroySubpicture(SubpictureId XvmcSubpicture) XvmcDestroySubpictureCookie {
|
||||
cookie := c.newCookie(false, false)
|
||||
c.newRequest(c.xvmcDestroySubpictureRequest(SubpictureId), cookie)
|
||||
return XvmcDestroySubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcDestroySubpictureChecked(SubpictureId XvmcSubpicture) XvmcDestroySubpictureCookie {
|
||||
cookie := c.newCookie(true, false)
|
||||
c.newRequest(c.xvmcDestroySubpictureRequest(SubpictureId), cookie)
|
||||
return XvmcDestroySubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook XvmcDestroySubpictureCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcDestroySubpicture
|
||||
func (c *Conn) xvmcDestroySubpictureRequest(SubpictureId XvmcSubpicture) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(SubpictureId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request XvmcListSubpictureTypes
|
||||
// size: 12
|
||||
type XvmcListSubpictureTypesCookie struct {
|
||||
*cookie
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcListSubpictureTypes(PortId XvPort, SurfaceId XvmcSurface) XvmcListSubpictureTypesCookie {
|
||||
cookie := c.newCookie(true, true)
|
||||
c.newRequest(c.xvmcListSubpictureTypesRequest(PortId, SurfaceId), cookie)
|
||||
return XvmcListSubpictureTypesCookie{cookie}
|
||||
}
|
||||
|
||||
func (c *Conn) XvmcListSubpictureTypesUnchecked(PortId XvPort, SurfaceId XvmcSurface) XvmcListSubpictureTypesCookie {
|
||||
cookie := c.newCookie(false, true)
|
||||
c.newRequest(c.xvmcListSubpictureTypesRequest(PortId, SurfaceId), cookie)
|
||||
return XvmcListSubpictureTypesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for XvmcListSubpictureTypes
|
||||
// size: (32 + XvImageFormatInfoListSize(Types))
|
||||
type XvmcListSubpictureTypesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Num uint32
|
||||
// padding: 20 bytes
|
||||
Types []XvImageFormatInfo // size: XvImageFormatInfoListSize(Types)
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request XvmcListSubpictureTypes
|
||||
func (cook XvmcListSubpictureTypesCookie) Reply() (*XvmcListSubpictureTypesReply, error) {
|
||||
buf, err := cook.reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return xvmcListSubpictureTypesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for XvmcListSubpictureTypes
|
||||
func xvmcListSubpictureTypesReply(buf []byte) *XvmcListSubpictureTypesReply {
|
||||
v := new(XvmcListSubpictureTypesReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Num = Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Types = make([]XvImageFormatInfo, v.Num)
|
||||
b += ReadXvImageFormatInfoList(buf[b:], v.Types)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (cook XvmcListSubpictureTypesCookie) Check() error {
|
||||
return cook.check()
|
||||
}
|
||||
|
||||
// Write request to wire for XvmcListSubpictureTypes
|
||||
func (c *Conn) xvmcListSubpictureTypesRequest(PortId XvPort, SurfaceId XvmcSurface) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 8 // request opcode
|
||||
b += 1
|
||||
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
Put32(buf[b:], uint32(PortId))
|
||||
b += 4
|
||||
|
||||
Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
140
nexgb/bigreq/bigreq.go
Normal file
140
nexgb/bigreq/bigreq.go
Normal file
@ -0,0 +1,140 @@
|
||||
package bigreq
|
||||
|
||||
/*
|
||||
This file was generated by bigreq.xml on May 10 2012 4:20:27pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the BIG-REQUESTS extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 12, "BIG-REQUESTS").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named BIG-REQUESTS could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["BIG-REQUESTS"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["BIG-REQUESTS"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["BIG-REQUESTS"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["BIG-REQUESTS"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["BIG-REQUESTS"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Request Enable
|
||||
// size: 4
|
||||
type EnableCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func Enable(c *xgb.Conn) EnableCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(enableRequest(c), cookie)
|
||||
return EnableCookie{cookie}
|
||||
}
|
||||
|
||||
func EnableUnchecked(c *xgb.Conn) EnableCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(enableRequest(c), cookie)
|
||||
return EnableCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Enable
|
||||
// size: 12
|
||||
type EnableReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MaximumRequestLength uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Enable
|
||||
func (cook EnableCookie) Reply() (*EnableReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return enableReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Enable
|
||||
func enableReply(buf []byte) *EnableReply {
|
||||
v := new(EnableReply)
|
||||
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.MaximumRequestLength = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for Enable
|
||||
func enableRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["BIG-REQUESTS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
575
nexgb/composite/composite.go
Normal file
575
nexgb/composite/composite.go
Normal file
@ -0,0 +1,575 @@
|
||||
package composite
|
||||
|
||||
/*
|
||||
This file was generated by composite.xml on May 10 2012 4:20:27pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xfixes"
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the Composite extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 9, "Composite").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named Composite could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["Composite"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["Composite"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["Composite"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["Composite"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["Composite"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
const (
|
||||
RedirectAutomatic = 0
|
||||
RedirectManual = 1
|
||||
)
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 12
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 32
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint32
|
||||
MinorVersion uint32
|
||||
// padding: 16 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.MinorVersion = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 16 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], ClientMajorVersion)
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], ClientMinorVersion)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request RedirectWindow
|
||||
// size: 12
|
||||
type RedirectWindowCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for RedirectWindow
|
||||
func RedirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(redirectWindowRequest(c, Window, Update), cookie)
|
||||
return RedirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func RedirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(redirectWindowRequest(c, Window, Update), cookie)
|
||||
return RedirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook RedirectWindowCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for RedirectWindow
|
||||
func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request RedirectSubwindows
|
||||
// size: 12
|
||||
type RedirectSubwindowsCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for RedirectSubwindows
|
||||
func RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie)
|
||||
return RedirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func RedirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie)
|
||||
return RedirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook RedirectSubwindowsCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for RedirectSubwindows
|
||||
func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request UnredirectWindow
|
||||
// size: 12
|
||||
type UnredirectWindowCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for UnredirectWindow
|
||||
func UnredirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie)
|
||||
return UnredirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func UnredirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie)
|
||||
return UnredirectWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook UnredirectWindowCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for UnredirectWindow
|
||||
func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request UnredirectSubwindows
|
||||
// size: 12
|
||||
type UnredirectSubwindowsCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for UnredirectSubwindows
|
||||
func UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie)
|
||||
return UnredirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func UnredirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie)
|
||||
return UnredirectSubwindowsCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook UnredirectSubwindowsCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for UnredirectSubwindows
|
||||
func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = Update
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CreateRegionFromBorderClip
|
||||
// size: 12
|
||||
type CreateRegionFromBorderClipCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CreateRegionFromBorderClip
|
||||
func CreateRegionFromBorderClip(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie)
|
||||
return CreateRegionFromBorderClipCookie{cookie}
|
||||
}
|
||||
|
||||
func CreateRegionFromBorderClipChecked(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie)
|
||||
return CreateRegionFromBorderClipCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CreateRegionFromBorderClipCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for CreateRegionFromBorderClip
|
||||
func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Region))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request NameWindowPixmap
|
||||
// size: 12
|
||||
type NameWindowPixmapCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for NameWindowPixmap
|
||||
func NameWindowPixmap(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie)
|
||||
return NameWindowPixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func NameWindowPixmapChecked(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie)
|
||||
return NameWindowPixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook NameWindowPixmapCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for NameWindowPixmap
|
||||
func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Pixmap))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetOverlayWindow
|
||||
// size: 8
|
||||
type GetOverlayWindowCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getOverlayWindowRequest(c, Window), cookie)
|
||||
return GetOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getOverlayWindowRequest(c, Window), cookie)
|
||||
return GetOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetOverlayWindow
|
||||
// size: 32
|
||||
type GetOverlayWindowReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
OverlayWin xproto.Window
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetOverlayWindow
|
||||
func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getOverlayWindowReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetOverlayWindow
|
||||
func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply {
|
||||
v := new(GetOverlayWindowReply)
|
||||
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.OverlayWin = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetOverlayWindow
|
||||
func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ReleaseOverlayWindow
|
||||
// size: 8
|
||||
type ReleaseOverlayWindowCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ReleaseOverlayWindow
|
||||
func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie)
|
||||
return ReleaseOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func ReleaseOverlayWindowChecked(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie)
|
||||
return ReleaseOverlayWindowCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ReleaseOverlayWindowCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for ReleaseOverlayWindow
|
||||
func releaseOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["COMPOSITE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 8 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
@ -38,7 +38,7 @@ func (c *Conn) connect(display string) error {
|
||||
return errors.New("unsupported auth protocol " + authName)
|
||||
}
|
||||
|
||||
buf := make([]byte, 12+pad(len(authName))+pad(len(authData)))
|
||||
buf := make([]byte, 12+Pad(len(authName))+Pad(len(authData)))
|
||||
buf[0] = 0x6c
|
||||
buf[1] = 0
|
||||
Put16(buf[2:], 11)
|
||||
@ -47,7 +47,7 @@ func (c *Conn) connect(display string) error {
|
||||
Put16(buf[8:], uint16(len(authData)))
|
||||
Put16(buf[10:], 0)
|
||||
copy(buf[12:], []byte(authName))
|
||||
copy(buf[12+pad(len(authName)):], authData)
|
||||
copy(buf[12+Pad(len(authName)):], authData)
|
||||
if _, err = c.conn.Write(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -78,11 +78,14 @@ func (c *Conn) connect(display string) error {
|
||||
string(reason))
|
||||
}
|
||||
|
||||
ReadSetupInfo(buf, &c.Setup)
|
||||
// Unfortunately, it isn't really feasible to read the setup bytes here,
|
||||
// since the code to do so is in a different package.
|
||||
// Users must call 'xproto.Setup(X)' to get the setup info.
|
||||
c.SetupBytes = buf
|
||||
|
||||
if c.defaultScreen >= len(c.Setup.Roots) {
|
||||
c.defaultScreen = 0
|
||||
}
|
||||
// But also read stuff that we *need* to get started.
|
||||
c.setupResourceIdBase = Get32(buf[12:])
|
||||
c.setupResourceIdMask = Get32(buf[16:])
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -137,7 +140,7 @@ func (c *Conn) dial(display string) error {
|
||||
}
|
||||
|
||||
if len(scr) != 0 {
|
||||
c.defaultScreen, err = strconv.Atoi(scr)
|
||||
c.DefaultScreen, err = strconv.Atoi(scr)
|
||||
if err != nil {
|
||||
return errors.New("bad display string: " + display0)
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// cookie is the internal representation of a cookie, where one is generated
|
||||
// Cookie is the internal representation of a cookie, where one is generated
|
||||
// for *every* request sent by XGB.
|
||||
// 'cookie' is most frequently used by embedding it into a more specific
|
||||
// kind of cookie, i.e., 'GetInputFocusCookie'.
|
||||
type cookie struct {
|
||||
type Cookie struct {
|
||||
conn *Conn
|
||||
Sequence uint16
|
||||
replyChan chan []byte
|
||||
@ -22,8 +22,10 @@ type cookie struct {
|
||||
// function for more info on those.)
|
||||
// Note that a sequence number is not set until just before the request
|
||||
// corresponding to this cookie is sent over the wire.
|
||||
func (c *Conn) newCookie(checked, reply bool) *cookie {
|
||||
cookie := &cookie{
|
||||
// This function should not be used. It is exported for use in the extension
|
||||
// sub-packages.
|
||||
func (c *Conn) NewCookie(checked, reply bool) *Cookie {
|
||||
cookie := &Cookie{
|
||||
conn: c,
|
||||
Sequence: 0, // we add the sequence id just before sending a request
|
||||
replyChan: nil,
|
||||
@ -60,21 +62,23 @@ func (c *Conn) newCookie(checked, reply bool) *cookie {
|
||||
return cookie
|
||||
}
|
||||
|
||||
// reply detects whether this is a checked or unchecked cookie, and calls
|
||||
// Reply detects whether this is a checked or unchecked cookie, and calls
|
||||
// 'replyChecked' or 'replyUnchecked' appropriately.
|
||||
func (c cookie) reply() ([]byte, error) {
|
||||
// This should not be used. It is exported for use in extension sub-packages.
|
||||
func (c Cookie) Reply() ([]byte, error) {
|
||||
// checked
|
||||
if c.errorChan != nil {
|
||||
return c.replyChecked()
|
||||
return c.ReplyChecked()
|
||||
}
|
||||
return c.replyUnchecked()
|
||||
return c.ReplyUnchecked()
|
||||
}
|
||||
|
||||
// replyChecked waits for a response on either the replyChan or errorChan
|
||||
// ReplyChecked waits for a response on either the replyChan or errorChan
|
||||
// channels. If the former arrives, the bytes are returned with a nil error.
|
||||
// If the latter arrives, no bytes are returned (nil) and the error received
|
||||
// is returned.
|
||||
func (c cookie) replyChecked() ([]byte, error) {
|
||||
// This should not be used. It is exported for use in extension sub-packages.
|
||||
func (c Cookie) ReplyChecked() ([]byte, error) {
|
||||
if c.replyChan == nil {
|
||||
return nil, errors.New("Cannot call 'replyChecked' on a cookie that " +
|
||||
"is not expecting a *reply* or an error.")
|
||||
@ -93,13 +97,14 @@ func (c cookie) replyChecked() ([]byte, error) {
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
// replyChecked waits for a response on either the replyChan or pingChan
|
||||
// ReplyChecked waits for a response on either the replyChan or pingChan
|
||||
// channels. If the former arrives, the bytes are returned with a nil error.
|
||||
// If the latter arrives, no bytes are returned (nil) and a nil error
|
||||
// is returned. (In the latter case, the corresponding error can be retrieved
|
||||
// from (Wait|Poll)ForEvent asynchronously.)
|
||||
// In all honesty, you *probably* don't want to use this method.
|
||||
func (c cookie) replyUnchecked() ([]byte, error) {
|
||||
// This should not be used. It is exported for use in extension sub-packages.
|
||||
func (c Cookie) ReplyUnchecked() ([]byte, error) {
|
||||
if c.replyChan == nil {
|
||||
return nil, errors.New("Cannot call 'replyUnchecked' on a cookie " +
|
||||
"that is not expecting a *reply*.")
|
||||
@ -114,7 +119,7 @@ func (c cookie) replyUnchecked() ([]byte, error) {
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
// check is used for checked requests that have no replies. It is a mechanism
|
||||
// Check is used for checked requests that have no replies. It is a mechanism
|
||||
// by which to report "success" or "error" in a synchronous fashion. (Therefore,
|
||||
// unchecked requests without replies cannot use this method.)
|
||||
// If the request causes an error, it is sent to this cookie's errorChan.
|
||||
@ -122,7 +127,8 @@ func (c cookie) replyUnchecked() ([]byte, error) {
|
||||
// Thus, pingChan is sent a value when the *next* reply is read.
|
||||
// If no more replies are being processed, we force a round trip request with
|
||||
// GetInputFocus.
|
||||
func (c cookie) check() error {
|
||||
// This should not be used. It is exported for use in extension sub-packages.
|
||||
func (c Cookie) Check() error {
|
||||
if c.replyChan != nil {
|
||||
return errors.New("Cannot call 'Check' on a cookie that is " +
|
||||
"expecting a *reply*. Use 'Reply' instead.")
|
||||
@ -142,7 +148,7 @@ func (c cookie) check() error {
|
||||
}
|
||||
|
||||
// Now force a round trip and try again, but block this time.
|
||||
c.conn.GetInputFocus().Reply()
|
||||
c.conn.Sync()
|
||||
select {
|
||||
case err := <-c.errorChan:
|
||||
return err
|
||||
|
511
nexgb/damage/damage.go
Normal file
511
nexgb/damage/damage.go
Normal file
@ -0,0 +1,511 @@
|
||||
package damage
|
||||
|
||||
/*
|
||||
This file was generated by damage.xml on May 10 2012 4:20:27pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xfixes"
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the DAMAGE extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 6, "DAMAGE").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named DAMAGE could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["DAMAGE"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["DAMAGE"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["DAMAGE"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["DAMAGE"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["DAMAGE"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
const (
|
||||
ReportLevelRawRectangles = 0
|
||||
ReportLevelDeltaRectangles = 1
|
||||
ReportLevelBoundingBox = 2
|
||||
ReportLevelNonEmpty = 3
|
||||
)
|
||||
|
||||
type Damage uint32
|
||||
|
||||
func NewDamageId(c *xgb.Conn) (Damage, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return Damage(id), nil
|
||||
}
|
||||
|
||||
// Event definition Notify (0)
|
||||
// Size: 32
|
||||
|
||||
const Notify = 0
|
||||
|
||||
type NotifyEvent struct {
|
||||
Sequence uint16
|
||||
Level byte
|
||||
Drawable xproto.Drawable
|
||||
Damage Damage
|
||||
Timestamp xproto.Timestamp
|
||||
Area xproto.Rectangle
|
||||
Geometry xproto.Rectangle
|
||||
}
|
||||
|
||||
// Event read Notify
|
||||
func NotifyEventNew(buf []byte) xgb.Event {
|
||||
v := NotifyEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
v.Level = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Drawable = xproto.Drawable(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Damage = Damage(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Area = xproto.Rectangle{}
|
||||
b += xproto.RectangleRead(buf[b:], &v.Area)
|
||||
|
||||
v.Geometry = xproto.Rectangle{}
|
||||
b += xproto.RectangleRead(buf[b:], &v.Geometry)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write Notify
|
||||
func (v NotifyEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
buf[b] = v.Level
|
||||
b += 1
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Damage))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
||||
b += 4
|
||||
|
||||
{
|
||||
structBytes := v.Area.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
|
||||
{
|
||||
structBytes := v.Geometry.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v NotifyEvent) ImplementsEvent() {}
|
||||
|
||||
func (v NotifyEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v NotifyEvent) String() string {
|
||||
fieldVals := make([]string, 0, 6)
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Level: %d", v.Level))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Damage: %d", v.Damage))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp))
|
||||
return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["DAMAGE"][0] = NotifyEventNew
|
||||
}
|
||||
|
||||
// Error definition BadDamage (0)
|
||||
// Size: 32
|
||||
|
||||
const BadBadDamage = 0
|
||||
|
||||
type BadDamageError struct {
|
||||
Sequence uint16
|
||||
NiceName string
|
||||
}
|
||||
|
||||
// Error read BadDamage
|
||||
func BadDamageErrorNew(buf []byte) xgb.Error {
|
||||
v := BadDamageError{}
|
||||
v.NiceName = "BadDamage"
|
||||
|
||||
b := 1 // skip error determinant
|
||||
b += 1 // don't read error number
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (err BadDamageError) ImplementsError() {}
|
||||
|
||||
func (err BadDamageError) SequenceId() uint16 {
|
||||
return err.Sequence
|
||||
}
|
||||
|
||||
func (err BadDamageError) BadId() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (err BadDamageError) Error() string {
|
||||
fieldVals := make([]string, 0, 0)
|
||||
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
||||
return "BadBadDamage {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtErrorFuncs["DAMAGE"][0] = BadDamageErrorNew
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 12
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 32
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint32
|
||||
MinorVersion uint32
|
||||
// padding: 16 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.MinorVersion = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 16 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], ClientMajorVersion)
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], ClientMinorVersion)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Create
|
||||
// size: 16
|
||||
type CreateCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Create
|
||||
func Create(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie)
|
||||
return CreateCookie{cookie}
|
||||
}
|
||||
|
||||
func CreateChecked(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie)
|
||||
return CreateCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CreateCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Create
|
||||
func createRequest(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Damage))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
buf[b] = Level
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Destroy
|
||||
// size: 8
|
||||
type DestroyCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Destroy
|
||||
func Destroy(c *xgb.Conn, Damage Damage) DestroyCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(destroyRequest(c, Damage), cookie)
|
||||
return DestroyCookie{cookie}
|
||||
}
|
||||
|
||||
func DestroyChecked(c *xgb.Conn, Damage Damage) DestroyCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(destroyRequest(c, Damage), cookie)
|
||||
return DestroyCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DestroyCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Destroy
|
||||
func destroyRequest(c *xgb.Conn, Damage Damage) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Damage))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Subtract
|
||||
// size: 16
|
||||
type SubtractCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Subtract
|
||||
func Subtract(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie)
|
||||
return SubtractCookie{cookie}
|
||||
}
|
||||
|
||||
func SubtractChecked(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie)
|
||||
return SubtractCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook SubtractCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Subtract
|
||||
func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Damage))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Repair))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Parts))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Add
|
||||
// size: 12
|
||||
type AddCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Add
|
||||
func Add(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(addRequest(c, Drawable, Region), cookie)
|
||||
return AddCookie{cookie}
|
||||
}
|
||||
|
||||
func AddChecked(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(addRequest(c, Drawable, Region), cookie)
|
||||
return AddCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook AddCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Add
|
||||
func addRequest(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DAMAGE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Region))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
23
nexgb/doc.go
23
nexgb/doc.go
@ -24,6 +24,7 @@ accompanying documentation can be found in examples/create-window.
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/BurntSushi/xgb"
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -33,18 +34,19 @@ accompanying documentation can be found in examples/create-window.
|
||||
return
|
||||
}
|
||||
|
||||
wid, _ := X.NewId()
|
||||
X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root,
|
||||
wid, _ := xproto.NewWindowId(X)
|
||||
screen := xproto.Setup(X).DefaultScreen(X)
|
||||
xproto.CreateWindow(X, screen.RootDepth, wid, screen.Root,
|
||||
0, 0, 500, 500, 0,
|
||||
xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual,
|
||||
xgb.CwBackPixel | xgb.CwEventMask,
|
||||
xproto.WindowClassInputOutput, screen.RootVisual,
|
||||
xproto.CwBackPixel | xproto.CwEventMask,
|
||||
[]uint32{ // values must be in the order defined by the protocol
|
||||
0xffffffff,
|
||||
xgb.EventMaskStructureNotify |
|
||||
xgb.EventMaskKeyPress |
|
||||
xgb.EventMaskKeyRelease})
|
||||
xproto.EventMaskStructureNotify |
|
||||
xproto.EventMaskKeyPress |
|
||||
xproto.EventMaskKeyRelease})
|
||||
|
||||
X.MapWindow(wid)
|
||||
xproto.MapWindow(X, wid)
|
||||
for {
|
||||
ev, xerr := X.WaitForEvent()
|
||||
if ev == nil && xerr == nil {
|
||||
@ -73,6 +75,7 @@ can be found in examples/xinerama.
|
||||
"fmt"
|
||||
"log"
|
||||
"github.com/BurntSushi/xgb"
|
||||
"github.com/BurntSushi/xgb/xinerama"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -84,12 +87,12 @@ can be found in examples/xinerama.
|
||||
// Initialize the Xinerama extension.
|
||||
// The appropriate 'Init' function must be run for *every*
|
||||
// extension before any of its requests can be used.
|
||||
err = X.XineramaInit()
|
||||
err = xinerama.Init(X)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
reply, err := X.XineramaQueryScreens().Reply()
|
||||
reply, err := xinerama.QueryScreens(X).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
590
nexgb/dpms/dpms.go
Normal file
590
nexgb/dpms/dpms.go
Normal file
@ -0,0 +1,590 @@
|
||||
package dpms
|
||||
|
||||
/*
|
||||
This file was generated by dpms.xml on May 10 2012 4:20:27pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the DPMS extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 4, "DPMS").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named DPMS could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["DPMS"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["DPMS"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["DPMS"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["DPMS"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
const (
|
||||
DPMSModeOn = 0
|
||||
DPMSModeStandby = 1
|
||||
DPMSModeSuspend = 2
|
||||
DPMSModeOff = 3
|
||||
)
|
||||
|
||||
// Request GetVersion
|
||||
// size: 8
|
||||
type GetVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return GetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return GetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetVersion
|
||||
// size: 12
|
||||
type GetVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetVersion
|
||||
func (cook GetVersionCookie) Reply() (*GetVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetVersion
|
||||
func getVersionReply(buf []byte) *GetVersionReply {
|
||||
v := new(GetVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetVersion
|
||||
func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Capable
|
||||
// size: 4
|
||||
type CapableCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func Capable(c *xgb.Conn) CapableCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(capableRequest(c), cookie)
|
||||
return CapableCookie{cookie}
|
||||
}
|
||||
|
||||
func CapableUnchecked(c *xgb.Conn) CapableCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(capableRequest(c), cookie)
|
||||
return CapableCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Capable
|
||||
// size: 32
|
||||
type CapableReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Capable bool
|
||||
// padding: 23 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Capable
|
||||
func (cook CapableCookie) Reply() (*CapableReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return capableReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Capable
|
||||
func capableReply(buf []byte) *CapableReply {
|
||||
v := new(CapableReply)
|
||||
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
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Capable = true
|
||||
} else {
|
||||
v.Capable = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 23 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for Capable
|
||||
func capableRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetTimeouts
|
||||
// size: 4
|
||||
type GetTimeoutsCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getTimeoutsRequest(c), cookie)
|
||||
return GetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getTimeoutsRequest(c), cookie)
|
||||
return GetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetTimeouts
|
||||
// size: 32
|
||||
type GetTimeoutsReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
StandbyTimeout uint16
|
||||
SuspendTimeout uint16
|
||||
OffTimeout uint16
|
||||
// padding: 18 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetTimeouts
|
||||
func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getTimeoutsReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetTimeouts
|
||||
func getTimeoutsReply(buf []byte) *GetTimeoutsReply {
|
||||
v := new(GetTimeoutsReply)
|
||||
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.StandbyTimeout = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.SuspendTimeout = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.OffTimeout = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 18 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetTimeouts
|
||||
func getTimeoutsRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request SetTimeouts
|
||||
// size: 12
|
||||
type SetTimeoutsCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for SetTimeouts
|
||||
func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie)
|
||||
return SetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie)
|
||||
return SetTimeoutsCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook SetTimeoutsCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for SetTimeouts
|
||||
func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], StandbyTimeout)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], SuspendTimeout)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], OffTimeout)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Enable
|
||||
// size: 4
|
||||
type EnableCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Enable
|
||||
func Enable(c *xgb.Conn) EnableCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(enableRequest(c), cookie)
|
||||
return EnableCookie{cookie}
|
||||
}
|
||||
|
||||
func EnableChecked(c *xgb.Conn) EnableCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(enableRequest(c), cookie)
|
||||
return EnableCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook EnableCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Enable
|
||||
func enableRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Disable
|
||||
// size: 4
|
||||
type DisableCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Disable
|
||||
func Disable(c *xgb.Conn) DisableCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(disableRequest(c), cookie)
|
||||
return DisableCookie{cookie}
|
||||
}
|
||||
|
||||
func DisableChecked(c *xgb.Conn) DisableCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(disableRequest(c), cookie)
|
||||
return DisableCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DisableCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Disable
|
||||
func disableRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ForceLevel
|
||||
// size: 8
|
||||
type ForceLevelCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for ForceLevel
|
||||
func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(forceLevelRequest(c, PowerLevel), cookie)
|
||||
return ForceLevelCookie{cookie}
|
||||
}
|
||||
|
||||
func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(forceLevelRequest(c, PowerLevel), cookie)
|
||||
return ForceLevelCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook ForceLevelCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for ForceLevel
|
||||
func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], PowerLevel)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Info
|
||||
// size: 4
|
||||
type InfoCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func Info(c *xgb.Conn) InfoCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(infoRequest(c), cookie)
|
||||
return InfoCookie{cookie}
|
||||
}
|
||||
|
||||
func InfoUnchecked(c *xgb.Conn) InfoCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(infoRequest(c), cookie)
|
||||
return InfoCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Info
|
||||
// size: 32
|
||||
type InfoReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
PowerLevel uint16
|
||||
State bool
|
||||
// padding: 21 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Info
|
||||
func (cook InfoCookie) Reply() (*InfoReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return infoReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Info
|
||||
func infoReply(buf []byte) *InfoReply {
|
||||
v := new(InfoReply)
|
||||
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.PowerLevel = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.State = true
|
||||
} else {
|
||||
v.State = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 21 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for Info
|
||||
func infoRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["DPMS"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
1522
nexgb/dri2/dri2.go
Normal file
1522
nexgb/dri2/dri2.go
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/BurntSushi/xgb"
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -17,15 +18,23 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// xproto.Setup retrieves the Setup information from the setup bytes
|
||||
// gathered during connection.
|
||||
setup := xproto.Setup(X)
|
||||
|
||||
// This is the default screen with all its associated info.
|
||||
screen := setup.DefaultScreen(X)
|
||||
|
||||
// Any time a new resource (i.e., a window, pixmap, graphics context, etc.)
|
||||
// is created, we need to generate a resource identifier with NewId.
|
||||
wid, _ := X.NewId()
|
||||
// is created, we need to generate a resource identifier.
|
||||
// If the resource is a window, then use xproto.NewWindowId. If it's for
|
||||
// a pixmap, then use xproto.NewPixmapId. And so on...
|
||||
wid, _ := xproto.NewWindowId(X)
|
||||
|
||||
// CreateWindow takes a boatload of parameters.
|
||||
X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root,
|
||||
xproto.CreateWindow(X, screen.RootDepth, wid, screen.Root,
|
||||
0, 0, 500, 500, 0,
|
||||
xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual,
|
||||
0, []uint32{})
|
||||
xproto.WindowClassInputOutput, screen.RootVisual, 0, []uint32{})
|
||||
|
||||
// This call to ChangeWindowAttributes could be factored out and
|
||||
// included with the above CreateWindow call, but it is left here for
|
||||
@ -34,13 +43,13 @@ func main() {
|
||||
// etc.) and when a key press or a key release has been made when the
|
||||
// window has focus.
|
||||
// We also set the 'BackPixel' to white so that the window isn't butt ugly.
|
||||
X.ChangeWindowAttributes(wid,
|
||||
xgb.CwBackPixel|xgb.CwEventMask,
|
||||
xproto.ChangeWindowAttributes(X, wid,
|
||||
xproto.CwBackPixel|xproto.CwEventMask,
|
||||
[]uint32{ // values must be in the order defined by the protocol
|
||||
0xffffffff,
|
||||
xgb.EventMaskStructureNotify |
|
||||
xgb.EventMaskKeyPress |
|
||||
xgb.EventMaskKeyRelease})
|
||||
xproto.EventMaskStructureNotify |
|
||||
xproto.EventMaskKeyPress |
|
||||
xproto.EventMaskKeyRelease})
|
||||
|
||||
// MapWindow makes the window we've created appear on the screen.
|
||||
// We demonstrated the use of a 'checked' request here.
|
||||
@ -58,7 +67,7 @@ func main() {
|
||||
//
|
||||
// Note that requests without replies are by default unchecked while
|
||||
// requests *with* replies are checked by default.
|
||||
err = X.MapWindowChecked(wid).Check()
|
||||
err = xproto.MapWindowChecked(X, wid).Check()
|
||||
if err != nil {
|
||||
fmt.Printf("Checked Error for mapping window %d: %s\n", wid, err)
|
||||
} else {
|
||||
@ -67,7 +76,7 @@ func main() {
|
||||
|
||||
// This is an example of an invalid MapWindow request and what an error
|
||||
// looks like.
|
||||
err = X.MapWindowChecked(0).Check()
|
||||
err = xproto.MapWindowChecked(X, 0).Check()
|
||||
if err != nil {
|
||||
fmt.Printf("Checked Error for mapping window 0x1: %s\n", err)
|
||||
} else { // neva
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/BurntSushi/xgb"
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -16,18 +17,21 @@ func main() {
|
||||
}
|
||||
|
||||
// Get the window id of the root window.
|
||||
root := X.DefaultScreen().Root
|
||||
setup := xproto.Setup(X)
|
||||
root := setup.DefaultScreen(X).Root
|
||||
|
||||
// Get the atom id (i.e., intern an atom) of "_NET_ACTIVE_WINDOW".
|
||||
aname := "_NET_ACTIVE_WINDOW"
|
||||
activeAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply()
|
||||
activeAtom, err := xproto.InternAtom(X, true, uint16(len(aname)),
|
||||
aname).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Get the atom id (i.e., intern an atom) of "_NET_WM_NAME".
|
||||
aname = "_NET_WM_NAME"
|
||||
nameAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply()
|
||||
nameAtom, err := xproto.InternAtom(X, true, uint16(len(aname)),
|
||||
aname).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -37,19 +41,19 @@ func main() {
|
||||
// XGB helper function, 'Get32', to pull an unsigned 32-bit integer out
|
||||
// of the byte slice. We then convert it to an X resource id so it can
|
||||
// be used to get the name of the window in the next GetProperty request.
|
||||
reply, err := X.GetProperty(false, root, activeAtom.Atom,
|
||||
xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
|
||||
reply, err := xproto.GetProperty(X, false, root, activeAtom.Atom,
|
||||
xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
windowId := xgb.Id(xgb.Get32(reply.Value))
|
||||
windowId := xproto.Window(xgb.Get32(reply.Value))
|
||||
fmt.Printf("Active window id: %X\n", windowId)
|
||||
|
||||
// Now get the value of _NET_WM_NAME for the active window.
|
||||
// Note that this time, we simply convert the resulting byte slice,
|
||||
// reply.Value, to a string.
|
||||
reply, err = X.GetProperty(false, windowId, nameAtom.Atom,
|
||||
xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
|
||||
reply, err = xproto.GetProperty(X, false, windowId, nameAtom.Atom,
|
||||
xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -15,27 +15,32 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/BurntSushi/xgb"
|
||||
"github.com/BurntSushi/xgb/randr"
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
func main() {
|
||||
X, _ := xgb.NewConn()
|
||||
|
||||
// Every extension must be initialized before it can be used.
|
||||
err := X.RandrInit()
|
||||
err := randr.Init(X)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Get the root window on the default screen.
|
||||
root := xproto.Setup(X).DefaultScreen(X).Root
|
||||
|
||||
// Gets the current screen resources. Screen resources contains a list
|
||||
// of names, crtcs, outputs and modes, among other things.
|
||||
resources, err := X.RandrGetScreenResources(X.DefaultScreen().Root).Reply()
|
||||
resources, err := randr.GetScreenResources(X, root).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Iterate through all of the outputs and show some of their info.
|
||||
for _, output := range resources.Outputs {
|
||||
info, err := X.RandrGetOutputInfo(output, 0).Reply()
|
||||
info, err := randr.GetOutputInfo(X, output, 0).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -52,7 +57,7 @@ func main() {
|
||||
|
||||
// Iterate through all of the crtcs and show some of their info.
|
||||
for _, crtc := range resources.Crtcs {
|
||||
info, err := X.RandrGetCrtcInfo(crtc, 0).Reply()
|
||||
info, err := randr.GetCrtcInfo(X, crtc, 0).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -61,11 +66,11 @@ func main() {
|
||||
}
|
||||
|
||||
// Tell RandR to send us events. (I think these are all of them, as of 1.3.)
|
||||
err = X.RandrSelectInputChecked(X.DefaultScreen().Root,
|
||||
xgb.RandrNotifyMaskScreenChange|
|
||||
xgb.RandrNotifyMaskCrtcChange|
|
||||
xgb.RandrNotifyMaskOutputChange|
|
||||
xgb.RandrNotifyMaskOutputProperty).Check()
|
||||
err = randr.SelectInputChecked(X, root,
|
||||
randr.NotifyMaskScreenChange|
|
||||
randr.NotifyMaskCrtcChange|
|
||||
randr.NotifyMaskOutputChange|
|
||||
randr.NotifyMaskOutputProperty).Check()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/BurntSushi/xgb"
|
||||
"github.com/BurntSushi/xgb/xinerama"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -17,13 +18,13 @@ func main() {
|
||||
// Initialize the Xinerama extension.
|
||||
// The appropriate 'Init' function must be run for *every*
|
||||
// extension before any of its requests can be used.
|
||||
err = X.XineramaInit()
|
||||
err = xinerama.Init(X)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Issue a request to get the screen information.
|
||||
reply, err := X.XineramaQueryScreens().Reply()
|
||||
reply, err := xinerama.QueryScreens(X).Reply()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
153
nexgb/ge/ge.go
Normal file
153
nexgb/ge/ge.go
Normal file
@ -0,0 +1,153 @@
|
||||
package ge
|
||||
|
||||
/*
|
||||
This file was generated by ge.xml on May 10 2012 4:20:27pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the Generic Event Extension extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 23, "Generic Event Extension").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named Generic Event Extension could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["Generic Event Extension"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["Generic Event Extension"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["Generic Event Extension"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["Generic Event Extension"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["Generic Event Extension"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 8
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 32
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint16
|
||||
MinorVersion uint16
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["GENERIC EVENT EXTENSION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
9168
nexgb/glx/glx.go
Normal file
9168
nexgb/glx/glx.go
Normal file
File diff suppressed because it is too large
Load Diff
3964
nexgb/randr/randr.go
Normal file
3964
nexgb/randr/randr.go
Normal file
File diff suppressed because it is too large
Load Diff
1089
nexgb/record/record.go
Normal file
1089
nexgb/record/record.go
Normal file
File diff suppressed because it is too large
Load Diff
3542
nexgb/render/render.go
Normal file
3542
nexgb/render/render.go
Normal file
File diff suppressed because it is too large
Load Diff
514
nexgb/res/res.go
Normal file
514
nexgb/res/res.go
Normal file
@ -0,0 +1,514 @@
|
||||
package res
|
||||
|
||||
/*
|
||||
This file was generated by res.xml on May 10 2012 4:20:28pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the X-Resource extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 10, "X-Resource").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named X-Resource could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["X-Resource"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["X-Resource"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["X-Resource"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["X-Resource"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["X-Resource"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// 'Client' struct definition
|
||||
// Size: 8
|
||||
type Client struct {
|
||||
ResourceBase uint32
|
||||
ResourceMask uint32
|
||||
}
|
||||
|
||||
// Struct read Client
|
||||
func ClientRead(buf []byte, v *Client) int {
|
||||
b := 0
|
||||
|
||||
v.ResourceBase = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.ResourceMask = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read Client
|
||||
func ClientReadList(buf []byte, dest []Client) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = Client{}
|
||||
b += ClientRead(buf[b:], &dest[i])
|
||||
}
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
// Struct write Client
|
||||
func (v Client) Bytes() []byte {
|
||||
buf := make([]byte, 8)
|
||||
b := 0
|
||||
|
||||
xgb.Put32(buf[b:], v.ResourceBase)
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], v.ResourceMask)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list Client
|
||||
func ClientListBytes(buf []byte, list []Client) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// 'Type' struct definition
|
||||
// Size: 8
|
||||
type Type struct {
|
||||
ResourceType xproto.Atom
|
||||
Count uint32
|
||||
}
|
||||
|
||||
// Struct read Type
|
||||
func TypeRead(buf []byte, v *Type) int {
|
||||
b := 0
|
||||
|
||||
v.ResourceType = xproto.Atom(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Count = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read Type
|
||||
func TypeReadList(buf []byte, dest []Type) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = Type{}
|
||||
b += TypeRead(buf[b:], &dest[i])
|
||||
}
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
// Struct write Type
|
||||
func (v Type) Bytes() []byte {
|
||||
buf := make([]byte, 8)
|
||||
b := 0
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.ResourceType))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], v.Count)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list Type
|
||||
func TypeListBytes(buf []byte, list []Type) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 8
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 12
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajor uint16
|
||||
ServerMinor uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajor = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinor = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = ClientMajor
|
||||
b += 1
|
||||
|
||||
buf[b] = ClientMinor
|
||||
b += 1
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request QueryClients
|
||||
// size: 4
|
||||
type QueryClientsCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryClients(c *xgb.Conn) QueryClientsCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryClientsRequest(c), cookie)
|
||||
return QueryClientsCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryClientsRequest(c), cookie)
|
||||
return QueryClientsCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryClients
|
||||
// size: (32 + xgb.Pad((int(NumClients) * 8)))
|
||||
type QueryClientsReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
NumClients uint32
|
||||
// padding: 20 bytes
|
||||
Clients []Client // size: xgb.Pad((int(NumClients) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryClients
|
||||
func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryClientsReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryClients
|
||||
func queryClientsReply(buf []byte) *QueryClientsReply {
|
||||
v := new(QueryClientsReply)
|
||||
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.NumClients = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Clients = make([]Client, v.NumClients)
|
||||
b += ClientReadList(buf[b:], v.Clients)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryClients
|
||||
func queryClientsRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request QueryClientResources
|
||||
// size: 8
|
||||
type QueryClientResourcesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryClientResourcesRequest(c, Xid), cookie)
|
||||
return QueryClientResourcesCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryClientResourcesUnchecked(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryClientResourcesRequest(c, Xid), cookie)
|
||||
return QueryClientResourcesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryClientResources
|
||||
// size: (32 + xgb.Pad((int(NumTypes) * 8)))
|
||||
type QueryClientResourcesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
NumTypes uint32
|
||||
// padding: 20 bytes
|
||||
Types []Type // size: xgb.Pad((int(NumTypes) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryClientResources
|
||||
func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryClientResourcesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryClientResources
|
||||
func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply {
|
||||
v := new(QueryClientResourcesReply)
|
||||
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.NumTypes = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Types = make([]Type, v.NumTypes)
|
||||
b += TypeReadList(buf[b:], v.Types)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryClientResources
|
||||
func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], Xid)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request QueryClientPixmapBytes
|
||||
// size: 8
|
||||
type QueryClientPixmapBytesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie)
|
||||
return QueryClientPixmapBytesCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie)
|
||||
return QueryClientPixmapBytesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryClientPixmapBytes
|
||||
// size: 16
|
||||
type QueryClientPixmapBytesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Bytes uint32
|
||||
BytesOverflow uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryClientPixmapBytes
|
||||
func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryClientPixmapBytesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryClientPixmapBytes
|
||||
func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply {
|
||||
v := new(QueryClientPixmapBytesReply)
|
||||
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.Bytes = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.BytesOverflow = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryClientPixmapBytes
|
||||
func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["X-RESOURCE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], Xid)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
621
nexgb/screensaver/screensaver.go
Normal file
621
nexgb/screensaver/screensaver.go
Normal file
@ -0,0 +1,621 @@
|
||||
package screensaver
|
||||
|
||||
/*
|
||||
This file was generated by screensaver.xml on May 10 2012 4:20:28pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the MIT-SCREEN-SAVER extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 16, "MIT-SCREEN-SAVER").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named MIT-SCREEN-SAVER could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["MIT-SCREEN-SAVER"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["MIT-SCREEN-SAVER"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["MIT-SCREEN-SAVER"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
const (
|
||||
KindBlanked = 0
|
||||
KindInternal = 1
|
||||
KindExternal = 2
|
||||
)
|
||||
|
||||
const (
|
||||
EventNotifyMask = 1
|
||||
EventCycleMask = 2
|
||||
)
|
||||
|
||||
const (
|
||||
StateOff = 0
|
||||
StateOn = 1
|
||||
StateCycle = 2
|
||||
StateDisabled = 3
|
||||
)
|
||||
|
||||
// Event definition Notify (0)
|
||||
// Size: 32
|
||||
|
||||
const Notify = 0
|
||||
|
||||
type NotifyEvent struct {
|
||||
Sequence uint16
|
||||
Code byte
|
||||
State byte
|
||||
// padding: 1 bytes
|
||||
SequenceNumber uint16
|
||||
Time xproto.Timestamp
|
||||
Root xproto.Window
|
||||
Window xproto.Window
|
||||
Kind byte
|
||||
Forced bool
|
||||
// padding: 14 bytes
|
||||
}
|
||||
|
||||
// Event read Notify
|
||||
func NotifyEventNew(buf []byte) xgb.Event {
|
||||
v := NotifyEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
v.Code = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.State = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.SequenceNumber = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Time = xproto.Timestamp(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Root = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Kind = buf[b]
|
||||
b += 1
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Forced = true
|
||||
} else {
|
||||
v.Forced = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 14 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write Notify
|
||||
func (v NotifyEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
buf[b] = v.Code
|
||||
b += 1
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
buf[b] = v.State
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
xgb.Put16(buf[b:], v.SequenceNumber)
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Time))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Root))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = v.Kind
|
||||
b += 1
|
||||
|
||||
if v.Forced {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 14 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v NotifyEvent) ImplementsEvent() {}
|
||||
|
||||
func (v NotifyEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v NotifyEvent) String() string {
|
||||
fieldVals := make([]string, 0, 10)
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Code: %d", v.Code))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("SequenceNumber: %d", v.SequenceNumber))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Forced: %t", v.Forced))
|
||||
return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"][0] = NotifyEventNew
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 8
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 32
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = ClientMajorVersion
|
||||
b += 1
|
||||
|
||||
buf[b] = ClientMinorVersion
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request QueryInfo
|
||||
// size: 8
|
||||
type QueryInfoCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryInfo(c *xgb.Conn, Drawable xproto.Drawable) QueryInfoCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryInfoRequest(c, Drawable), cookie)
|
||||
return QueryInfoCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryInfoUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryInfoCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryInfoRequest(c, Drawable), cookie)
|
||||
return QueryInfoCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryInfo
|
||||
// size: 32
|
||||
type QueryInfoReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
State byte
|
||||
SaverWindow xproto.Window
|
||||
MsUntilServer uint32
|
||||
MsSinceUserInput uint32
|
||||
EventMask uint32
|
||||
Kind byte
|
||||
// padding: 7 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryInfo
|
||||
func (cook QueryInfoCookie) Reply() (*QueryInfoReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryInfoReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryInfo
|
||||
func queryInfoReply(buf []byte) *QueryInfoReply {
|
||||
v := new(QueryInfoReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.State = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.SaverWindow = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.MsUntilServer = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.MsSinceUserInput = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.EventMask = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Kind = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 7 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryInfo
|
||||
func queryInfoRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request SelectInput
|
||||
// size: 12
|
||||
type SelectInputCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for SelectInput
|
||||
func SelectInput(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) SelectInputCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(selectInputRequest(c, Drawable, EventMask), cookie)
|
||||
return SelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func SelectInputChecked(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) SelectInputCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(selectInputRequest(c, Drawable, EventMask), cookie)
|
||||
return SelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook SelectInputCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for SelectInput
|
||||
func selectInputRequest(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], EventMask)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request SetAttributes
|
||||
// size: xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask)))))))
|
||||
type SetAttributesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for SetAttributes
|
||||
func SetAttributes(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) SetAttributesCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(setAttributesRequest(c, Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie)
|
||||
return SetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func SetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) SetAttributesCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(setAttributesRequest(c, Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie)
|
||||
return SetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook SetAttributesCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for SetAttributes
|
||||
func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) []byte {
|
||||
size := xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask)))))))
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], uint16(X))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(Y))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], BorderWidth)
|
||||
b += 2
|
||||
|
||||
buf[b] = Class
|
||||
b += 1
|
||||
|
||||
buf[b] = Depth
|
||||
b += 1
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Visual))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], ValueMask)
|
||||
b += 4
|
||||
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
|
||||
xgb.Put32(buf[b:], ValueList[i])
|
||||
b += 4
|
||||
}
|
||||
b = xgb.Pad(b)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request UnsetAttributes
|
||||
// size: 8
|
||||
type UnsetAttributesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for UnsetAttributes
|
||||
func UnsetAttributes(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(unsetAttributesRequest(c, Drawable), cookie)
|
||||
return UnsetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func UnsetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(unsetAttributesRequest(c, Drawable), cookie)
|
||||
return UnsetAttributesCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook UnsetAttributesCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for UnsetAttributes
|
||||
func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Suspend
|
||||
// size: 8
|
||||
type SuspendCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Suspend
|
||||
func Suspend(c *xgb.Conn, Suspend bool) SuspendCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(suspendRequest(c, Suspend), cookie)
|
||||
return SuspendCookie{cookie}
|
||||
}
|
||||
|
||||
func SuspendChecked(c *xgb.Conn, Suspend bool) SuspendCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(suspendRequest(c, Suspend), cookie)
|
||||
return SuspendCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook SuspendCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Suspend
|
||||
func suspendRequest(c *xgb.Conn, Suspend bool) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SCREEN-SAVER"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
if Suspend {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
883
nexgb/shape/shape.go
Normal file
883
nexgb/shape/shape.go
Normal file
@ -0,0 +1,883 @@
|
||||
package shape
|
||||
|
||||
/*
|
||||
This file was generated by shape.xml on May 10 2012 4:20:28pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the SHAPE extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 5, "SHAPE").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named SHAPE could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["SHAPE"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["SHAPE"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["SHAPE"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["SHAPE"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["SHAPE"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
const (
|
||||
SoSet = 0
|
||||
SoUnion = 1
|
||||
SoIntersect = 2
|
||||
SoSubtract = 3
|
||||
SoInvert = 4
|
||||
)
|
||||
|
||||
const (
|
||||
SkBounding = 0
|
||||
SkClip = 1
|
||||
SkInput = 2
|
||||
)
|
||||
|
||||
type Op byte
|
||||
|
||||
type Kind byte
|
||||
|
||||
// Event definition Notify (0)
|
||||
// Size: 32
|
||||
|
||||
const Notify = 0
|
||||
|
||||
type NotifyEvent struct {
|
||||
Sequence uint16
|
||||
ShapeKind Kind
|
||||
AffectedWindow xproto.Window
|
||||
ExtentsX int16
|
||||
ExtentsY int16
|
||||
ExtentsWidth uint16
|
||||
ExtentsHeight uint16
|
||||
ServerTime xproto.Timestamp
|
||||
Shaped bool
|
||||
// padding: 11 bytes
|
||||
}
|
||||
|
||||
// Event read Notify
|
||||
func NotifyEventNew(buf []byte) xgb.Event {
|
||||
v := NotifyEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
v.ShapeKind = Kind(buf[b])
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.AffectedWindow = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.ExtentsX = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ExtentsY = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ExtentsWidth = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ExtentsHeight = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerTime = xproto.Timestamp(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Shaped = true
|
||||
} else {
|
||||
v.Shaped = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 11 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write Notify
|
||||
func (v NotifyEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(v.ShapeKind)
|
||||
b += 1
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.AffectedWindow))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], uint16(v.ExtentsX))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(v.ExtentsY))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.ExtentsWidth)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.ExtentsHeight)
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.ServerTime))
|
||||
b += 4
|
||||
|
||||
if v.Shaped {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 11 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v NotifyEvent) ImplementsEvent() {}
|
||||
|
||||
func (v NotifyEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v NotifyEvent) String() string {
|
||||
fieldVals := make([]string, 0, 9)
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("ShapeKind: %d", v.ShapeKind))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("AffectedWindow: %d", v.AffectedWindow))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("ExtentsX: %d", v.ExtentsX))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("ExtentsY: %d", v.ExtentsY))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("ExtentsWidth: %d", v.ExtentsWidth))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("ExtentsHeight: %d", v.ExtentsHeight))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("ServerTime: %d", v.ServerTime))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Shaped: %t", v.Shaped))
|
||||
return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["SHAPE"][0] = NotifyEventNew
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 4
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 12
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
MajorVersion uint16
|
||||
MinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Rectangles
|
||||
// size: xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8))))
|
||||
type RectanglesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Rectangles
|
||||
func Rectangles(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie)
|
||||
return RectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
func RectanglesChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie)
|
||||
return RectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook RectanglesCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Rectangles
|
||||
func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) []byte {
|
||||
size := xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8))))
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(Operation)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
buf[b] = Ordering
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
b += xproto.RectangleListBytes(buf[b:], Rectangles)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Mask
|
||||
// size: 20
|
||||
type MaskCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Mask
|
||||
func Mask(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie)
|
||||
return MaskCookie{cookie}
|
||||
}
|
||||
|
||||
func MaskChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie)
|
||||
return MaskCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook MaskCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Mask
|
||||
func maskRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) []byte {
|
||||
size := 20
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(Operation)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SourceBitmap))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Combine
|
||||
// size: 20
|
||||
type CombineCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Combine
|
||||
func Combine(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie)
|
||||
return CombineCookie{cookie}
|
||||
}
|
||||
|
||||
func CombineChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie)
|
||||
return CombineCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CombineCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Combine
|
||||
func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) []byte {
|
||||
size := 20
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(Operation)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
buf[b] = byte(SourceKind)
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SourceWindow))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Offset
|
||||
// size: 16
|
||||
type OffsetCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Offset
|
||||
func Offset(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) OffsetCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(offsetRequest(c, DestinationKind, DestinationWindow, XOffset, YOffset), cookie)
|
||||
return OffsetCookie{cookie}
|
||||
}
|
||||
|
||||
func OffsetChecked(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) OffsetCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(offsetRequest(c, DestinationKind, DestinationWindow, XOffset, YOffset), cookie)
|
||||
return OffsetCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook OffsetCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Offset
|
||||
func offsetRequest(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = byte(DestinationKind)
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], uint16(XOffset))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(YOffset))
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request QueryExtents
|
||||
// size: 8
|
||||
type QueryExtentsCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryExtents(c *xgb.Conn, DestinationWindow xproto.Window) QueryExtentsCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryExtentsRequest(c, DestinationWindow), cookie)
|
||||
return QueryExtentsCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryExtentsUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) QueryExtentsCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryExtentsRequest(c, DestinationWindow), cookie)
|
||||
return QueryExtentsCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryExtents
|
||||
// size: 28
|
||||
type QueryExtentsReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
BoundingShaped bool
|
||||
ClipShaped bool
|
||||
// padding: 2 bytes
|
||||
BoundingShapeExtentsX int16
|
||||
BoundingShapeExtentsY int16
|
||||
BoundingShapeExtentsWidth uint16
|
||||
BoundingShapeExtentsHeight uint16
|
||||
ClipShapeExtentsX int16
|
||||
ClipShapeExtentsY int16
|
||||
ClipShapeExtentsWidth uint16
|
||||
ClipShapeExtentsHeight uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryExtents
|
||||
func (cook QueryExtentsCookie) Reply() (*QueryExtentsReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryExtentsReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryExtents
|
||||
func queryExtentsReply(buf []byte) *QueryExtentsReply {
|
||||
v := new(QueryExtentsReply)
|
||||
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
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.BoundingShaped = true
|
||||
} else {
|
||||
v.BoundingShaped = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.ClipShaped = true
|
||||
} else {
|
||||
v.ClipShaped = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
v.BoundingShapeExtentsX = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.BoundingShapeExtentsY = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.BoundingShapeExtentsWidth = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.BoundingShapeExtentsHeight = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsX = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsY = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsWidth = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ClipShapeExtentsHeight = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryExtents
|
||||
func queryExtentsRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request SelectInput
|
||||
// size: 12
|
||||
type SelectInputCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for SelectInput
|
||||
func SelectInput(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie)
|
||||
return SelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func SelectInputChecked(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie)
|
||||
return SelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook SelectInputCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for SelectInput
|
||||
func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
if Enable {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request InputSelected
|
||||
// size: 8
|
||||
type InputSelectedCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func InputSelected(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie)
|
||||
return InputSelectedCookie{cookie}
|
||||
}
|
||||
|
||||
func InputSelectedUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie)
|
||||
return InputSelectedCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for InputSelected
|
||||
// size: 8
|
||||
type InputSelectedReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Enabled bool
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request InputSelected
|
||||
func (cook InputSelectedCookie) Reply() (*InputSelectedReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return inputSelectedReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for InputSelected
|
||||
func inputSelectedReply(buf []byte) *InputSelectedReply {
|
||||
v := new(InputSelectedReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Enabled = true
|
||||
} else {
|
||||
v.Enabled = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for InputSelected
|
||||
func inputSelectedRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(DestinationWindow))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetRectangles
|
||||
// size: 12
|
||||
type GetRectanglesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetRectangles(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie)
|
||||
return GetRectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
func GetRectanglesUnchecked(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie)
|
||||
return GetRectanglesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetRectangles
|
||||
// size: (32 + xgb.Pad((int(RectanglesLen) * 8)))
|
||||
type GetRectanglesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Ordering byte
|
||||
RectanglesLen uint32
|
||||
// padding: 20 bytes
|
||||
Rectangles []xproto.Rectangle // size: xgb.Pad((int(RectanglesLen) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetRectangles
|
||||
func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getRectanglesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetRectangles
|
||||
func getRectanglesReply(buf []byte) *GetRectanglesReply {
|
||||
v := new(GetRectanglesReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.Ordering = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.RectanglesLen = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Rectangles = make([]xproto.Rectangle, v.RectanglesLen)
|
||||
b += xproto.RectangleReadList(buf[b:], v.Rectangles)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetRectangles
|
||||
func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["SHAPE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 8 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
buf[b] = byte(SourceKind)
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
672
nexgb/shm/shm.go
Normal file
672
nexgb/shm/shm.go
Normal file
@ -0,0 +1,672 @@
|
||||
package shm
|
||||
|
||||
/*
|
||||
This file was generated by shm.xml on May 10 2012 4:20:28pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the MIT-SHM extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 7, "MIT-SHM").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named MIT-SHM could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["MIT-SHM"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["MIT-SHM"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["MIT-SHM"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["MIT-SHM"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["MIT-SHM"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
type Seg uint32
|
||||
|
||||
func NewSegId(c *xgb.Conn) (Seg, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return Seg(id), nil
|
||||
}
|
||||
|
||||
// Event definition Completion (0)
|
||||
// Size: 32
|
||||
|
||||
const Completion = 0
|
||||
|
||||
type CompletionEvent struct {
|
||||
Sequence uint16
|
||||
// padding: 1 bytes
|
||||
Drawable xproto.Drawable
|
||||
MinorEvent uint16
|
||||
MajorEvent byte
|
||||
// padding: 1 bytes
|
||||
Shmseg Seg
|
||||
Offset uint32
|
||||
}
|
||||
|
||||
// Event read Completion
|
||||
func CompletionEventNew(buf []byte) xgb.Event {
|
||||
v := CompletionEvent{}
|
||||
b := 1 // don't read event number
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Drawable = xproto.Drawable(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.MinorEvent = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MajorEvent = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Shmseg = Seg(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Offset = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Event write Completion
|
||||
func (v CompletionEvent) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
// write event number
|
||||
buf[b] = 0
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
b += 2 // skip sequence number
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], v.MinorEvent)
|
||||
b += 2
|
||||
|
||||
buf[b] = v.MajorEvent
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Shmseg))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], v.Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (v CompletionEvent) ImplementsEvent() {}
|
||||
|
||||
func (v CompletionEvent) SequenceId() uint16 {
|
||||
return v.Sequence
|
||||
}
|
||||
|
||||
func (v CompletionEvent) String() string {
|
||||
fieldVals := make([]string, 0, 7)
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("MinorEvent: %d", v.MinorEvent))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("MajorEvent: %d", v.MajorEvent))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Shmseg: %d", v.Shmseg))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Offset: %d", v.Offset))
|
||||
return "Completion {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["MIT-SHM"][0] = CompletionEventNew
|
||||
}
|
||||
|
||||
// ErrorCopy definition BadSeg (0)
|
||||
|
||||
const BadBadSeg = 0
|
||||
|
||||
type BadSegError xproto.ValueError
|
||||
|
||||
func BadSegErrorNew(buf []byte) xgb.Error {
|
||||
v := BadSegError(xproto.ValueErrorNew(buf).(xproto.ValueError))
|
||||
v.NiceName = "BadSeg"
|
||||
return v
|
||||
}
|
||||
|
||||
func (err BadSegError) ImplementsError() {}
|
||||
|
||||
func (err BadSegError) SequenceId() uint16 {
|
||||
return err.Sequence
|
||||
}
|
||||
|
||||
func (err BadSegError) BadId() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (err BadSegError) Error() string {
|
||||
fieldVals := make([]string, 0, 4)
|
||||
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode))
|
||||
fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode))
|
||||
return "BadBadSeg {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtErrorFuncs["MIT-SHM"][0] = BadSegErrorNew
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 4
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 32
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
SharedPixmaps bool
|
||||
MajorVersion uint16
|
||||
MinorVersion uint16
|
||||
Uid uint16
|
||||
Gid uint16
|
||||
PixmapFormat byte
|
||||
// padding: 15 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.SharedPixmaps = true
|
||||
} else {
|
||||
v.SharedPixmaps = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MajorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Uid = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Gid = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.PixmapFormat = buf[b]
|
||||
b += 1
|
||||
|
||||
b += 15 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Attach
|
||||
// size: 16
|
||||
type AttachCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Attach
|
||||
func Attach(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) AttachCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(attachRequest(c, Shmseg, Shmid, ReadOnly), cookie)
|
||||
return AttachCookie{cookie}
|
||||
}
|
||||
|
||||
func AttachChecked(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) AttachCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(attachRequest(c, Shmseg, Shmid, ReadOnly), cookie)
|
||||
return AttachCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook AttachCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Attach
|
||||
func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte {
|
||||
size := 16
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], Shmid)
|
||||
b += 4
|
||||
|
||||
if ReadOnly {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Detach
|
||||
// size: 8
|
||||
type DetachCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for Detach
|
||||
func Detach(c *xgb.Conn, Shmseg Seg) DetachCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(detachRequest(c, Shmseg), cookie)
|
||||
return DetachCookie{cookie}
|
||||
}
|
||||
|
||||
func DetachChecked(c *xgb.Conn, Shmseg Seg) DetachCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(detachRequest(c, Shmseg), cookie)
|
||||
return DetachCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DetachCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for Detach
|
||||
func detachRequest(c *xgb.Conn, Shmseg Seg) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request PutImage
|
||||
// size: 40
|
||||
type PutImageCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for PutImage
|
||||
func PutImage(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
|
||||
return PutImageCookie{cookie}
|
||||
}
|
||||
|
||||
func PutImageChecked(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie)
|
||||
return PutImageCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook PutImageCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for PutImage
|
||||
func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) []byte {
|
||||
size := 40
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Gc))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], TotalWidth)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], TotalHeight)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], SrcX)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], SrcY)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], SrcWidth)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], SrcHeight)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(DstX))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(DstY))
|
||||
b += 2
|
||||
|
||||
buf[b] = Depth
|
||||
b += 1
|
||||
|
||||
buf[b] = Format
|
||||
b += 1
|
||||
|
||||
buf[b] = SendEvent
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetImage
|
||||
// size: 32
|
||||
type GetImageCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetImage(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) GetImageCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getImageRequest(c, Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie)
|
||||
return GetImageCookie{cookie}
|
||||
}
|
||||
|
||||
func GetImageUnchecked(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) GetImageCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getImageRequest(c, Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie)
|
||||
return GetImageCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetImage
|
||||
// size: 16
|
||||
type GetImageReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Depth byte
|
||||
Visual xproto.Visualid
|
||||
Size uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetImage
|
||||
func (cook GetImageCookie) Reply() (*GetImageReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getImageReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetImage
|
||||
func getImageReply(buf []byte) *GetImageReply {
|
||||
v := new(GetImageReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.Depth = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Visual = xproto.Visualid(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Size = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetImage
|
||||
func getImageRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) []byte {
|
||||
size := 32
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], uint16(X))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(Y))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], PlaneMask)
|
||||
b += 4
|
||||
|
||||
buf[b] = Format
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CreatePixmap
|
||||
// size: 28
|
||||
type CreatePixmapCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for CreatePixmap
|
||||
func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
|
||||
return CreatePixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func CreatePixmapChecked(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie)
|
||||
return CreatePixmapCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook CreatePixmapCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for CreatePixmap
|
||||
func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) []byte {
|
||||
size := 28
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["MIT-SHM"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Pid))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Drawable))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
buf[b] = Depth
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Shmseg))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], Offset)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
29
nexgb/sync.go
Normal file
29
nexgb/sync.go
Normal file
@ -0,0 +1,29 @@
|
||||
package xgb
|
||||
|
||||
// Sync sends a round trip request and wait for the response.
|
||||
// This forces all pending cookies to be dealt with.
|
||||
// You actually shouldn't need to use this like you might with Xlib. Namely,
|
||||
// buffers are automatically flushed using Go's channels and round trip requests
|
||||
// are forced where appropriate automatically.
|
||||
func (c *Conn) Sync() {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(c.getInputFocusRequest(), cookie)
|
||||
cookie.Reply() // wait for the buffer to clear
|
||||
}
|
||||
|
||||
// getInputFocusRequest writes the raw bytes to a buffer.
|
||||
// It is duplicated from xproto/xproto.go.
|
||||
func (c *Conn) getInputFocusRequest() []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = 43 // request opcode
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
1927
nexgb/sync/sync.go
Normal file
1927
nexgb/sync/sync.go
Normal file
File diff suppressed because it is too large
Load Diff
320
nexgb/xcmisc/xcmisc.go
Normal file
320
nexgb/xcmisc/xcmisc.go
Normal file
@ -0,0 +1,320 @@
|
||||
package xcmisc
|
||||
|
||||
/*
|
||||
This file was generated by xc_misc.xml on May 10 2012 4:20:28pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the XC-MISC extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 7, "XC-MISC").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named XC-MISC could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["XC-MISC"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["XC-MISC"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["XC-MISC"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["XC-MISC"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["XC-MISC"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Request GetVersion
|
||||
// size: 8
|
||||
type GetVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return GetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return GetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetVersion
|
||||
// size: 12
|
||||
type GetVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetVersion
|
||||
func (cook GetVersionCookie) Reply() (*GetVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetVersion
|
||||
func getVersionReply(buf []byte) *GetVersionReply {
|
||||
v := new(GetVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetVersion
|
||||
func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XC-MISC"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetXIDRange
|
||||
// size: 4
|
||||
type GetXIDRangeCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getXIDRangeRequest(c), cookie)
|
||||
return GetXIDRangeCookie{cookie}
|
||||
}
|
||||
|
||||
func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getXIDRangeRequest(c), cookie)
|
||||
return GetXIDRangeCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetXIDRange
|
||||
// size: 16
|
||||
type GetXIDRangeReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
StartId uint32
|
||||
Count uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetXIDRange
|
||||
func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getXIDRangeReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetXIDRange
|
||||
func getXIDRangeReply(buf []byte) *GetXIDRangeReply {
|
||||
v := new(GetXIDRangeReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.StartId = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Count = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetXIDRange
|
||||
func getXIDRangeRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XC-MISC"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetXIDList
|
||||
// size: 8
|
||||
type GetXIDListCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getXIDListRequest(c, Count), cookie)
|
||||
return GetXIDListCookie{cookie}
|
||||
}
|
||||
|
||||
func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getXIDListRequest(c, Count), cookie)
|
||||
return GetXIDListCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetXIDList
|
||||
// size: (32 + xgb.Pad((int(IdsLen) * 4)))
|
||||
type GetXIDListReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
IdsLen uint32
|
||||
// padding: 20 bytes
|
||||
Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetXIDList
|
||||
func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getXIDListReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetXIDList
|
||||
func getXIDListReply(buf []byte) *GetXIDListReply {
|
||||
v := new(GetXIDListReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.IdsLen = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Ids = make([]uint32, v.IdsLen)
|
||||
for i := 0; i < int(v.IdsLen); i++ {
|
||||
v.Ids[i] = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = xgb.Pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetXIDList
|
||||
func getXIDListRequest(c *xgb.Conn, Count uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XC-MISC"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], Count)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
525
nexgb/xevie/xevie.go
Normal file
525
nexgb/xevie/xevie.go
Normal file
@ -0,0 +1,525 @@
|
||||
package xevie
|
||||
|
||||
/*
|
||||
This file was generated by xevie.xml on May 10 2012 4:20:28pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the XEVIE extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 5, "XEVIE").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named XEVIE could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["XEVIE"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["XEVIE"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["XEVIE"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["XEVIE"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["XEVIE"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
const (
|
||||
DatatypeUnmodified = 0
|
||||
DatatypeModified = 1
|
||||
)
|
||||
|
||||
// 'Event' struct definition
|
||||
// Size: 32
|
||||
type Event struct {
|
||||
// padding: 32 bytes
|
||||
}
|
||||
|
||||
// Struct read Event
|
||||
func EventRead(buf []byte, v *Event) int {
|
||||
b := 0
|
||||
|
||||
b += 32 // padding
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read Event
|
||||
func EventReadList(buf []byte, dest []Event) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = Event{}
|
||||
b += EventRead(buf[b:], &dest[i])
|
||||
}
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
// Struct write Event
|
||||
func (v Event) Bytes() []byte {
|
||||
buf := make([]byte, 32)
|
||||
b := 0
|
||||
|
||||
b += 32 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list Event
|
||||
func EventListBytes(buf []byte, list []Event) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 8
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 32
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
ServerMajorVersion uint16
|
||||
ServerMinorVersion uint16
|
||||
// padding: 20 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.ServerMajorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ServerMinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMajorVersion)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], ClientMinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Start
|
||||
// size: 8
|
||||
type StartCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func Start(c *xgb.Conn, Screen uint32) StartCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(startRequest(c, Screen), cookie)
|
||||
return StartCookie{cookie}
|
||||
}
|
||||
|
||||
func StartUnchecked(c *xgb.Conn, Screen uint32) StartCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(startRequest(c, Screen), cookie)
|
||||
return StartCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Start
|
||||
// size: 32
|
||||
type StartReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Start
|
||||
func (cook StartCookie) Reply() (*StartReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return startReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Start
|
||||
func startReply(buf []byte) *StartReply {
|
||||
v := new(StartReply)
|
||||
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
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for Start
|
||||
func startRequest(c *xgb.Conn, Screen uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], Screen)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request End
|
||||
// size: 8
|
||||
type EndCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func End(c *xgb.Conn, Cmap uint32) EndCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(endRequest(c, Cmap), cookie)
|
||||
return EndCookie{cookie}
|
||||
}
|
||||
|
||||
func EndUnchecked(c *xgb.Conn, Cmap uint32) EndCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(endRequest(c, Cmap), cookie)
|
||||
return EndCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for End
|
||||
// size: 32
|
||||
type EndReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request End
|
||||
func (cook EndCookie) Reply() (*EndReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return endReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for End
|
||||
func endReply(buf []byte) *EndReply {
|
||||
v := new(EndReply)
|
||||
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
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for End
|
||||
func endRequest(c *xgb.Conn, Cmap uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], Cmap)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request Send
|
||||
// size: 104
|
||||
type SendCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func Send(c *xgb.Conn, Event Event, DataType uint32) SendCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(sendRequest(c, Event, DataType), cookie)
|
||||
return SendCookie{cookie}
|
||||
}
|
||||
|
||||
func SendUnchecked(c *xgb.Conn, Event Event, DataType uint32) SendCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(sendRequest(c, Event, DataType), cookie)
|
||||
return SendCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for Send
|
||||
// size: 32
|
||||
type SendReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request Send
|
||||
func (cook SendCookie) Reply() (*SendReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return sendReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for Send
|
||||
func sendReply(buf []byte) *SendReply {
|
||||
v := new(SendReply)
|
||||
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
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for Send
|
||||
func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte {
|
||||
size := 104
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
{
|
||||
structBytes := Event.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
|
||||
xgb.Put32(buf[b:], DataType)
|
||||
b += 4
|
||||
|
||||
b += 64 // padding
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request SelectInput
|
||||
// size: 8
|
||||
type SelectInputCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func SelectInput(c *xgb.Conn, EventMask uint32) SelectInputCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(selectInputRequest(c, EventMask), cookie)
|
||||
return SelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
func SelectInputUnchecked(c *xgb.Conn, EventMask uint32) SelectInputCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(selectInputRequest(c, EventMask), cookie)
|
||||
return SelectInputCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for SelectInput
|
||||
// size: 32
|
||||
type SelectInputReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request SelectInput
|
||||
func (cook SelectInputCookie) Reply() (*SelectInputReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return selectInputReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for SelectInput
|
||||
func selectInputReply(buf []byte) *SelectInputReply {
|
||||
v := new(SelectInputReply)
|
||||
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
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for SelectInput
|
||||
func selectInputRequest(c *xgb.Conn, EventMask uint32) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XEVIE"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], EventMask)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
1121
nexgb/xf86dri/xf86dri.go
Normal file
1121
nexgb/xf86dri/xf86dri.go
Normal file
File diff suppressed because it is too large
Load Diff
2360
nexgb/xf86vidmode/xf86vidmode.go
Normal file
2360
nexgb/xf86vidmode/xf86vidmode.go
Normal file
File diff suppressed because it is too large
Load Diff
2155
nexgb/xfixes/xfixes.go
Normal file
2155
nexgb/xfixes/xfixes.go
Normal file
File diff suppressed because it is too large
Load Diff
89
nexgb/xgb.go
89
nexgb/xgb.go
@ -9,7 +9,14 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
var logger = log.New(os.Stderr, "XGB: ", 0)
|
||||
var (
|
||||
logger = log.New(os.Stderr, "XGB: ", 0)
|
||||
|
||||
// ExtLock is a lock used whenever new extensions are initialized.
|
||||
// It should not be used. It is exported for use in the extension
|
||||
// sub-packages.
|
||||
ExtLock sync.Mutex
|
||||
)
|
||||
|
||||
const (
|
||||
// cookieBuffer represents the queue size of cookies existing at any
|
||||
@ -44,17 +51,21 @@ type Conn struct {
|
||||
host string
|
||||
conn net.Conn
|
||||
display string
|
||||
defaultScreen int
|
||||
Setup SetupInfo
|
||||
DefaultScreen int
|
||||
SetupBytes []byte
|
||||
|
||||
setupResourceIdBase uint32
|
||||
setupResourceIdMask uint32
|
||||
|
||||
eventChan chan eventOrError
|
||||
cookieChan chan *cookie
|
||||
cookieChan chan *Cookie
|
||||
xidChan chan xid
|
||||
seqChan chan uint16
|
||||
reqChan chan *request
|
||||
|
||||
extLock sync.Mutex
|
||||
extensions map[string]byte
|
||||
// Extensions is a map from extension name to major opcode. It should
|
||||
// not be used. It is exported for use in the extension sub-packages.
|
||||
Extensions map[string]byte
|
||||
}
|
||||
|
||||
// NewConn creates a new connection instance. It initializes locks, data
|
||||
@ -83,9 +94,9 @@ func NewConnDisplay(display string) (*Conn, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
conn.extensions = make(map[string]byte)
|
||||
conn.Extensions = make(map[string]byte)
|
||||
|
||||
conn.cookieChan = make(chan *cookie, cookieBuffer)
|
||||
conn.cookieChan = make(chan *Cookie, cookieBuffer)
|
||||
conn.xidChan = make(chan xid, xidBuffer)
|
||||
conn.seqChan = make(chan uint16, seqBuffer)
|
||||
conn.reqChan = make(chan *request, reqBuffer)
|
||||
@ -104,12 +115,6 @@ func (c *Conn) Close() {
|
||||
c.conn.Close()
|
||||
}
|
||||
|
||||
// DefaultScreen returns the Screen info for the default screen, which is
|
||||
// 0 or the one given in the display argument to Dial.
|
||||
func (c *Conn) DefaultScreen() *ScreenInfo {
|
||||
return &c.Setup.Roots[c.defaultScreen]
|
||||
}
|
||||
|
||||
// Event is an interface that can contain any of the events returned by the
|
||||
// server. Use a type assertion switch to extract the Event structs.
|
||||
type Event interface {
|
||||
@ -118,16 +123,20 @@ type Event interface {
|
||||
String() string
|
||||
}
|
||||
|
||||
type newEventFun func(buf []byte) Event
|
||||
// NewEventFun is the type of function use to construct events from raw bytes.
|
||||
// It should not be used. It is exported for use in the extension sub-packages.
|
||||
type NewEventFun func(buf []byte) Event
|
||||
|
||||
// newEventFuncs is a map from event numbers to functions that create
|
||||
// the corresponding event.
|
||||
var newEventFuncs = make(map[int]newEventFun)
|
||||
// NewEventFuncs is a map from event numbers to functions that create
|
||||
// the corresponding event. It should not be used. It is exported for use
|
||||
// in the extension sub-packages.
|
||||
var NewEventFuncs = make(map[int]NewEventFun)
|
||||
|
||||
// newExtEventFuncs is a temporary map that stores event constructor functions
|
||||
// NewExtEventFuncs is a temporary map that stores event constructor functions
|
||||
// for each extension. When an extension is initialized, each event for that
|
||||
// extension is added to the 'newEventFuncs' map.
|
||||
var newExtEventFuncs = make(map[string]map[int]newEventFun)
|
||||
// extension is added to the 'NewEventFuncs' map. It should not be used. It is
|
||||
// exported for use in the extension sub-packages.
|
||||
var NewExtEventFuncs = make(map[string]map[int]NewEventFun)
|
||||
|
||||
// Error is an interface that can contain any of the errors returned by
|
||||
// the server. Use a type assertion switch to extract the Error structs.
|
||||
@ -138,16 +147,20 @@ type Error interface {
|
||||
Error() string
|
||||
}
|
||||
|
||||
type newErrorFun func(buf []byte) Error
|
||||
// NewErrorFun is the type of function use to construct errors from raw bytes.
|
||||
// It should not be used. It is exported for use in the extension sub-packages.
|
||||
type NewErrorFun func(buf []byte) Error
|
||||
|
||||
// newErrorFuncs is a map from error numbers to functions that create
|
||||
// the corresponding error.
|
||||
var newErrorFuncs = make(map[int]newErrorFun)
|
||||
// NewErrorFuncs is a map from error numbers to functions that create
|
||||
// the corresponding error. It should not be used. It is exported for use in
|
||||
// the extension sub-packages.
|
||||
var NewErrorFuncs = make(map[int]NewErrorFun)
|
||||
|
||||
// newExtErrorFuncs is a temporary map that stores error constructor functions
|
||||
// NewExtErrorFuncs is a temporary map that stores error constructor functions
|
||||
// for each extension. When an extension is initialized, each error for that
|
||||
// extension is added to the 'newErrorFuncs' map.
|
||||
var newExtErrorFuncs = make(map[string]map[int]newErrorFun)
|
||||
// extension is added to the 'NewErrorFuncs' map. It should not be used. It is
|
||||
// exported for use in the extension sub-packages.
|
||||
var NewExtErrorFuncs = make(map[string]map[int]NewErrorFun)
|
||||
|
||||
// eventOrError corresponds to values that can be either an event or an
|
||||
// error.
|
||||
@ -194,8 +207,8 @@ func (conn *Conn) generateXIds() {
|
||||
// 00111000 & 11001000 = 00001000.
|
||||
// And we use that value to increment the last resource id to get a new one.
|
||||
// (And then, of course, we OR it with resource-id-base.)
|
||||
inc := conn.Setup.ResourceIdMask & -conn.Setup.ResourceIdMask
|
||||
max := conn.Setup.ResourceIdMask
|
||||
inc := conn.setupResourceIdMask & -conn.setupResourceIdMask
|
||||
max := conn.setupResourceIdMask
|
||||
last := uint32(0)
|
||||
for {
|
||||
// TODO: Use the XC Misc extension to look for released ids.
|
||||
@ -209,7 +222,7 @@ func (conn *Conn) generateXIds() {
|
||||
|
||||
last += inc
|
||||
conn.xidChan <- xid{
|
||||
id: last | conn.Setup.ResourceIdBase,
|
||||
id: last | conn.setupResourceIdBase,
|
||||
err: nil,
|
||||
}
|
||||
}
|
||||
@ -244,14 +257,14 @@ func (c *Conn) generateSeqIds() {
|
||||
// The cookie is used to match up the reply/error.
|
||||
type request struct {
|
||||
buf []byte
|
||||
cookie *cookie
|
||||
cookie *Cookie
|
||||
}
|
||||
|
||||
// newRequest takes the bytes an a cookie, constructs a request type,
|
||||
// NewRequest takes the bytes an a cookie, constructs a request type,
|
||||
// and sends it over the Conn.reqChan channel.
|
||||
// Note that the sequence number is added to the cookie after it is sent
|
||||
// over the request channel.
|
||||
func (c *Conn) newRequest(buf []byte, cookie *cookie) {
|
||||
func (c *Conn) NewRequest(buf []byte, cookie *Cookie) {
|
||||
c.reqChan <- &request{buf: buf, cookie: cookie}
|
||||
}
|
||||
|
||||
@ -264,11 +277,11 @@ func (c *Conn) sendRequests() {
|
||||
// Note that we circumvent the request channel, because we're *in*
|
||||
// the request channel.
|
||||
if len(c.cookieChan) == cookieBuffer-1 {
|
||||
cookie := c.newCookie(true, true)
|
||||
cookie := c.NewCookie(true, true)
|
||||
cookie.Sequence = c.newSequenceId()
|
||||
c.cookieChan <- cookie
|
||||
c.writeBuffer(c.getInputFocusRequest())
|
||||
GetInputFocusCookie{cookie}.Reply() // wait for the buffer to clear
|
||||
cookie.Reply() // wait for the buffer to clear
|
||||
}
|
||||
|
||||
req.cookie.Sequence = c.newSequenceId()
|
||||
@ -315,7 +328,7 @@ func (c *Conn) readResponses() {
|
||||
case 0: // This is an error
|
||||
// Use the constructor function for this error (that is auto
|
||||
// generated) by looking it up by the error number.
|
||||
newErrFun, ok := newErrorFuncs[int(buf[1])]
|
||||
newErrFun, ok := NewErrorFuncs[int(buf[1])]
|
||||
if !ok {
|
||||
logger.Printf("BUG: Could not find error constructor function "+
|
||||
"for error with number %d.", buf[1])
|
||||
@ -352,7 +365,7 @@ func (c *Conn) readResponses() {
|
||||
// the most significant bit (which is set when it was sent from
|
||||
// a SendEvent request).
|
||||
evNum := int(buf[0] & 127)
|
||||
newEventFun, ok := newEventFuncs[evNum]
|
||||
newEventFun, ok := NewEventFuncs[evNum]
|
||||
if !ok {
|
||||
logger.Printf("BUG: Could not find event construct function "+
|
||||
"for event with number %d.", evNum)
|
||||
|
@ -5,30 +5,30 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// stringsJoin is an alias to strings.Join. It allows us to avoid having to
|
||||
// StringsJoin is an alias to strings.Join. It allows us to avoid having to
|
||||
// import 'strings' in each of the generated Go files.
|
||||
func stringsJoin(ss []string, sep string) string {
|
||||
func StringsJoin(ss []string, sep string) string {
|
||||
return strings.Join(ss, sep)
|
||||
}
|
||||
|
||||
// sprintf is so we don't need to import 'fmt' in the generated Go files.
|
||||
func sprintf(format string, v ...interface{}) string {
|
||||
// Sprintf is so we don't need to import 'fmt' in the generated Go files.
|
||||
func Sprintf(format string, v ...interface{}) string {
|
||||
return fmt.Sprintf(format, v...)
|
||||
}
|
||||
|
||||
// errorf is just a wrapper for fmt.Errorf. Exists for the same reason
|
||||
// Errorf is just a wrapper for fmt.Errorf. Exists for the same reason
|
||||
// that 'stringsJoin' and 'sprintf' exists.
|
||||
func errorf(format string, v ...interface{}) error {
|
||||
func Errorf(format string, v ...interface{}) error {
|
||||
return fmt.Errorf(format, v...)
|
||||
}
|
||||
|
||||
// Pad a length to align on 4 bytes.
|
||||
func pad(n int) int {
|
||||
func Pad(n int) int {
|
||||
return (n + 3) & ^3
|
||||
}
|
||||
|
||||
// popCount counts the number of bits set in a value list mask.
|
||||
func popCount(mask0 int) int {
|
||||
func PopCount(mask0 int) int {
|
||||
mask := uint32(mask0)
|
||||
n := 0
|
||||
for i := uint32(0); i < 32; i++ {
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -49,10 +48,10 @@ func (c *Context) Morph(xmlBytes []byte) {
|
||||
parsedXml.Imports.Eval()
|
||||
|
||||
// Translate XML types to nice types
|
||||
c.protocol = parsedXml.Translate()
|
||||
c.protocol = parsedXml.Translate(nil)
|
||||
|
||||
// Start with Go header.
|
||||
c.Putln("package xgb")
|
||||
c.Putln("package %s", c.protocol.PkgName())
|
||||
c.Putln("")
|
||||
c.Putln("/*")
|
||||
c.Putln("\tThis file was generated by %s.xml on %s.",
|
||||
@ -61,44 +60,53 @@ func (c *Context) Morph(xmlBytes []byte) {
|
||||
c.Putln("*/")
|
||||
c.Putln("")
|
||||
|
||||
// Write imports in comments
|
||||
if len(c.protocol.Imports) > 0 {
|
||||
c.Putln("// Imports are not necessary for XGB because everything is ")
|
||||
c.Putln("// in one package. They are still listed here for reference.")
|
||||
for _, imp := range c.protocol.Imports {
|
||||
c.Putln("// import \"%s\"", imp.Name)
|
||||
}
|
||||
c.Putln("")
|
||||
// Write imports. We always need to import at least xgb.
|
||||
// We also need to import xproto if it's an extension.
|
||||
c.Putln("import (")
|
||||
c.Putln("\"github.com/BurntSushi/xgb\"")
|
||||
c.Putln("")
|
||||
if c.protocol.isExt() {
|
||||
c.Putln("\"github.com/BurntSushi/xgb/xproto\"")
|
||||
}
|
||||
for _, imp := range c.protocol.Imports {
|
||||
// We always import xproto, so skip it if it's explicitly imported
|
||||
if imp.Name == "xproto" {
|
||||
continue
|
||||
}
|
||||
c.Putln("\"github.com/BurntSushi/xgb/%s\"", imp.Name)
|
||||
}
|
||||
c.Putln(")")
|
||||
c.Putln("")
|
||||
|
||||
// If this is an extension, create a function to initialize the extension
|
||||
// before it can be used.
|
||||
if c.protocol.isExt() {
|
||||
name := strings.Title(c.protocol.Name) + "Init"
|
||||
xname := c.protocol.ExtXName
|
||||
|
||||
c.Putln("// %s must be called before using the %s extension.",
|
||||
name, xname)
|
||||
c.Putln("func (c *Conn) %s() error {", name)
|
||||
c.Putln("reply, err := c.QueryExtension(%d, \"%s\").Reply()",
|
||||
c.Putln("// Init must be called before using the %s extension.",
|
||||
xname)
|
||||
c.Putln("func Init(c *xgb.Conn) error {")
|
||||
c.Putln("reply, err := xproto.QueryExtension(c, %d, \"%s\").Reply()",
|
||||
len(xname), xname)
|
||||
c.Putln("switch {")
|
||||
c.Putln("case err != nil:")
|
||||
c.Putln("return err")
|
||||
c.Putln("case !reply.Present:")
|
||||
c.Putln("return errorf(\"No extension named %s could be found on "+
|
||||
c.Putln("return xgb.Errorf(\"No extension named %s could be found on "+
|
||||
"on the server.\")", xname)
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
c.Putln("c.extLock.Lock()")
|
||||
c.Putln("c.extensions[\"%s\"] = reply.MajorOpcode", xname)
|
||||
c.Putln("for evNum, fun := range newExtEventFuncs[\"%s\"] {", xname)
|
||||
c.Putln("newEventFuncs[int(reply.FirstEvent) + evNum] = fun")
|
||||
c.Putln("xgb.ExtLock.Lock()")
|
||||
c.Putln("c.Extensions[\"%s\"] = reply.MajorOpcode", xname)
|
||||
c.Putln("for evNum, fun := range xgb.NewExtEventFuncs[\"%s\"] {",
|
||||
xname)
|
||||
c.Putln("xgb.NewEventFuncs[int(reply.FirstEvent) + evNum] = fun")
|
||||
c.Putln("}")
|
||||
c.Putln("for errNum, fun := range newExtErrorFuncs[\"%s\"] {", xname)
|
||||
c.Putln("newErrorFuncs[int(reply.FirstError) + errNum] = fun")
|
||||
c.Putln("for errNum, fun := range xgb.NewExtErrorFuncs[\"%s\"] {",
|
||||
xname)
|
||||
c.Putln("xgb.NewErrorFuncs[int(reply.FirstError) + errNum] = fun")
|
||||
c.Putln("}")
|
||||
c.Putln("c.extLock.Unlock()")
|
||||
c.Putln("xgb.ExtLock.Unlock()")
|
||||
c.Putln("")
|
||||
c.Putln("return nil")
|
||||
c.Putln("}")
|
||||
@ -107,8 +115,26 @@ func (c *Context) Morph(xmlBytes []byte) {
|
||||
// Make sure newExtEventFuncs["EXT_NAME"] map is initialized.
|
||||
// Same deal for newExtErrorFuncs["EXT_NAME"]
|
||||
c.Putln("func init() {")
|
||||
c.Putln("newExtEventFuncs[\"%s\"] = make(map[int]newEventFun)", xname)
|
||||
c.Putln("newExtErrorFuncs[\"%s\"] = make(map[int]newErrorFun)", xname)
|
||||
c.Putln("xgb.NewExtEventFuncs[\"%s\"] = make(map[int]xgb.NewEventFun)",
|
||||
xname)
|
||||
c.Putln("xgb.NewExtErrorFuncs[\"%s\"] = make(map[int]xgb.NewErrorFun)",
|
||||
xname)
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
} else {
|
||||
// In the xproto package, we must provide a Setup function that uses
|
||||
// SetupBytes in xgb.Conn to return a SetupInfo structure.
|
||||
c.Putln("// Setup parses the setup bytes retrieved when")
|
||||
c.Putln("// connecting into a SetupInfo struct.")
|
||||
c.Putln("func Setup(c *xgb.Conn) *SetupInfo {")
|
||||
c.Putln("setup := new(SetupInfo)")
|
||||
c.Putln("SetupInfoRead(c.SetupBytes, setup)")
|
||||
c.Putln("return setup")
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
c.Putln("// DefaultScreen gets the default screen info from SetupInfo.")
|
||||
c.Putln("func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo {")
|
||||
c.Putln("return &s.Roots[c.DefaultScreen]")
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ func (e *Padding) Reduce(prefix string) string {
|
||||
if e.Concrete() {
|
||||
return fmt.Sprintf("%d", e.Eval())
|
||||
}
|
||||
return fmt.Sprintf("pad(%s)", e.Expr.Reduce(prefix))
|
||||
return fmt.Sprintf("xgb.Pad(%s)", e.Expr.Reduce(prefix))
|
||||
}
|
||||
|
||||
func (e *Padding) String() string {
|
||||
@ -233,7 +233,7 @@ func (e *PopCount) Reduce(prefix string) string {
|
||||
if e.Concrete() {
|
||||
return fmt.Sprintf("%d", e.Eval())
|
||||
}
|
||||
return fmt.Sprintf("popCount(%s)", e.Expr.Reduce(prefix))
|
||||
return fmt.Sprintf("xgb.PopCount(%s)", e.Expr.Reduce(prefix))
|
||||
}
|
||||
|
||||
func (e *PopCount) String() string {
|
||||
|
@ -245,7 +245,7 @@ func (f *ValueField) SrcType() string {
|
||||
func (f *ValueField) Size() Size {
|
||||
maskSize := f.MaskType.Size()
|
||||
listSize := newExpressionSize(&Function{
|
||||
Name: "pad",
|
||||
Name: "xgb.Pad",
|
||||
Expr: &BinaryOp{
|
||||
Op: "*",
|
||||
Expr1: &Value{v: 4},
|
||||
|
@ -82,7 +82,7 @@ func (enum *Enum) Define(c *Context) {
|
||||
func (res *Resource) Define(c *Context) {
|
||||
c.Putln("type %s uint32", res.SrcName())
|
||||
c.Putln("")
|
||||
c.Putln("func (c *Conn) New%sId() (%s, error) {",
|
||||
c.Putln("func New%sId(c *xgb.Conn) (%s, error) {",
|
||||
res.SrcName(), res.SrcName())
|
||||
c.Putln("id, err := c.NewId()")
|
||||
c.Putln("if err != nil {")
|
||||
@ -167,10 +167,10 @@ func (f *ValueField) Read(c *Context, prefix string) {
|
||||
c.Putln("%s%s = make([]uint32, %s)",
|
||||
prefix, f.ListName, f.ListLength().Reduce(prefix))
|
||||
c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix))
|
||||
c.Putln("%s%s[i] = Get32(buf[b:])", prefix, f.ListName)
|
||||
c.Putln("%s%s[i] = xgb.Get32(buf[b:])", prefix, f.ListName)
|
||||
c.Putln("b += 4")
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
}
|
||||
|
||||
func (f *ValueField) Write(c *Context, prefix string) {
|
||||
@ -180,10 +180,10 @@ func (f *ValueField) Write(c *Context, prefix string) {
|
||||
fmt.Sprintf("%s%s", prefix, f.MaskName), f.MaskType)
|
||||
}
|
||||
c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix))
|
||||
c.Putln("Put32(buf[b:], %s%s[i])", prefix, f.ListName)
|
||||
c.Putln("xgb.Put32(buf[b:], %s%s[i])", prefix, f.ListName)
|
||||
c.Putln("b += 4")
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
}
|
||||
|
||||
// Switch field
|
||||
|
@ -30,10 +30,10 @@ func (e *Error) Define(c *Context) {
|
||||
// Let's the XGB event loop read this error.
|
||||
c.Putln("func init() {")
|
||||
if c.protocol.isExt() {
|
||||
c.Putln("newExtErrorFuncs[\"%s\"][%d] = New%s",
|
||||
c.Putln("xgb.NewExtErrorFuncs[\"%s\"][%d] = %sNew",
|
||||
c.protocol.ExtXName, e.Number, e.ErrType())
|
||||
} else {
|
||||
c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.ErrType())
|
||||
c.Putln("xgb.NewErrorFuncs[%d] = %sNew", e.Number, e.ErrType())
|
||||
}
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
@ -41,14 +41,14 @@ func (e *Error) Define(c *Context) {
|
||||
|
||||
func (e *Error) Read(c *Context) {
|
||||
c.Putln("// Error read %s", e.SrcName())
|
||||
c.Putln("func New%s(buf []byte) Error {", e.ErrType())
|
||||
c.Putln("func %sNew(buf []byte) xgb.Error {", e.ErrType())
|
||||
c.Putln("v := %s{}", e.ErrType())
|
||||
c.Putln("v.NiceName = \"%s\"", e.SrcName())
|
||||
c.Putln("")
|
||||
c.Putln("b := 1 // skip error determinant")
|
||||
c.Putln("b += 1 // don't read error number")
|
||||
c.Putln("")
|
||||
c.Putln("v.Sequence = Get16(buf[b:])")
|
||||
c.Putln("v.Sequence = xgb.Get16(buf[b:])")
|
||||
c.Putln("b += 2")
|
||||
c.Putln("")
|
||||
for _, field := range e.Fields {
|
||||
@ -101,18 +101,18 @@ func (e *ErrorCopy) Define(c *Context) {
|
||||
// Let's the XGB know how to read this error.
|
||||
c.Putln("func init() {")
|
||||
if c.protocol.isExt() {
|
||||
c.Putln("newExtErrorFuncs[\"%s\"][%d] = New%s",
|
||||
c.Putln("xgb.NewExtErrorFuncs[\"%s\"][%d] = %sNew",
|
||||
c.protocol.ExtXName, e.Number, e.ErrType())
|
||||
} else {
|
||||
c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.ErrType())
|
||||
c.Putln("xgb.NewErrorFuncs[%d] = %sNew", e.Number, e.ErrType())
|
||||
}
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
}
|
||||
|
||||
func (e *ErrorCopy) Read(c *Context) {
|
||||
c.Putln("func New%s(buf []byte) Error {", e.ErrType())
|
||||
c.Putln("v := %s(New%s(buf).(%s))",
|
||||
c.Putln("func %sNew(buf []byte) xgb.Error {", e.ErrType())
|
||||
c.Putln("v := %s(%sNew(buf).(%s))",
|
||||
e.ErrType(), e.Old.(*Error).ErrType(), e.Old.(*Error).ErrType())
|
||||
c.Putln("v.NiceName = \"%s\"", e.SrcName())
|
||||
c.Putln("return v")
|
||||
@ -148,7 +148,7 @@ func ErrorFieldString(c *Context, fields []Field, errName string) {
|
||||
c.Putln("fieldVals := make([]string, 0, %d)", len(fields))
|
||||
c.Putln("fieldVals = append(fieldVals, \"NiceName: \" + err.NiceName)")
|
||||
c.Putln("fieldVals = append(fieldVals, "+
|
||||
"sprintf(\"Sequence: %s\", err.Sequence))", "%d")
|
||||
"xgb.Sprintf(\"Sequence: %s\", err.Sequence))", "%d")
|
||||
for _, field := range fields {
|
||||
switch field.(type) {
|
||||
case *PadField:
|
||||
@ -158,11 +158,12 @@ func ErrorFieldString(c *Context, fields []Field, errName string) {
|
||||
c.Putln("fieldVals = append(fieldVals, \"%s: \" + err.%s)",
|
||||
field.SrcName(), field.SrcName())
|
||||
} else {
|
||||
format := fmt.Sprintf("sprintf(\"%s: %s\", err.%s)",
|
||||
format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", err.%s)",
|
||||
field.SrcName(), "%d", field.SrcName())
|
||||
c.Putln("fieldVals = append(fieldVals, %s)", format)
|
||||
}
|
||||
}
|
||||
}
|
||||
c.Putln("return \"%s {\" + stringsJoin(fieldVals, \", \") + \"}\"", errName)
|
||||
c.Putln("return \"%s {\" + xgb.StringsJoin(fieldVals, \", \") + \"}\"",
|
||||
errName)
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ func (e *Event) Define(c *Context) {
|
||||
// Let's the XGB event loop read this event.
|
||||
c.Putln("func init() {")
|
||||
if c.protocol.isExt() {
|
||||
c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s",
|
||||
c.Putln("xgb.NewExtEventFuncs[\"%s\"][%d] = %sNew",
|
||||
c.protocol.ExtXName, e.Number, e.EvType())
|
||||
} else {
|
||||
c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType())
|
||||
c.Putln("xgb.NewEventFuncs[%d] = %sNew", e.Number, e.EvType())
|
||||
}
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
@ -59,13 +59,13 @@ func (e *Event) Define(c *Context) {
|
||||
|
||||
func (e *Event) Read(c *Context) {
|
||||
c.Putln("// Event read %s", e.SrcName())
|
||||
c.Putln("func New%s(buf []byte) Event {", e.EvType())
|
||||
c.Putln("func %sNew(buf []byte) xgb.Event {", e.EvType())
|
||||
c.Putln("v := %s{}", e.EvType())
|
||||
c.Putln("b := 1 // don't read event number")
|
||||
c.Putln("")
|
||||
for i, field := range e.Fields {
|
||||
if i == 1 && !e.NoSequence {
|
||||
c.Putln("v.Sequence = Get16(buf[b:])")
|
||||
c.Putln("v.Sequence = xgb.Get16(buf[b:])")
|
||||
c.Putln("b += 2")
|
||||
c.Putln("")
|
||||
}
|
||||
@ -136,18 +136,18 @@ func (e *EventCopy) Define(c *Context) {
|
||||
// Let's the XGB event loop read this event.
|
||||
c.Putln("func init() {")
|
||||
if c.protocol.isExt() {
|
||||
c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s",
|
||||
c.Putln("xgb.NewExtEventFuncs[\"%s\"][%d] = %sNew",
|
||||
c.protocol.ExtXName, e.Number, e.EvType())
|
||||
} else {
|
||||
c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType())
|
||||
c.Putln("xgb.NewEventFuncs[%d] = %sNew", e.Number, e.EvType())
|
||||
}
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
}
|
||||
|
||||
func (e *EventCopy) Read(c *Context) {
|
||||
c.Putln("func New%s(buf []byte) Event {", e.EvType())
|
||||
c.Putln("return %s(New%s(buf).(%s))",
|
||||
c.Putln("func %sNew(buf []byte) xgb.Event {", e.EvType())
|
||||
c.Putln("return %s(%sNew(buf).(%s))",
|
||||
e.EvType(), e.Old.(*Event).EvType(), e.Old.(*Event).EvType())
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
@ -166,7 +166,7 @@ func EventFieldString(c *Context, fields []Field, evName string) {
|
||||
c.Putln("fieldVals := make([]string, 0, %d)", len(fields))
|
||||
if evName != "KeymapNotify" {
|
||||
c.Putln("fieldVals = append(fieldVals, "+
|
||||
"sprintf(\"Sequence: %s\", v.Sequence))", "%d")
|
||||
"xgb.Sprintf(\"Sequence: %s\", v.Sequence))", "%d")
|
||||
}
|
||||
for _, field := range fields {
|
||||
switch f := field.(type) {
|
||||
@ -183,19 +183,20 @@ func EventFieldString(c *Context, fields []Field, evName string) {
|
||||
|
||||
switch field.SrcType() {
|
||||
case "string":
|
||||
format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)",
|
||||
format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", v.%s)",
|
||||
field.SrcName(), "%s", field.SrcName())
|
||||
c.Putln("fieldVals = append(fieldVals, %s)", format)
|
||||
case "bool":
|
||||
format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)",
|
||||
format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", v.%s)",
|
||||
field.SrcName(), "%t", field.SrcName())
|
||||
c.Putln("fieldVals = append(fieldVals, %s)", format)
|
||||
default:
|
||||
format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)",
|
||||
format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", v.%s)",
|
||||
field.SrcName(), "%d", field.SrcName())
|
||||
c.Putln("fieldVals = append(fieldVals, %s)", format)
|
||||
}
|
||||
}
|
||||
}
|
||||
c.Putln("return \"%s {\" + stringsJoin(fieldVals, \", \") + \"}\"", evName)
|
||||
c.Putln("return \"%s {\" + xgb.StringsJoin(fieldVals, \", \") + \"}\"",
|
||||
evName)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ func (f *ListField) Read(c *Context, prefix string) {
|
||||
c.Putln("for i := 0; i < int(%s); i++ {", length)
|
||||
ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t)
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
case *Base:
|
||||
length := f.LengthExpr.Reduce(prefix)
|
||||
if strings.ToLower(t.XmlName()) == "char" {
|
||||
@ -29,13 +29,13 @@ func (f *ListField) Read(c *Context, prefix string) {
|
||||
c.Putln("byteString := make([]%s, %s)", t.SrcName(), length)
|
||||
c.Putln("copy(byteString[:%s], buf[b:])", length)
|
||||
c.Putln("%s%s = string(byteString)", prefix, f.SrcName())
|
||||
c.Putln("b += pad(int(%s))", length)
|
||||
c.Putln("b += xgb.Pad(int(%s))", length)
|
||||
c.Putln("}")
|
||||
} else if t.SrcName() == "byte" {
|
||||
c.Putln("%s%s = make([]%s, %s)",
|
||||
prefix, f.SrcName(), t.SrcName(), length)
|
||||
c.Putln("copy(%s%s[:%s], buf[b:])", prefix, f.SrcName(), length)
|
||||
c.Putln("b += pad(int(%s))", length)
|
||||
c.Putln("b += xgb.Pad(int(%s))", length)
|
||||
} else {
|
||||
c.Putln("%s%s = make([]%s, %s)",
|
||||
prefix, f.SrcName(), t.SrcName(), length)
|
||||
@ -43,7 +43,7 @@ func (f *ListField) Read(c *Context, prefix string) {
|
||||
ReadSimpleSingleField(c,
|
||||
fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t)
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
}
|
||||
case *TypeDef:
|
||||
length := f.LengthExpr.Reduce(prefix)
|
||||
@ -52,16 +52,16 @@ func (f *ListField) Read(c *Context, prefix string) {
|
||||
c.Putln("for i := 0; i < int(%s); i++ {", length)
|
||||
ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t)
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
case *Union:
|
||||
c.Putln("%s%s = make([]%s, %s)",
|
||||
prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix))
|
||||
c.Putln("b += Read%sList(buf[b:], %s%s)",
|
||||
c.Putln("b += %sReadList(buf[b:], %s%s)",
|
||||
t.SrcName(), prefix, f.SrcName())
|
||||
case *Struct:
|
||||
c.Putln("%s%s = make([]%s, %s)",
|
||||
prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix))
|
||||
c.Putln("b += Read%sList(buf[b:], %s%s)",
|
||||
c.Putln("b += %sReadList(buf[b:], %s%s)",
|
||||
t.SrcName(), prefix, f.SrcName())
|
||||
default:
|
||||
log.Panicf("Cannot read list field '%s' with %T type.",
|
||||
@ -77,18 +77,18 @@ func (f *ListField) Write(c *Context, prefix string) {
|
||||
WriteSimpleSingleField(c,
|
||||
fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t)
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
case *Base:
|
||||
length := f.Length().Reduce(prefix)
|
||||
if t.SrcName() == "byte" {
|
||||
c.Putln("copy(buf[b:], %s%s[:%s])", prefix, f.SrcName(), length)
|
||||
c.Putln("b += pad(int(%s))", length)
|
||||
c.Putln("b += xgb.Pad(int(%s))", length)
|
||||
} else {
|
||||
c.Putln("for i := 0; i < int(%s); i++ {", length)
|
||||
WriteSimpleSingleField(c,
|
||||
fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t)
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
}
|
||||
case *TypeDef:
|
||||
length := f.Length().Reduce(prefix)
|
||||
@ -96,7 +96,7 @@ func (f *ListField) Write(c *Context, prefix string) {
|
||||
WriteSimpleSingleField(c,
|
||||
fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t)
|
||||
c.Putln("}")
|
||||
c.Putln("b = pad(b)")
|
||||
c.Putln("b = xgb.Pad(b)")
|
||||
case *Union:
|
||||
c.Putln("b += %sListBytes(buf[b:], %s%s)",
|
||||
t.SrcName(), prefix, f.SrcName())
|
||||
|
@ -9,22 +9,22 @@ func (r *Request) Define(c *Context) {
|
||||
c.Putln("// Request %s", r.SrcName())
|
||||
c.Putln("// size: %s", r.Size(c))
|
||||
c.Putln("type %s struct {", r.CookieName())
|
||||
c.Putln("*cookie")
|
||||
c.Putln("*xgb.Cookie")
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
if r.Reply != nil {
|
||||
c.Putln("func (c *Conn) %s(%s) %s {",
|
||||
c.Putln("func %s(c *xgb.Conn, %s) %s {",
|
||||
r.SrcName(), r.ParamNameTypes(), r.CookieName())
|
||||
c.Putln("cookie := c.newCookie(true, true)")
|
||||
c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("cookie := c.NewCookie(true, true)")
|
||||
c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("return %s{cookie}", r.CookieName())
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
|
||||
c.Putln("func (c *Conn) %sUnchecked(%s) %s {",
|
||||
c.Putln("func %sUnchecked(c *xgb.Conn, %s) %s {",
|
||||
r.SrcName(), r.ParamNameTypes(), r.CookieName())
|
||||
c.Putln("cookie := c.newCookie(false, true)")
|
||||
c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("cookie := c.NewCookie(false, true)")
|
||||
c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("return %s{cookie}", r.CookieName())
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
@ -32,27 +32,27 @@ func (r *Request) Define(c *Context) {
|
||||
r.ReadReply(c)
|
||||
} else {
|
||||
c.Putln("// Write request to wire for %s", r.SrcName())
|
||||
c.Putln("func (c *Conn) %s(%s) %s {",
|
||||
c.Putln("func %s(c *xgb.Conn, %s) %s {",
|
||||
r.SrcName(), r.ParamNameTypes(), r.CookieName())
|
||||
c.Putln("cookie := c.newCookie(false, false)")
|
||||
c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("cookie := c.NewCookie(false, false)")
|
||||
c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("return %s{cookie}", r.CookieName())
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
|
||||
c.Putln("func (c *Conn) %sChecked(%s) %s {",
|
||||
c.Putln("func %sChecked(c *xgb.Conn, %s) %s {",
|
||||
r.SrcName(), r.ParamNameTypes(), r.CookieName())
|
||||
c.Putln("cookie := c.newCookie(true, false)")
|
||||
c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("cookie := c.NewCookie(true, false)")
|
||||
c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames())
|
||||
c.Putln("return %s{cookie}", r.CookieName())
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
|
||||
c.Putln("func (cook %s) Check() error {", r.CookieName())
|
||||
c.Putln("return cook.Cookie.Check()")
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
}
|
||||
|
||||
c.Putln("func (cook %s) Check() error {", r.CookieName())
|
||||
c.Putln("return cook.check()")
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
r.WriteRequest(c)
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ func (r *Request) ReadReply(c *Context) {
|
||||
c.Putln("// Waits and reads reply data from request %s", r.SrcName())
|
||||
c.Putln("func (cook %s) Reply() (*%s, error) {",
|
||||
r.CookieName(), r.ReplyTypeName())
|
||||
c.Putln("buf, err := cook.reply()")
|
||||
c.Putln("buf, err := cook.Cookie.Reply()")
|
||||
c.Putln("if err != nil {")
|
||||
c.Putln("return nil, err")
|
||||
c.Putln("}")
|
||||
@ -92,10 +92,10 @@ func (r *Request) ReadReply(c *Context) {
|
||||
field.Read(c, "v.")
|
||||
c.Putln("")
|
||||
if i == 0 {
|
||||
c.Putln("v.Sequence = Get16(buf[b:])")
|
||||
c.Putln("v.Sequence = xgb.Get16(buf[b:])")
|
||||
c.Putln("b += 2")
|
||||
c.Putln("")
|
||||
c.Putln("v.Length = Get32(buf[b:]) // 4-byte units")
|
||||
c.Putln("v.Length = xgb.Get32(buf[b:]) // 4-byte units")
|
||||
c.Putln("b += 4")
|
||||
c.Putln("")
|
||||
}
|
||||
@ -107,19 +107,20 @@ func (r *Request) ReadReply(c *Context) {
|
||||
|
||||
func (r *Request) WriteRequest(c *Context) {
|
||||
writeSize := func() {
|
||||
c.Putln("Put16(buf[b:], uint16(size / 4)) " +
|
||||
c.Putln("xgb.Put16(buf[b:], uint16(size / 4)) " +
|
||||
"// write request size in 4-byte units")
|
||||
c.Putln("b += 2")
|
||||
c.Putln("")
|
||||
}
|
||||
c.Putln("// Write request to wire for %s", r.SrcName())
|
||||
c.Putln("func (c *Conn) %s(%s) []byte {", r.ReqName(), r.ParamNameTypes())
|
||||
c.Putln("func %s(c *xgb.Conn, %s) []byte {",
|
||||
r.ReqName(), r.ParamNameTypes())
|
||||
c.Putln("size := %s", r.Size(c))
|
||||
c.Putln("b := 0")
|
||||
c.Putln("buf := make([]byte, size)")
|
||||
c.Putln("")
|
||||
if c.protocol.isExt() {
|
||||
c.Putln("buf[b] = c.extensions[\"%s\"]",
|
||||
c.Putln("buf[b] = c.Extensions[\"%s\"]",
|
||||
strings.ToUpper(c.protocol.ExtXName))
|
||||
c.Putln("b += 1")
|
||||
c.Putln("")
|
||||
@ -165,7 +166,7 @@ func (r *Request) ParamNames() string {
|
||||
names = append(names, fmt.Sprintf("%s", field.SrcName()))
|
||||
}
|
||||
}
|
||||
return strings.Join(names, ",")
|
||||
return strings.Join(names, ", ")
|
||||
}
|
||||
|
||||
func (r *Request) ParamNameTypes() string {
|
||||
@ -189,5 +190,5 @@ func (r *Request) ParamNameTypes() string {
|
||||
fmt.Sprintf("%s %s", field.SrcName(), field.SrcType()))
|
||||
}
|
||||
}
|
||||
return strings.Join(nameTypes, ",")
|
||||
return strings.Join(nameTypes, ", ")
|
||||
}
|
||||
|
@ -12,17 +12,17 @@ func (f *SingleField) Define(c *Context) {
|
||||
func ReadSimpleSingleField(c *Context, name string, typ Type) {
|
||||
switch t := typ.(type) {
|
||||
case *Resource:
|
||||
c.Putln("%s = %s(Get32(buf[b:]))", name, t.SrcName())
|
||||
c.Putln("%s = %s(xgb.Get32(buf[b:]))", name, t.SrcName())
|
||||
case *TypeDef:
|
||||
switch t.Size().Eval() {
|
||||
case 1:
|
||||
c.Putln("%s = %s(buf[b])", name, t.SrcName())
|
||||
case 2:
|
||||
c.Putln("%s = %s(Get16(buf[b:]))", name, t.SrcName())
|
||||
c.Putln("%s = %s(xgb.Get16(buf[b:]))", name, t.SrcName())
|
||||
case 4:
|
||||
c.Putln("%s = %s(Get32(buf[b:]))", name, t.SrcName())
|
||||
c.Putln("%s = %s(xgb.Get32(buf[b:]))", name, t.SrcName())
|
||||
case 8:
|
||||
c.Putln("%s = %s(Get64(buf[b:]))", name, t.SrcName())
|
||||
c.Putln("%s = %s(xgb.Get64(buf[b:]))", name, t.SrcName())
|
||||
}
|
||||
case *Base:
|
||||
// If this is a bool, stop short and do something special.
|
||||
@ -40,11 +40,11 @@ func ReadSimpleSingleField(c *Context, name string, typ Type) {
|
||||
case 1:
|
||||
val = fmt.Sprintf("buf[b]")
|
||||
case 2:
|
||||
val = fmt.Sprintf("Get16(buf[b:])")
|
||||
val = fmt.Sprintf("xgb.Get16(buf[b:])")
|
||||
case 4:
|
||||
val = fmt.Sprintf("Get32(buf[b:])")
|
||||
val = fmt.Sprintf("xgb.Get32(buf[b:])")
|
||||
case 8:
|
||||
val = fmt.Sprintf("Get64(buf[b:])")
|
||||
val = fmt.Sprintf("xgb.Get64(buf[b:])")
|
||||
}
|
||||
|
||||
// We need to convert base types if they aren't uintXX or byte
|
||||
@ -71,10 +71,10 @@ func (f *SingleField) Read(c *Context, prefix string) {
|
||||
ReadSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t)
|
||||
case *Struct:
|
||||
c.Putln("%s%s = %s{}", prefix, f.SrcName(), t.SrcName())
|
||||
c.Putln("b += Read%s(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName())
|
||||
c.Putln("b += %sRead(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName())
|
||||
case *Union:
|
||||
c.Putln("%s%s = %s{}", prefix, f.SrcName(), t.SrcName())
|
||||
c.Putln("b += Read%s(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName())
|
||||
c.Putln("b += %sRead(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName())
|
||||
default:
|
||||
log.Panicf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type)
|
||||
}
|
||||
@ -83,17 +83,17 @@ func (f *SingleField) Read(c *Context, prefix string) {
|
||||
func WriteSimpleSingleField(c *Context, name string, typ Type) {
|
||||
switch t := typ.(type) {
|
||||
case *Resource:
|
||||
c.Putln("Put32(buf[b:], uint32(%s))", name)
|
||||
c.Putln("xgb.Put32(buf[b:], uint32(%s))", name)
|
||||
case *TypeDef:
|
||||
switch t.Size().Eval() {
|
||||
case 1:
|
||||
c.Putln("buf[b] = byte(%s)", name)
|
||||
case 2:
|
||||
c.Putln("Put16(buf[b:], uint16(%s))", name)
|
||||
c.Putln("xgb.Put16(buf[b:], uint16(%s))", name)
|
||||
case 4:
|
||||
c.Putln("Put32(buf[b:], uint32(%s))", name)
|
||||
c.Putln("xgb.Put32(buf[b:], uint32(%s))", name)
|
||||
case 8:
|
||||
c.Putln("Put64(buf[b:], uint64(%s))", name)
|
||||
c.Putln("xgb.Put64(buf[b:], uint64(%s))", name)
|
||||
}
|
||||
case *Base:
|
||||
// If this is a bool, stop short and do something special.
|
||||
@ -115,21 +115,21 @@ func WriteSimpleSingleField(c *Context, name string, typ Type) {
|
||||
}
|
||||
case 2:
|
||||
if t.SrcName() != "uint16" {
|
||||
c.Putln("Put16(buf[b:], uint16(%s))", name)
|
||||
c.Putln("xgb.Put16(buf[b:], uint16(%s))", name)
|
||||
} else {
|
||||
c.Putln("Put16(buf[b:], %s)", name)
|
||||
c.Putln("xgb.Put16(buf[b:], %s)", name)
|
||||
}
|
||||
case 4:
|
||||
if t.SrcName() != "uint32" {
|
||||
c.Putln("Put32(buf[b:], uint32(%s))", name)
|
||||
c.Putln("xgb.Put32(buf[b:], uint32(%s))", name)
|
||||
} else {
|
||||
c.Putln("Put32(buf[b:], %s)", name)
|
||||
c.Putln("xgb.Put32(buf[b:], %s)", name)
|
||||
}
|
||||
case 8:
|
||||
if t.SrcName() != "uint64" {
|
||||
c.Putln("Put64(buf[b:], uint64(%s))", name)
|
||||
c.Putln("xgb.Put64(buf[b:], uint64(%s))", name)
|
||||
} else {
|
||||
c.Putln("Put64(buf[b:], %s)", name)
|
||||
c.Putln("xgb.Put64(buf[b:], %s)", name)
|
||||
}
|
||||
}
|
||||
default:
|
||||
@ -152,13 +152,13 @@ func (f *SingleField) Write(c *Context, prefix string) {
|
||||
c.Putln("{")
|
||||
c.Putln("unionBytes := %s%s.Bytes()", prefix, f.SrcName())
|
||||
c.Putln("copy(buf[b:], unionBytes)")
|
||||
c.Putln("b += pad(len(unionBytes))")
|
||||
c.Putln("b += xgb.Pad(len(unionBytes))")
|
||||
c.Putln("}")
|
||||
case *Struct:
|
||||
c.Putln("{")
|
||||
c.Putln("structBytes := %s%s.Bytes()", prefix, f.SrcName())
|
||||
c.Putln("copy(buf[b:], structBytes)")
|
||||
c.Putln("b += pad(len(structBytes))")
|
||||
c.Putln("b += xgb.Pad(len(structBytes))")
|
||||
c.Putln("}")
|
||||
default:
|
||||
log.Fatalf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type)
|
||||
|
@ -35,7 +35,7 @@ func (s *Struct) Define(c *Context) {
|
||||
// 'ReadStructName' should only be used to read raw reply data from the wire.
|
||||
func (s *Struct) Read(c *Context) {
|
||||
c.Putln("// Struct read %s", s.SrcName())
|
||||
c.Putln("func Read%s(buf []byte, v *%s) int {", s.SrcName(), s.SrcName())
|
||||
c.Putln("func %sRead(buf []byte, v *%s) int {", s.SrcName(), s.SrcName())
|
||||
|
||||
c.Putln("b := 0")
|
||||
c.Putln("")
|
||||
@ -54,16 +54,16 @@ func (s *Struct) Read(c *Context) {
|
||||
// the number of bytes read from the byte slice.
|
||||
func (s *Struct) ReadList(c *Context) {
|
||||
c.Putln("// Struct list read %s", s.SrcName())
|
||||
c.Putln("func Read%sList(buf []byte, dest []%s) int {",
|
||||
c.Putln("func %sReadList(buf []byte, dest []%s) int {",
|
||||
s.SrcName(), s.SrcName())
|
||||
|
||||
c.Putln("b := 0")
|
||||
c.Putln("for i := 0; i < len(dest); i++ {")
|
||||
c.Putln("dest[i] = %s{}", s.SrcName())
|
||||
c.Putln("b += Read%s(buf[b:], &dest[i])", s.SrcName())
|
||||
c.Putln("b += %sRead(buf[b:], &dest[i])", s.SrcName())
|
||||
c.Putln("}")
|
||||
|
||||
c.Putln("return pad(b)")
|
||||
c.Putln("return xgb.Pad(b)")
|
||||
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
@ -93,7 +93,7 @@ func (s *Struct) WriteList(c *Context) {
|
||||
c.Putln("for _, item := range list {")
|
||||
c.Putln("structBytes = item.Bytes()")
|
||||
c.Putln("copy(buf[b:], structBytes)")
|
||||
c.Putln("b += pad(len(structBytes))")
|
||||
c.Putln("b += xgb.Pad(len(structBytes))")
|
||||
c.Putln("}")
|
||||
c.Putln("return b")
|
||||
c.Putln("}")
|
||||
|
@ -8,7 +8,7 @@ func (u *Union) Define(c *Context) {
|
||||
c.Putln("// Instead use one of the following constructors for '%s':",
|
||||
u.SrcName())
|
||||
for _, field := range u.Fields {
|
||||
c.Putln("// New%s%s(%s %s) %s", u.SrcName(), field.SrcName(),
|
||||
c.Putln("// %s%sNew(%s %s) %s", u.SrcName(), field.SrcName(),
|
||||
field.SrcName(), field.SrcType(), u.SrcName())
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ func (u *Union) New(c *Context) {
|
||||
for _, field := range u.Fields {
|
||||
c.Putln("// Union constructor for %s for field %s.",
|
||||
u.SrcName(), field.SrcName())
|
||||
c.Putln("func New%s%s(%s %s) %s {",
|
||||
c.Putln("func %s%sNew(%s %s) %s {",
|
||||
u.SrcName(), field.SrcName(), field.SrcName(),
|
||||
field.SrcType(), u.SrcName())
|
||||
c.Putln("var b int")
|
||||
@ -66,7 +66,7 @@ func (u *Union) New(c *Context) {
|
||||
|
||||
func (u *Union) Read(c *Context) {
|
||||
c.Putln("// Union read %s", u.SrcName())
|
||||
c.Putln("func Read%s(buf []byte, v *%s) int {", u.SrcName(), u.SrcName())
|
||||
c.Putln("func %sRead(buf []byte, v *%s) int {", u.SrcName(), u.SrcName())
|
||||
c.Putln("var b int")
|
||||
c.Putln("")
|
||||
for _, field := range u.Fields {
|
||||
@ -81,14 +81,14 @@ func (u *Union) Read(c *Context) {
|
||||
|
||||
func (u *Union) ReadList(c *Context) {
|
||||
c.Putln("// Union list read %s", u.SrcName())
|
||||
c.Putln("func Read%sList(buf []byte, dest []%s) int {",
|
||||
c.Putln("func %sReadList(buf []byte, dest []%s) int {",
|
||||
u.SrcName(), u.SrcName())
|
||||
c.Putln("b := 0")
|
||||
c.Putln("for i := 0; i < len(dest); i++ {")
|
||||
c.Putln("dest[i] = %s{}", u.SrcName())
|
||||
c.Putln("b += Read%s(buf[b:], &dest[i])", u.SrcName())
|
||||
c.Putln("b += %sRead(buf[b:], &dest[i])", u.SrcName())
|
||||
c.Putln("}")
|
||||
c.Putln("return pad(b)")
|
||||
c.Putln("return xgb.Pad(b)")
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
}
|
||||
@ -121,7 +121,7 @@ func (u *Union) WriteList(c *Context) {
|
||||
c.Putln("for _, item := range list {")
|
||||
c.Putln("unionBytes = item.Bytes()")
|
||||
c.Putln("copy(buf[b:], unionBytes)")
|
||||
c.Putln("b += pad(len(unionBytes))")
|
||||
c.Putln("b += xgb.Pad(len(unionBytes))")
|
||||
c.Putln("}")
|
||||
c.Putln("return b")
|
||||
c.Putln("}")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -9,6 +10,7 @@ import (
|
||||
// if this protocol imports other other extensions. The import relationship
|
||||
// is recursive.
|
||||
type Protocol struct {
|
||||
Parent *Protocol
|
||||
Name string
|
||||
ExtXName string
|
||||
ExtName string
|
||||
@ -33,6 +35,28 @@ func (p *Protocol) Initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
// PkgName returns the name of this package.
|
||||
// i.e., 'xproto' for the core X protocol, 'randr' for the RandR extension, etc.
|
||||
func (p *Protocol) PkgName() string {
|
||||
return strings.Replace(p.Name, "_", "", -1)
|
||||
}
|
||||
|
||||
// ProtocolGet searches the current context for the protocol with the given
|
||||
// name. (i.e., the current protocol and its imports.)
|
||||
// It is an error if one is not found.
|
||||
func (p *Protocol) ProtocolFind(name string) *Protocol {
|
||||
if p.Name == name {
|
||||
return p // that was easy
|
||||
}
|
||||
for _, imp := range p.Imports {
|
||||
if imp.Name == name {
|
||||
return imp
|
||||
}
|
||||
}
|
||||
log.Panicf("Could not find protocol with name '%s'.", name)
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
// isExt returns true if this protocol is an extension.
|
||||
// i.e., it's name isn't "xproto".
|
||||
func (p *Protocol) isExt() bool {
|
||||
|
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
@ -23,7 +22,7 @@ type Request struct {
|
||||
func (r *Request) Initialize(p *Protocol) {
|
||||
r.srcName = SrcName(p, r.xmlName)
|
||||
if p.isExt() {
|
||||
r.srcName = strings.Title(strings.ToLower(p.Name)) + r.srcName
|
||||
r.srcName = r.srcName
|
||||
}
|
||||
|
||||
if r.Reply != nil {
|
||||
|
@ -18,8 +18,9 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (xml *XML) Translate() *Protocol {
|
||||
func (xml *XML) Translate(parent *Protocol) *Protocol {
|
||||
protocol := &Protocol{
|
||||
Parent: parent,
|
||||
Name: xml.Header,
|
||||
ExtXName: xml.ExtensionXName,
|
||||
ExtName: xml.ExtensionName,
|
||||
@ -33,7 +34,8 @@ func (xml *XML) Translate() *Protocol {
|
||||
|
||||
for _, imp := range xml.Imports {
|
||||
if imp.xml != nil {
|
||||
protocol.Imports = append(protocol.Imports, imp.xml.Translate())
|
||||
protocol.Imports = append(protocol.Imports,
|
||||
imp.xml.Translate(protocol))
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,7 +211,7 @@ func (x *XMLRequest) Translate() *Request {
|
||||
// The XML protocol description references 'string_len' in the
|
||||
// computation of the 'odd_length' field. However, 'string_len' is not
|
||||
// defined. Therefore, let's forcefully add it as a 'local field'.
|
||||
// (i.e., a parameter in the caller but does not get send over the wire.)
|
||||
// (i.e., a parameter in the caller but does not get sent over the wire.)
|
||||
if x.Name == "QueryTextExtents" {
|
||||
stringLenLocal := &LocalField{&SingleField{
|
||||
xmlName: "string_len",
|
||||
@ -399,27 +401,15 @@ func TypeSrcName(p *Protocol, typ Type) string {
|
||||
if colon := strings.Index(t, ":"); colon > -1 {
|
||||
namespace := t[:colon]
|
||||
rest := t[colon+1:]
|
||||
return splitAndTitle(namespace) + splitAndTitle(rest)
|
||||
return p.ProtocolFind(namespace).PkgName() + "." + splitAndTitle(rest)
|
||||
}
|
||||
|
||||
// Since there is no namespace, we need to look for a namespace
|
||||
// in the current context.
|
||||
niceType := splitAndTitle(t)
|
||||
if p.isExt() {
|
||||
for _, typ2 := range p.Types {
|
||||
if t == typ2.XmlName() {
|
||||
return strings.Title(p.Name) + niceType
|
||||
}
|
||||
}
|
||||
for _, imp := range p.Imports {
|
||||
for _, typ2 := range imp.Types {
|
||||
if t == typ2.XmlName() {
|
||||
return strings.Title(imp.Name) + niceType
|
||||
}
|
||||
}
|
||||
}
|
||||
// Since there's no namespace, we're left with the raw type name.
|
||||
// If the type is part of the source we're generating (i.e., there is
|
||||
// no parent protocol), then just return that type name.
|
||||
// Otherwise, we must qualify it with a package name.
|
||||
if p.Parent == nil {
|
||||
return splitAndTitle(t)
|
||||
}
|
||||
|
||||
// We couldn't find one, so return it without a prefix.
|
||||
return niceType
|
||||
return p.PkgName() + "." + splitAndTitle(t)
|
||||
}
|
||||
|
633
nexgb/xinerama/xinerama.go
Normal file
633
nexgb/xinerama/xinerama.go
Normal file
@ -0,0 +1,633 @@
|
||||
package xinerama
|
||||
|
||||
/*
|
||||
This file was generated by xinerama.xml on May 10 2012 4:20:28pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the XINERAMA extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 8, "XINERAMA").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named XINERAMA could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["XINERAMA"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["XINERAMA"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["XINERAMA"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["XINERAMA"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// 'ScreenInfo' struct definition
|
||||
// Size: 8
|
||||
type ScreenInfo struct {
|
||||
XOrg int16
|
||||
YOrg int16
|
||||
Width uint16
|
||||
Height uint16
|
||||
}
|
||||
|
||||
// Struct read ScreenInfo
|
||||
func ScreenInfoRead(buf []byte, v *ScreenInfo) int {
|
||||
b := 0
|
||||
|
||||
v.XOrg = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.YOrg = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.Width = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Height = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read ScreenInfo
|
||||
func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = ScreenInfo{}
|
||||
b += ScreenInfoRead(buf[b:], &dest[i])
|
||||
}
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
// Struct write ScreenInfo
|
||||
func (v ScreenInfo) Bytes() []byte {
|
||||
buf := make([]byte, 8)
|
||||
b := 0
|
||||
|
||||
xgb.Put16(buf[b:], uint16(v.XOrg))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(v.YOrg))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.Width)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.Height)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list ScreenInfo
|
||||
func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 8
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c, Major, Minor), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c, Major, Minor), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 12
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Major uint16
|
||||
Minor uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Major = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Minor = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = Major
|
||||
b += 1
|
||||
|
||||
buf[b] = Minor
|
||||
b += 1
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetState
|
||||
// size: 8
|
||||
type GetStateCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getStateRequest(c, Window), cookie)
|
||||
return GetStateCookie{cookie}
|
||||
}
|
||||
|
||||
func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getStateRequest(c, Window), cookie)
|
||||
return GetStateCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetState
|
||||
// size: 12
|
||||
type GetStateReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
State byte
|
||||
Window xproto.Window
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetState
|
||||
func (cook GetStateCookie) Reply() (*GetStateReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getStateReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetState
|
||||
func getStateReply(buf []byte) *GetStateReply {
|
||||
v := new(GetStateReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.State = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetState
|
||||
func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetScreenCount
|
||||
// size: 8
|
||||
type GetScreenCountCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getScreenCountRequest(c, Window), cookie)
|
||||
return GetScreenCountCookie{cookie}
|
||||
}
|
||||
|
||||
func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getScreenCountRequest(c, Window), cookie)
|
||||
return GetScreenCountCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetScreenCount
|
||||
// size: 12
|
||||
type GetScreenCountReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
ScreenCount byte
|
||||
Window xproto.Window
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetScreenCount
|
||||
func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getScreenCountReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetScreenCount
|
||||
func getScreenCountReply(buf []byte) *GetScreenCountReply {
|
||||
v := new(GetScreenCountReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.ScreenCount = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetScreenCount
|
||||
func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GetScreenSize
|
||||
// size: 12
|
||||
type GetScreenSizeCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie)
|
||||
return GetScreenSizeCookie{cookie}
|
||||
}
|
||||
|
||||
func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie)
|
||||
return GetScreenSizeCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetScreenSize
|
||||
// size: 24
|
||||
type GetScreenSizeReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Width uint32
|
||||
Height uint32
|
||||
Window xproto.Window
|
||||
Screen uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetScreenSize
|
||||
func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getScreenSizeReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetScreenSize
|
||||
func getScreenSizeReply(buf []byte) *GetScreenSizeReply {
|
||||
v := new(GetScreenSizeReply)
|
||||
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.Width = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Height = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.Screen = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetScreenSize
|
||||
func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], Screen)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request IsActive
|
||||
// size: 4
|
||||
type IsActiveCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func IsActive(c *xgb.Conn) IsActiveCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(isActiveRequest(c), cookie)
|
||||
return IsActiveCookie{cookie}
|
||||
}
|
||||
|
||||
func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(isActiveRequest(c), cookie)
|
||||
return IsActiveCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for IsActive
|
||||
// size: 12
|
||||
type IsActiveReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
State uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request IsActive
|
||||
func (cook IsActiveCookie) Reply() (*IsActiveReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return isActiveReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for IsActive
|
||||
func isActiveReply(buf []byte) *IsActiveReply {
|
||||
v := new(IsActiveReply)
|
||||
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.State = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for IsActive
|
||||
func isActiveRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request QueryScreens
|
||||
// size: 4
|
||||
type QueryScreensCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryScreens(c *xgb.Conn) QueryScreensCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryScreensRequest(c), cookie)
|
||||
return QueryScreensCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryScreensRequest(c), cookie)
|
||||
return QueryScreensCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryScreens
|
||||
// size: (32 + xgb.Pad((int(Number) * 8)))
|
||||
type QueryScreensReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Number uint32
|
||||
// padding: 20 bytes
|
||||
ScreenInfo []ScreenInfo // size: xgb.Pad((int(Number) * 8))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryScreens
|
||||
func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryScreensReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryScreens
|
||||
func queryScreensReply(buf []byte) *QueryScreensReply {
|
||||
v := new(QueryScreensReply)
|
||||
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.Number = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.ScreenInfo = make([]ScreenInfo, v.Number)
|
||||
b += ScreenInfoReadList(buf[b:], v.ScreenInfo)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryScreens
|
||||
func queryScreensRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XINERAMA"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
7219
nexgb/xinput/xinput.go
Normal file
7219
nexgb/xinput/xinput.go
Normal file
File diff suppressed because it is too large
Load Diff
2164
nexgb/xprint/xprint.go
Normal file
2164
nexgb/xprint/xprint.go
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
package xgb
|
||||
package xproto
|
||||
|
||||
/*
|
||||
Tests for XGB.
|
||||
@ -21,17 +21,19 @@ import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/xgb"
|
||||
)
|
||||
|
||||
// The X connection used throughout testing.
|
||||
var X *Conn
|
||||
var X *xgb.Conn
|
||||
|
||||
// init initializes the X connection, seeds the RNG and starts waiting
|
||||
// for events.
|
||||
func init() {
|
||||
var err error
|
||||
|
||||
X, err = NewConn()
|
||||
X, err = xgb.NewConn()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -48,7 +50,7 @@ func init() {
|
||||
// TestSynchronousError purposefully causes a BadWindow error in a
|
||||
// MapWindow request, and checks it synchronously.
|
||||
func TestSynchronousError(t *testing.T) {
|
||||
err := X.MapWindowChecked(0).Check() // resource id 0 is always invalid
|
||||
err := MapWindowChecked(X, 0).Check() // resource 0 is always invalid
|
||||
if err == nil {
|
||||
t.Fatalf("MapWindow: A MapWindow request that should return an " +
|
||||
"error has returned a nil error.")
|
||||
@ -59,7 +61,7 @@ func TestSynchronousError(t *testing.T) {
|
||||
// TestAsynchronousError does the same thing as TestSynchronousError, but
|
||||
// grabs the error asynchronously instead.
|
||||
func TestAsynchronousError(t *testing.T) {
|
||||
X.MapWindow(0) // resource id 0 is always invalid
|
||||
MapWindow(X, 0) // resource id 0 is always invalid
|
||||
|
||||
evOrErr := waitForEvent(t, 5)
|
||||
if evOrErr.ev != nil {
|
||||
@ -77,7 +79,7 @@ func TestAsynchronousError(t *testing.T) {
|
||||
func TestCookieBuffer(t *testing.T) {
|
||||
n := (1 << 16) + 10
|
||||
for i := 0; i < n; i++ {
|
||||
X.NoOperation()
|
||||
NoOperation(X)
|
||||
}
|
||||
TestProperty(t)
|
||||
}
|
||||
@ -88,7 +90,7 @@ func TestCookieBuffer(t *testing.T) {
|
||||
func TestSequenceWrap(t *testing.T) {
|
||||
n := (1 << 16) + 10
|
||||
for i := 0; i < n; i++ {
|
||||
_, err := X.InternAtom(false, 5, "RANDO").Reply()
|
||||
_, err := InternAtom(X, false, 5, "RANDO").Reply()
|
||||
if err != nil {
|
||||
t.Fatalf("InternAtom: %s", err)
|
||||
}
|
||||
@ -127,13 +129,13 @@ func TestWindowEvents(t *testing.T) {
|
||||
// The geometry to set the window.
|
||||
gx, gy, gw, gh := 200, 400, 1000, 300
|
||||
|
||||
wid, err := X.NewWindowId()
|
||||
wid, err := NewWindowId(X)
|
||||
if err != nil {
|
||||
t.Fatalf("NewId: %s", err)
|
||||
}
|
||||
|
||||
screen := X.DefaultScreen() // alias
|
||||
err = X.CreateWindowChecked(screen.RootDepth, wid, screen.Root,
|
||||
screen := Setup(X).DefaultScreen(X) // alias
|
||||
err = CreateWindowChecked(X, screen.RootDepth, wid, screen.Root,
|
||||
0, 0, 500, 500, 0,
|
||||
WindowClassInputOutput, screen.RootVisual,
|
||||
CwBackPixel|CwOverrideRedirect, []uint32{0xffffffff, 1}).Check()
|
||||
@ -141,20 +143,20 @@ func TestWindowEvents(t *testing.T) {
|
||||
t.Fatalf("CreateWindow: %s", err)
|
||||
}
|
||||
|
||||
err = X.MapWindowChecked(wid).Check()
|
||||
err = MapWindowChecked(X, wid).Check()
|
||||
if err != nil {
|
||||
t.Fatalf("MapWindow: %s", err)
|
||||
}
|
||||
|
||||
// We don't listen in the CreateWindow request so that we don't get
|
||||
// a MapNotify event.
|
||||
err = X.ChangeWindowAttributesChecked(wid,
|
||||
err = ChangeWindowAttributesChecked(X, wid,
|
||||
CwEventMask, []uint32{EventMaskStructureNotify}).Check()
|
||||
if err != nil {
|
||||
t.Fatalf("ChangeWindowAttributes: %s", err)
|
||||
}
|
||||
|
||||
err = X.ConfigureWindowChecked(wid,
|
||||
err = ConfigureWindowChecked(X, wid,
|
||||
ConfigWindowX|ConfigWindowY|
|
||||
ConfigWindowWidth|ConfigWindowHeight,
|
||||
[]uint32{uint32(gx), uint32(gy), uint32(gw), uint32(gh)}).Check()
|
||||
@ -162,22 +164,6 @@ func TestWindowEvents(t *testing.T) {
|
||||
t.Fatalf("ConfigureWindow: %s", err)
|
||||
}
|
||||
|
||||
err = X.ConfigureWindowChecked(wid,
|
||||
ConfigWindowX|ConfigWindowY|
|
||||
ConfigWindowWidth|ConfigWindowHeight,
|
||||
[]uint32{uint32(gx + 2), uint32(gy), uint32(gw), uint32(gh)}).Check()
|
||||
if err != nil {
|
||||
t.Fatalf("ConfigureWindow: %s", err)
|
||||
}
|
||||
|
||||
err = X.ConfigureWindowChecked(wid,
|
||||
ConfigWindowX|ConfigWindowY|
|
||||
ConfigWindowWidth|ConfigWindowHeight,
|
||||
[]uint32{uint32(gx + 1), uint32(gy), uint32(gw), uint32(gh)}).Check()
|
||||
if err != nil {
|
||||
t.Fatalf("ConfigureWindow: %s", err)
|
||||
}
|
||||
|
||||
TestProperty(t)
|
||||
|
||||
evOrErr := waitForEvent(t, 5)
|
||||
@ -204,13 +190,13 @@ func TestWindowEvents(t *testing.T) {
|
||||
}
|
||||
|
||||
// Okay, clean up!
|
||||
err = X.ChangeWindowAttributesChecked(wid,
|
||||
err = ChangeWindowAttributesChecked(X, wid,
|
||||
CwEventMask, []uint32{0}).Check()
|
||||
if err != nil {
|
||||
t.Fatalf("ChangeWindowAttributes: %s", err)
|
||||
}
|
||||
|
||||
err = X.DestroyWindowChecked(wid).Check()
|
||||
err = DestroyWindowChecked(X, wid).Check()
|
||||
if err != nil {
|
||||
t.Fatalf("DestroyWindow: %s", err)
|
||||
}
|
||||
@ -234,7 +220,7 @@ func BenchmarkInternAtomsGood(b *testing.B) {
|
||||
b.StartTimer()
|
||||
cookies := make([]InternAtomCookie, b.N)
|
||||
for i := 0; i < b.N; i++ {
|
||||
cookies[i] = X.InternAtom(false, uint16(len(names[i])), names[i])
|
||||
cookies[i] = InternAtom(X, false, uint16(len(names[i])), names[i])
|
||||
}
|
||||
for _, cookie := range cookies {
|
||||
cookie.Reply()
|
||||
@ -251,7 +237,7 @@ func BenchmarkInternAtomsPoor(b *testing.B) {
|
||||
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
X.InternAtom(false, uint16(len(names[i])), names[i]).Reply()
|
||||
InternAtom(X, false, uint16(len(names[i])), names[i]).Reply()
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,24 +251,27 @@ func BenchmarkInternAtomsPoor(b *testing.B) {
|
||||
// It tests both requests with and without replies (GetProperty and
|
||||
// ChangeProperty respectively.)
|
||||
func changeAndGetProp(prop, val string) (string, error) {
|
||||
propAtom, err := X.InternAtom(false, uint16(len(prop)), prop).Reply()
|
||||
setup := Setup(X)
|
||||
root := setup.DefaultScreen(X).Root
|
||||
|
||||
propAtom, err := InternAtom(X, false, uint16(len(prop)), prop).Reply()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("InternAtom: %s", err)
|
||||
}
|
||||
|
||||
typName := "UTF8_STRING"
|
||||
typAtom, err := X.InternAtom(false, uint16(len(typName)), typName).Reply()
|
||||
typAtom, err := InternAtom(X, false, uint16(len(typName)), typName).Reply()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("InternAtom: %s", err)
|
||||
}
|
||||
|
||||
err = X.ChangePropertyChecked(PropModeReplace, X.DefaultScreen().Root,
|
||||
propAtom.Atom, typAtom.Atom, 8, uint32(len(val)), []byte(val)).Check()
|
||||
err = ChangePropertyChecked(X, PropModeReplace, root, propAtom.Atom,
|
||||
typAtom.Atom, 8, uint32(len(val)), []byte(val)).Check()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("ChangeProperty: %s", err)
|
||||
}
|
||||
|
||||
reply, err := X.GetProperty(false, X.DefaultScreen().Root, propAtom.Atom,
|
||||
reply, err := GetProperty(X, false, root, propAtom.Atom,
|
||||
GetPropertyTypeAny, 0, (1<<32)-1).Reply()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("GetProperty: %s", err)
|
||||
@ -343,8 +332,8 @@ func seqNames(n int) []string {
|
||||
|
||||
// evErr represents a value that is either an event or an error.
|
||||
type evErr struct {
|
||||
ev Event
|
||||
err Error
|
||||
ev xgb.Event
|
||||
err xgb.Error
|
||||
}
|
||||
|
||||
// channel used to pass evErrs.
|
1903
nexgb/xselinux/xselinux.go
Normal file
1903
nexgb/xselinux/xselinux.go
Normal file
File diff suppressed because it is too large
Load Diff
355
nexgb/xtest/xtest.go
Normal file
355
nexgb/xtest/xtest.go
Normal file
@ -0,0 +1,355 @@
|
||||
package xtest
|
||||
|
||||
/*
|
||||
This file was generated by xtest.xml on May 10 2012 4:20:29pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
)
|
||||
|
||||
// Init must be called before using the XTEST extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 5, "XTEST").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named XTEST could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["XTEST"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["XTEST"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["XTEST"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["XTEST"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["XTEST"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
const (
|
||||
CursorNone = 0
|
||||
CursorCurrent = 1
|
||||
)
|
||||
|
||||
// Request GetVersion
|
||||
// size: 8
|
||||
type GetVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func GetVersion(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie)
|
||||
return GetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func GetVersionUnchecked(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie)
|
||||
return GetVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for GetVersion
|
||||
// size: 10
|
||||
type GetVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
MajorVersion byte
|
||||
MinorVersion uint16
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request GetVersion
|
||||
func (cook GetVersionCookie) Reply() (*GetVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for GetVersion
|
||||
func getVersionReply(buf []byte) *GetVersionReply {
|
||||
v := new(GetVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
v.MajorVersion = buf[b]
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.MinorVersion = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetVersion
|
||||
func getVersionRequest(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = MajorVersion
|
||||
b += 1
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
xgb.Put16(buf[b:], MinorVersion)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CompareCursor
|
||||
// size: 12
|
||||
type CompareCursorCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func CompareCursor(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie)
|
||||
return CompareCursorCookie{cookie}
|
||||
}
|
||||
|
||||
func CompareCursorUnchecked(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie)
|
||||
return CompareCursorCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for CompareCursor
|
||||
// size: 8
|
||||
type CompareCursorReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
Same bool
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request CompareCursor
|
||||
func (cook CompareCursorCookie) Reply() (*CompareCursorReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return compareCursorReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for CompareCursor
|
||||
func compareCursorReply(buf []byte) *CompareCursorReply {
|
||||
v := new(CompareCursorReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Same = true
|
||||
} else {
|
||||
v.Same = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for CompareCursor
|
||||
func compareCursorRequest(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Window))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Cursor))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request FakeInput
|
||||
// size: 36
|
||||
type FakeInputCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for FakeInput
|
||||
func FakeInput(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie)
|
||||
return FakeInputCookie{cookie}
|
||||
}
|
||||
|
||||
func FakeInputChecked(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie)
|
||||
return FakeInputCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook FakeInputCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for FakeInput
|
||||
func fakeInputRequest(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) []byte {
|
||||
size := 36
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
buf[b] = Type
|
||||
b += 1
|
||||
|
||||
buf[b] = Detail
|
||||
b += 1
|
||||
|
||||
b += 2 // padding
|
||||
|
||||
xgb.Put32(buf[b:], Time)
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Root))
|
||||
b += 4
|
||||
|
||||
b += 8 // padding
|
||||
|
||||
xgb.Put16(buf[b:], uint16(RootX))
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], uint16(RootY))
|
||||
b += 2
|
||||
|
||||
b += 7 // padding
|
||||
|
||||
buf[b] = Deviceid
|
||||
b += 1
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request GrabControl
|
||||
// size: 8
|
||||
type GrabControlCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for GrabControl
|
||||
func GrabControl(c *xgb.Conn, Impervious bool) GrabControlCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(grabControlRequest(c, Impervious), cookie)
|
||||
return GrabControlCookie{cookie}
|
||||
}
|
||||
|
||||
func GrabControlChecked(c *xgb.Conn, Impervious bool) GrabControlCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(grabControlRequest(c, Impervious), cookie)
|
||||
return GrabControlCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook GrabControlCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for GrabControl
|
||||
func grabControlRequest(c *xgb.Conn, Impervious bool) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XTEST"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
if Impervious {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
b += 3 // padding
|
||||
|
||||
return buf
|
||||
}
|
2746
nexgb/xv/xv.go
Normal file
2746
nexgb/xv/xv.go
Normal file
File diff suppressed because it is too large
Load Diff
908
nexgb/xvmc/xvmc.go
Normal file
908
nexgb/xvmc/xvmc.go
Normal file
@ -0,0 +1,908 @@
|
||||
package xvmc
|
||||
|
||||
/*
|
||||
This file was generated by xvmc.xml on May 10 2012 4:20:29pm EDT.
|
||||
This file is automatically generated. Edit at your peril!
|
||||
*/
|
||||
|
||||
import (
|
||||
"github.com/BurntSushi/xgb"
|
||||
|
||||
"github.com/BurntSushi/xgb/xproto"
|
||||
"github.com/BurntSushi/xgb/xv"
|
||||
)
|
||||
|
||||
// Init must be called before using the XVideo-MotionCompensation extension.
|
||||
func Init(c *xgb.Conn) error {
|
||||
reply, err := xproto.QueryExtension(c, 25, "XVideo-MotionCompensation").Reply()
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case !reply.Present:
|
||||
return xgb.Errorf("No extension named XVideo-MotionCompensation could be found on on the server.")
|
||||
}
|
||||
|
||||
xgb.ExtLock.Lock()
|
||||
c.Extensions["XVideo-MotionCompensation"] = reply.MajorOpcode
|
||||
for evNum, fun := range xgb.NewExtEventFuncs["XVideo-MotionCompensation"] {
|
||||
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
||||
}
|
||||
for errNum, fun := range xgb.NewExtErrorFuncs["XVideo-MotionCompensation"] {
|
||||
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
||||
}
|
||||
xgb.ExtLock.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
xgb.NewExtEventFuncs["XVideo-MotionCompensation"] = make(map[int]xgb.NewEventFun)
|
||||
xgb.NewExtErrorFuncs["XVideo-MotionCompensation"] = make(map[int]xgb.NewErrorFun)
|
||||
}
|
||||
|
||||
// Skipping definition for base type 'Bool'
|
||||
|
||||
// Skipping definition for base type 'Float'
|
||||
|
||||
// Skipping definition for base type 'Card8'
|
||||
|
||||
// Skipping definition for base type 'Int16'
|
||||
|
||||
// Skipping definition for base type 'Int32'
|
||||
|
||||
// Skipping definition for base type 'Void'
|
||||
|
||||
// Skipping definition for base type 'Byte'
|
||||
|
||||
// Skipping definition for base type 'Int8'
|
||||
|
||||
// Skipping definition for base type 'Card16'
|
||||
|
||||
// Skipping definition for base type 'Char'
|
||||
|
||||
// Skipping definition for base type 'Card32'
|
||||
|
||||
// Skipping definition for base type 'Double'
|
||||
|
||||
type Context uint32
|
||||
|
||||
func NewContextId(c *xgb.Conn) (Context, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return Context(id), nil
|
||||
}
|
||||
|
||||
type Surface uint32
|
||||
|
||||
func NewSurfaceId(c *xgb.Conn) (Surface, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return Surface(id), nil
|
||||
}
|
||||
|
||||
type Subpicture uint32
|
||||
|
||||
func NewSubpictureId(c *xgb.Conn) (Subpicture, error) {
|
||||
id, err := c.NewId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return Subpicture(id), nil
|
||||
}
|
||||
|
||||
// 'SurfaceInfo' struct definition
|
||||
// Size: 24
|
||||
type SurfaceInfo struct {
|
||||
Id Surface
|
||||
ChromaFormat uint16
|
||||
Pad0 uint16
|
||||
MaxWidth uint16
|
||||
MaxHeight uint16
|
||||
SubpictureMaxWidth uint16
|
||||
SubpictureMaxHeight uint16
|
||||
McType uint32
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
// Struct read SurfaceInfo
|
||||
func SurfaceInfoRead(buf []byte, v *SurfaceInfo) int {
|
||||
b := 0
|
||||
|
||||
v.Id = Surface(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.ChromaFormat = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Pad0 = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MaxWidth = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.MaxHeight = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.SubpictureMaxWidth = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.SubpictureMaxHeight = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.McType = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Flags = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Struct list read SurfaceInfo
|
||||
func SurfaceInfoReadList(buf []byte, dest []SurfaceInfo) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = SurfaceInfo{}
|
||||
b += SurfaceInfoRead(buf[b:], &dest[i])
|
||||
}
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
// Struct write SurfaceInfo
|
||||
func (v SurfaceInfo) Bytes() []byte {
|
||||
buf := make([]byte, 24)
|
||||
b := 0
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Id))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], v.ChromaFormat)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.Pad0)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.MaxWidth)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.MaxHeight)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.SubpictureMaxWidth)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], v.SubpictureMaxHeight)
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], v.McType)
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], v.Flags)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Write struct list SurfaceInfo
|
||||
func SurfaceInfoListBytes(buf []byte, list []SurfaceInfo) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += xgb.Pad(len(structBytes))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Request QueryVersion
|
||||
// size: 4
|
||||
type QueryVersionCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func QueryVersion(c *xgb.Conn) QueryVersionCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(queryVersionRequest(c), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(queryVersionRequest(c), cookie)
|
||||
return QueryVersionCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for QueryVersion
|
||||
// size: 16
|
||||
type QueryVersionReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Major uint32
|
||||
Minor uint32
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request QueryVersion
|
||||
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return queryVersionReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for QueryVersion
|
||||
func queryVersionReply(buf []byte) *QueryVersionReply {
|
||||
v := new(QueryVersionReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Major = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Minor = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for QueryVersion
|
||||
func queryVersionRequest(c *xgb.Conn) []byte {
|
||||
size := 4
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 0 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ListSurfaceTypes
|
||||
// size: 8
|
||||
type ListSurfaceTypesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func ListSurfaceTypes(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie)
|
||||
return ListSurfaceTypesCookie{cookie}
|
||||
}
|
||||
|
||||
func ListSurfaceTypesUnchecked(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie)
|
||||
return ListSurfaceTypesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ListSurfaceTypes
|
||||
// size: (32 + xgb.Pad((int(Num) * 24)))
|
||||
type ListSurfaceTypesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Num uint32
|
||||
// padding: 20 bytes
|
||||
Surfaces []SurfaceInfo // size: xgb.Pad((int(Num) * 24))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ListSurfaceTypes
|
||||
func (cook ListSurfaceTypesCookie) Reply() (*ListSurfaceTypesReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return listSurfaceTypesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ListSurfaceTypes
|
||||
func listSurfaceTypesReply(buf []byte) *ListSurfaceTypesReply {
|
||||
v := new(ListSurfaceTypesReply)
|
||||
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.Num = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Surfaces = make([]SurfaceInfo, v.Num)
|
||||
b += SurfaceInfoReadList(buf[b:], v.Surfaces)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for ListSurfaceTypes
|
||||
func listSurfaceTypesRequest(c *xgb.Conn, PortId xv.Port) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 1 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(PortId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CreateContext
|
||||
// size: 24
|
||||
type CreateContextCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func CreateContext(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie)
|
||||
return CreateContextCookie{cookie}
|
||||
}
|
||||
|
||||
func CreateContextUnchecked(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie)
|
||||
return CreateContextCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for CreateContext
|
||||
// size: (36 + xgb.Pad((int(Length) * 4)))
|
||||
type CreateContextReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
WidthActual uint16
|
||||
HeightActual uint16
|
||||
FlagsReturn uint32
|
||||
// padding: 20 bytes
|
||||
PrivData []uint32 // size: xgb.Pad((int(Length) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request CreateContext
|
||||
func (cook CreateContextCookie) Reply() (*CreateContextReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return createContextReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for CreateContext
|
||||
func createContextReply(buf []byte) *CreateContextReply {
|
||||
v := new(CreateContextReply)
|
||||
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.WidthActual = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.HeightActual = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.FlagsReturn = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.PrivData = make([]uint32, v.Length)
|
||||
for i := 0; i < int(v.Length); i++ {
|
||||
v.PrivData[i] = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = xgb.Pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for CreateContext
|
||||
func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) []byte {
|
||||
size := 24
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 2 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(ContextId))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(PortId))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], Flags)
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DestroyContext
|
||||
// size: 8
|
||||
type DestroyContextCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DestroyContext
|
||||
func DestroyContext(c *xgb.Conn, ContextId Context) DestroyContextCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(destroyContextRequest(c, ContextId), cookie)
|
||||
return DestroyContextCookie{cookie}
|
||||
}
|
||||
|
||||
func DestroyContextChecked(c *xgb.Conn, ContextId Context) DestroyContextCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(destroyContextRequest(c, ContextId), cookie)
|
||||
return DestroyContextCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DestroyContextCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for DestroyContext
|
||||
func destroyContextRequest(c *xgb.Conn, ContextId Context) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 3 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(ContextId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CreateSurface
|
||||
// size: 12
|
||||
type CreateSurfaceCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func CreateSurface(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie)
|
||||
return CreateSurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
func CreateSurfaceUnchecked(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie)
|
||||
return CreateSurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for CreateSurface
|
||||
// size: (32 + xgb.Pad((int(Length) * 4)))
|
||||
type CreateSurfaceReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
// padding: 24 bytes
|
||||
PrivData []uint32 // size: xgb.Pad((int(Length) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request CreateSurface
|
||||
func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return createSurfaceReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for CreateSurface
|
||||
func createSurfaceReply(buf []byte) *CreateSurfaceReply {
|
||||
v := new(CreateSurfaceReply)
|
||||
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
|
||||
|
||||
b += 24 // padding
|
||||
|
||||
v.PrivData = make([]uint32, v.Length)
|
||||
for i := 0; i < int(v.Length); i++ {
|
||||
v.PrivData[i] = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = xgb.Pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for CreateSurface
|
||||
func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 4 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(ContextId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DestroySurface
|
||||
// size: 8
|
||||
type DestroySurfaceCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DestroySurface
|
||||
func DestroySurface(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie)
|
||||
return DestroySurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
func DestroySurfaceChecked(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie)
|
||||
return DestroySurfaceCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DestroySurfaceCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for DestroySurface
|
||||
func destroySurfaceRequest(c *xgb.Conn, SurfaceId Surface) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 5 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request CreateSubpicture
|
||||
// size: 20
|
||||
type CreateSubpictureCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func CreateSubpicture(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie)
|
||||
return CreateSubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
func CreateSubpictureUnchecked(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie)
|
||||
return CreateSubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for CreateSubpicture
|
||||
// size: (32 + xgb.Pad((int(Length) * 4)))
|
||||
type CreateSubpictureReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
WidthActual uint16
|
||||
HeightActual uint16
|
||||
NumPaletteEntries uint16
|
||||
EntryBytes uint16
|
||||
ComponentOrder []byte // size: 4
|
||||
// padding: 12 bytes
|
||||
PrivData []uint32 // size: xgb.Pad((int(Length) * 4))
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request CreateSubpicture
|
||||
func (cook CreateSubpictureCookie) Reply() (*CreateSubpictureReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return createSubpictureReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for CreateSubpicture
|
||||
func createSubpictureReply(buf []byte) *CreateSubpictureReply {
|
||||
v := new(CreateSubpictureReply)
|
||||
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.WidthActual = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.HeightActual = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.NumPaletteEntries = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.EntryBytes = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.ComponentOrder = make([]byte, 4)
|
||||
copy(v.ComponentOrder[:4], buf[b:])
|
||||
b += xgb.Pad(int(4))
|
||||
|
||||
b += 12 // padding
|
||||
|
||||
v.PrivData = make([]uint32, v.Length)
|
||||
for i := 0; i < int(v.Length); i++ {
|
||||
v.PrivData[i] = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
}
|
||||
b = xgb.Pad(b)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for CreateSubpicture
|
||||
func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) []byte {
|
||||
size := 20
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 6 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SubpictureId))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Context))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], XvimageId)
|
||||
b += 4
|
||||
|
||||
xgb.Put16(buf[b:], Width)
|
||||
b += 2
|
||||
|
||||
xgb.Put16(buf[b:], Height)
|
||||
b += 2
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request DestroySubpicture
|
||||
// size: 8
|
||||
type DestroySubpictureCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// Write request to wire for DestroySubpicture
|
||||
func DestroySubpicture(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie {
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie)
|
||||
return DestroySubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
func DestroySubpictureChecked(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie {
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie)
|
||||
return DestroySubpictureCookie{cookie}
|
||||
}
|
||||
|
||||
func (cook DestroySubpictureCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for DestroySubpicture
|
||||
func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte {
|
||||
size := 8
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 7 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SubpictureId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Request ListSubpictureTypes
|
||||
// size: 12
|
||||
type ListSubpictureTypesCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
func ListSubpictureTypes(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie {
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie)
|
||||
return ListSubpictureTypesCookie{cookie}
|
||||
}
|
||||
|
||||
func ListSubpictureTypesUnchecked(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie {
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie)
|
||||
return ListSubpictureTypesCookie{cookie}
|
||||
}
|
||||
|
||||
// Request reply for ListSubpictureTypes
|
||||
// size: (32 + xv.ImageFormatInfoListSize(Types))
|
||||
type ListSubpictureTypesReply struct {
|
||||
Sequence uint16
|
||||
Length uint32
|
||||
// padding: 1 bytes
|
||||
Num uint32
|
||||
// padding: 20 bytes
|
||||
Types []xv.ImageFormatInfo // size: xv.ImageFormatInfoListSize(Types)
|
||||
}
|
||||
|
||||
// Waits and reads reply data from request ListSubpictureTypes
|
||||
func (cook ListSubpictureTypesCookie) Reply() (*ListSubpictureTypesReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return listSubpictureTypesReply(buf), nil
|
||||
}
|
||||
|
||||
// Read reply into structure from buffer for ListSubpictureTypes
|
||||
func listSubpictureTypesReply(buf []byte) *ListSubpictureTypesReply {
|
||||
v := new(ListSubpictureTypesReply)
|
||||
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.Num = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 20 // padding
|
||||
|
||||
v.Types = make([]xv.ImageFormatInfo, v.Num)
|
||||
b += xv.ImageFormatInfoReadList(buf[b:], v.Types)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for ListSubpictureTypes
|
||||
func listSubpictureTypesRequest(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"]
|
||||
b += 1
|
||||
|
||||
buf[b] = 8 // request opcode
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(PortId))
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], uint32(SurfaceId))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
Loading…
Reference in New Issue
Block a user